Skip to main content
Defined in: server/FastMCP.ts:444

Constructors

Constructor

Defined in: server/FastMCP.ts:507

Parameters

options
FastMCPOptions

Returns

FastMCP

Properties

name

Defined in: server/FastMCP.ts:445

version

Defined in: server/FastMCP.ts:446

Accessors

address

Get Signature

Defined in: server/FastMCP.ts:1892 The bound address after run() resolves for the http transport. Null for stdio or before run().
Returns
ServerAddress | null

isRunning

Get Signature

Defined in: server/FastMCP.ts:1901 Whether run() or connect() has been called on this instance. Used by the CLI’s entrypoint loader to detect servers that already started themselves via top-level code, so it doesn’t attempt to start them a second time.
Returns
boolean

Methods

_addCloseCallback()

Defined in: server/FastMCP.ts:1724 Register a callback invoked when this server is closed — used by proxy connections.

Parameters

cb
() => Promise<void>

Returns

void

_dispatchPrompt()

Defined in: server/FastMCP.ts:1584 Dispatch a prompt render through this server’s middleware chain using an inherited context.

Parameters

name
string
args
Record<string, string>
ctx
McpContext

Returns

Promise< | InputRequiredResult | { description?: string; messages: PromptMessage[]; }>

_dispatchResource()

Defined in: server/FastMCP.ts:1544 Run a resource read through this server’s middleware chain using an inherited context. Returns the raw handler result so the parent can apply convertResourceResult with the actual requested URI (important for template resources).

Parameters

uri
string
params
Record<string, string> | undefined
ctx
McpContext

Returns

Promise<unknown>

_dispatchTool()

Defined in: server/FastMCP.ts:1485 Dispatch a tool call through this server’s middleware chain using an inherited context. Used by parent servers to honour child-level middleware when routing mounted tool calls.

Parameters

name
string
rawArgs
unknown
ctx
McpContext

Returns

Promise< | InputRequiredResult | { [key: string]: unknown; }>

_modernFetch()

Defined in: server/FastMCP.ts:1948 Modern-era (2026-07-28) in-process fetch entrypoint — the McpServerLike duck-type hook fastmcp-ts/client’s Client looks for when a caller pins modern era for an in-process server (versionNegotiation: { mode: { pin: '2026-07-28' } } }). Delegates directly to the same createMcpHandler instance the real HTTP modern path uses (_getModernHandler), so this is the identical dispatch a real network connection would get — no sockets, same code. Modern-only (legacy: 'reject'): a client using 'auto' or 'legacy' negotiation instead goes through connect() + InMemoryTransport (2025-era only), unaffected by this method.

Parameters

request
Request
options?
McpHandlerRequestOptions

Returns

Promise<Response>

_removePrompt()

Defined in: server/FastMCP.ts:1468

Parameters

name
string

Returns

boolean

_removeResource()

Defined in: server/FastMCP.ts:1454

Parameters

uri
string

Returns

boolean

_removeTool()

Defined in: server/FastMCP.ts:1447

Parameters

name
string

Returns

boolean

addProvider()

Defined in: server/FastMCP.ts:1733 Register a provider (FastMCPApp or FastMCP) on this server. All tools, resources, and prompts from the provider are mounted without a prefix. For FastMCPApp, pass provider.server; for FastMCP, pass directly.

Parameters

provider
| FastMCP | { server: FastMCP; }

Returns

this

close()

Defined in: server/FastMCP.ts:2449

Returns

Promise<void>

connect()

Defined in: server/FastMCP.ts:1905

Parameters

transport
Transport

Returns

Promise<void>

customRoute()

Defined in: server/FastMCP.ts:1443 Register a custom HTTP route on the listener run() starts — e.g. a Kubernetes liveness/readiness probe. The handler owns the whole exchange: no MCP auth, no DNS-rebinding guards, and no CORS headers run in front of it. Matching is exact-path (query string ignored); methods default to GET. Routes never serve on stdio or through fetch() — a framework embedding fetch() owns its own routing (same posture as dnsRebinding).

Parameters

config
CustomRouteConfig
handler
CustomRouteHandler

Returns

void

fetch()

Defined in: server/FastMCP.ts:1924 Serve an MCP request through a web-standard, fetch-native HTTP entrypoint. This entrypoint is always stateless and does not require run(): legacy (2025-era) requests use a fresh server instance per request, while modern (2026-07-28) requests share the instance’s modern handler and event bus. Authentication is deliberately external — options.authInfo is trusted and passed unchanged into the protocol handler, where it is exposed as ctx.auth. The embedding framework also owns Host/Origin validation and should abort its carrying requests during shutdown; stateless legacy response streams follow that request lifecycle, while close() terminates modern exchanges and streams.

Parameters

request
Request
options?
McpHandlerRequestOptions

Returns

Promise<Response>

getContext()

Defined in: server/FastMCP.ts:1885

Returns

McpContext

mount()

Defined in: server/FastMCP.ts:1700 Mount a child server onto this server. All tools, resources, and prompts from the child become accessible via this server. Pass a prefix to namespace names and prevent collisions.

Parameters

child
FastMCP
prefix?
string

Returns

this

notifyResourceUpdated()

Defined in: server/FastMCP.ts:1322 Signal that a resource changed and any subscriber should re-read it. This is the SINGLE change signal for resource updates across both eras — the legacy per-session push and the modern subscriptions/listen bus are driven from here:
  • Legacy connections (primary / stdio / legacy HTTP sessions) that called resources/subscribe for uri are pushed notifications/resources/updated directly on their live session (subscription set kept in per-session state).
  • The modern handler’s bus (W3) is published to as well; it does its own per-stream filtering, delivering only to subscriptions/listen streams that opted in to this URI. Optional chaining keeps it a no-op until the first modern HTTP request has actually built the handler.
  • A modern stdio connection is sent the notification unconditionally; the SDK’s stdio listen router intercepts it and fans out per honored subscription (or drops it when no stream opted in to the URI).
Unsubscribed sessions (and the modern streams that never opted in) receive nothing, so calling this for a URI with no subscribers is safe and cheap.

Parameters

uri
string

Returns

void

prompt()

Defined in: server/FastMCP.ts:1413

Parameters

config
PromptConfig
handler
(args?) => unknown

Returns

void

resource()

Defined in: server/FastMCP.ts:1424

Parameters

config
ResourceConfig
handler
(params?) => unknown

Returns

void

run()

Defined in: server/FastMCP.ts:1952

Parameters

options?
RunOptions

Returns

Promise<void>

tool()

Call Signature

Defined in: server/FastMCP.ts:1398
Type Parameters
S
S extends StandardSchemaV1<unknown, unknown>
Parameters
config
Omit<ToolConfig, "input"> & { input: S; }
handler
(args) => unknown
Returns
void

Call Signature

Defined in: server/FastMCP.ts:1403
Parameters
config
ToolConfig
handler
(args) => unknown
Returns
void

transform()

Defined in: server/FastMCP.ts:1476 Add a transform to the pipeline. Applied to list responses in registration order.

Parameters

t
Transform

Returns

this

use()

Defined in: server/FastMCP.ts:1878 Add a middleware to the pipeline. Can be called at any point before the first request arrives. setup() is called immediately on the primary server so that notification handlers and other server-level side-effects are active before connect() / run() is called. HTTP sessions created after use() will also have setup() called via _makeServer().

Parameters

mw
Middleware

Returns

this