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

Constructors

Constructor

new FastMCP(options): FastMCP;
Defined in: server/FastMCP.ts:237

Parameters

options
FastMCPOptions

Returns

FastMCP

Properties

name

readonly name: string;
Defined in: server/FastMCP.ts:210

version

readonly version: string;
Defined in: server/FastMCP.ts:211

Accessors

address

Get Signature

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

Methods

_addCloseCallback()

_addCloseCallback(cb): void;
Defined in: server/FastMCP.ts:1095 Register a callback invoked when this server is closed — used by proxy connections.

Parameters

cb
() => Promise<void>

Returns

void

_dispatchPrompt()

_dispatchPrompt(
   name, 
   args, 
   ctx): Promise<{
  description?: string;
  messages: PromptMessage[];
}>;
Defined in: server/FastMCP.ts:979 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<{ description?: string; messages: PromptMessage[]; }>

_dispatchResource()

_dispatchResource(
   uri, 
   params, 
   ctx): Promise<unknown>;
Defined in: server/FastMCP.ts:941 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()

_dispatchTool(
   name, 
   rawArgs, 
   ctx): Promise<{
[key: string]: unknown;
}>;
Defined in: server/FastMCP.ts:889 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<{ [key: string]: unknown; }>

_removePrompt()

_removePrompt(name): boolean;
Defined in: server/FastMCP.ts:872

Parameters

name
string

Returns

boolean

_removeResource()

_removeResource(uri): boolean;
Defined in: server/FastMCP.ts:858

Parameters

uri
string

Returns

boolean

_removeTool()

_removeTool(name): boolean;
Defined in: server/FastMCP.ts:851

Parameters

name
string

Returns

boolean

addProvider()

addProvider(provider): this;
Defined in: server/FastMCP.ts:1104 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()

close(): Promise<void>;
Defined in: server/FastMCP.ts:1478

Returns

Promise<void>

connect()

connect(transport): Promise<void>;
Defined in: server/FastMCP.ts:1266

Parameters

transport
Transport

Returns

Promise<void>

getContext()

getContext(): McpContext;
Defined in: server/FastMCP.ts:1255

Returns

McpContext

mount()

mount(child, prefix?): this;
Defined in: server/FastMCP.ts:1071 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

prompt()

prompt(config, handler): void;
Defined in: server/FastMCP.ts:829

Parameters

config
PromptConfig
handler
(args?) => unknown

Returns

void

resource()

resource(config, handler): void;
Defined in: server/FastMCP.ts:840

Parameters

config
ResourceConfig
handler
(params?) => unknown

Returns

void

run()

run(options?): Promise<void>;
Defined in: server/FastMCP.ts:1272

Parameters

options?
RunOptions

Returns

Promise<void>

tool()

Call Signature

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

Call Signature

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

transform()

transform(t): this;
Defined in: server/FastMCP.ts:880 Add a transform to the pipeline. Applied to list responses in registration order.

Parameters

t
Transform

Returns

this

use()

use(mw): this;
Defined in: server/FastMCP.ts:1249 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