Closes the connection.
Attaches to the given transport, starts it, and starts listening for messages.
The server
object assumes ownership of the Transport, replacing any callbacks that have already been set, and expects that it is the only user of the Transport instance going forward.
Checks if the server is connected to a transport.
True if the server is connected
Registers a zero-argument prompt name
, which will run the given function when the client calls it.
Registers a zero-argument prompt name
(with a description) which will run the given function when the client calls it.
Registers a prompt name
accepting the given arguments, which must be an object containing named properties associated with Zod schemas. When the client calls it, the function will be run with the parsed and validated arguments.
Registers a prompt name
(with a description) accepting the given arguments, which must be an object containing named properties associated with Zod schemas. When the client calls it, the function will be run with the parsed and validated arguments.
Registers a resource name
at a fixed URI, which will use the given callback to respond to read requests.
Registers a resource name
at a fixed URI with metadata, which will use the given callback to respond to read requests.
Registers a resource name
with a template pattern, which will use the given callback to respond to read requests.
Registers a resource name
with a template pattern and metadata, which will use the given callback to respond to read requests.
Sends a prompt list changed event to the client, if connected.
Sends a resource list changed event to the client, if connected.
Sends a tool list changed event to the client, if connected.
Registers a zero-argument tool name
, which will run the given function when the client calls it.
Registers a zero-argument tool name
(with a description) which will run the given function when the client calls it.
Registers a tool taking either a parameter schema for validation or annotations for additional metadata.
This unified overload handles both tool(name, paramsSchema, cb)
and tool(name, annotations, cb)
cases.
Note: We use a union type for the second parameter because TypeScript cannot reliably disambiguate between ToolAnnotations and ZodRawShape during overload resolution, as both are plain object types.
Optional
destructiveHint?: booleanIf true, the tool may perform destructive updates to its environment. If false, the tool performs only additive updates.
(This property is meaningful only when readOnlyHint == false
)
Default: true
Optional
idempotentHint?: booleanIf true, calling the tool repeatedly with the same arguments will have no additional effect on the its environment.
(This property is meaningful only when readOnlyHint == false
)
Default: false
Optional
openWorldHint?: booleanIf true, this tool may interact with an "open world" of external entities. If false, the tool's domain of interaction is closed. For example, the world of a web search tool is open, whereas that of a memory tool is not.
Default: true
Optional
readOnlyHint?: booleanIf true, the tool does not modify its environment.
Default: false
Optional
title?: stringA human-readable title for the tool.
Registers a tool name
(with a description) taking either parameter schema or annotations.
This unified overload handles both tool(name, description, paramsSchema, cb)
and
tool(name, description, annotations, cb)
cases.
Note: We use a union type for the third parameter because TypeScript cannot reliably disambiguate between ToolAnnotations and ZodRawShape during overload resolution, as both are plain object types.
Optional
destructiveHint?: booleanIf true, the tool may perform destructive updates to its environment. If false, the tool performs only additive updates.
(This property is meaningful only when readOnlyHint == false
)
Default: true
Optional
idempotentHint?: booleanIf true, calling the tool repeatedly with the same arguments will have no additional effect on the its environment.
(This property is meaningful only when readOnlyHint == false
)
Default: false
Optional
openWorldHint?: booleanIf true, this tool may interact with an "open world" of external entities. If false, the tool's domain of interaction is closed. For example, the world of a web search tool is open, whereas that of a memory tool is not.
Default: true
Optional
readOnlyHint?: booleanIf true, the tool does not modify its environment.
Default: false
Optional
title?: stringA human-readable title for the tool.
Registers a tool with both parameter schema and annotations.
Optional
destructiveHint?: booleanIf true, the tool may perform destructive updates to its environment. If false, the tool performs only additive updates.
(This property is meaningful only when readOnlyHint == false
)
Default: true
Optional
idempotentHint?: booleanIf true, calling the tool repeatedly with the same arguments will have no additional effect on the its environment.
(This property is meaningful only when readOnlyHint == false
)
Default: false
Optional
openWorldHint?: booleanIf true, this tool may interact with an "open world" of external entities. If false, the tool's domain of interaction is closed. For example, the world of a web search tool is open, whereas that of a memory tool is not.
Default: true
Optional
readOnlyHint?: booleanIf true, the tool does not modify its environment.
Default: false
Optional
title?: stringA human-readable title for the tool.
Registers a tool with description, parameter schema, and annotations.
Optional
destructiveHint?: booleanIf true, the tool may perform destructive updates to its environment. If false, the tool performs only additive updates.
(This property is meaningful only when readOnlyHint == false
)
Default: true
Optional
idempotentHint?: booleanIf true, calling the tool repeatedly with the same arguments will have no additional effect on the its environment.
(This property is meaningful only when readOnlyHint == false
)
Default: false
Optional
openWorldHint?: booleanIf true, this tool may interact with an "open world" of external entities. If false, the tool's domain of interaction is closed. For example, the world of a web search tool is open, whereas that of a memory tool is not.
Default: true
Optional
readOnlyHint?: booleanIf true, the tool does not modify its environment.
Default: false
Optional
title?: stringA human-readable title for the tool.
The underlying Server instance, useful for advanced operations like sending notifications.