Constructors
Constructor
Parameters
options
FastMCPOptions
Returns
FastMCP
Properties
name
version
Accessors
address
Get Signature
Returns
ServerAddress | null
isRunning
Get Signature
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()
Parameters
cb
() =>Promise<void>
Returns
void
_dispatchPrompt()
Parameters
name
string
args
Record<string, string>
ctx
McpContext
Returns
Promise<
| InputRequiredResult
| {
description?: string;
messages: PromptMessage[];
}>
_dispatchResource()
Parameters
uri
string
params
Record<string, string> | undefined
ctx
McpContext
Returns
Promise<unknown>
_dispatchTool()
Parameters
name
string
rawArgs
unknown
ctx
McpContext
Returns
Promise<
| InputRequiredResult
| {
[key: string]: unknown;
}>
_modernFetch()
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()
Parameters
name
string
Returns
boolean
_removeResource()
Parameters
uri
string
Returns
boolean
_removeTool()
Parameters
name
string
Returns
boolean
addProvider()
Parameters
provider
|FastMCP
| {
server: FastMCP;
}
Returns
this
close()
Returns
Promise<void>
connect()
Parameters
transport
Transport
Returns
Promise<void>
customRoute()
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()
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()
Returns
McpContext
mount()
Parameters
child
FastMCP
prefix?
string
Returns
this
notifyResourceUpdated()
- Legacy connections (primary / stdio / legacy HTTP sessions) that called
resources/subscribeforuriare pushednotifications/resources/updateddirectly 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/listenstreams 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).
Parameters
uri
string
Returns
void
prompt()
Parameters
config
PromptConfig
handler
(args?) => unknown
Returns
void
resource()
Parameters
config
ResourceConfig
handler
(params?) => unknown
Returns
void
run()
Parameters
options?
RunOptions
Returns
Promise<void>
tool()
Call Signature
Type Parameters
S
S extends StandardSchemaV1<unknown, unknown>
Parameters
config
Omit<ToolConfig, "input"> & {
input: S;
}
handler
(args) => unknown
Returns
void
Call Signature
Parameters
config
ToolConfig
handler
(args) => unknown
Returns
void
transform()
Parameters
t
Transform
Returns
this
use()
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