Server
An MCP server is responsible for storing features and handling new connections.
This server automatically responds to the initialization flow as initiated by the client. You can register tools, prompts, and resources using addTool, addPrompt, and addResource. The server will then automatically handle listing and retrieval requests from the client.
In case the server supports feature list notification or resource substitution, the server will automatically send notifications for all connected clients. Currently, after subscription to a resource, the server will NOT send the subscription confirmation as this response schema is not defined in the protocol.
Parameters
Information about this server implementation (name, version).
Configuration options for the server.
Optional provider for instructions from the server to the client about how to use this server. The provider is called each time a new session is started to support dynamic instructions.
A block to configure the mcp server.
Constructors
Alternative constructor that provides the instructions directly as a string.
Properties
Provides a snapshot of all prompts currently registered in the server
Provides a snapshot of all resources currently registered in the server
Provides a snapshot of all resource templates currently registered in the server.
Provides a snapshot of all sessions currently registered in the server
Provides a snapshot of all tools currently registered in the server
Functions
Registers a single prompt. The client can then retrieve the prompt.
Registers a single prompt by constructing a Prompt from given parameters.
Registers multiple prompts at once.
Registers a single resource. The client can then read the resource content.
Registers multiple resources at once.
Registers a resource template. Clients can discover it via resources/templates/list and read matching URIs via resources/read.
Registers a resource template by constructing a ResourceTemplate from given parameters.
Registers a single tool. The client can then call this tool.
Registers multiple tools at once.
Returns the ClientConnection for the session identified by sessionId.
Triggers ClientConnection.createElicitation request for session by provided sessionId.
Triggers URL mode ClientConnection.createElicitation request for session by provided sessionId.
Triggers ClientConnection.createMessage request for session by provided sessionId.
Starts a new server session with the given transport and initializes internal request handlers based on the server's capabilities.
Triggers ClientConnection.listRoots request for session by provided sessionId.
Triggers ClientConnection.ping request for session by provided sessionId.
Removes a single prompt by name.
Removes multiple prompts at once.
Removes a single resource by URI.
Removes multiple resources at once.
Removes a resource template by its URI template string.
Removes a single tool by name.
Removes multiple tools at once.
Triggers ClientConnection.sendElicitationComplete for session by provided sessionId.
Triggers ClientConnection.sendLoggingMessage for session by provided sessionId.
Triggers ClientConnection.sendPromptListChanged for session by provided sessionId.
Triggers ClientConnection.sendResourceListChanged for session by provided sessionId.
Triggers ClientConnection.sendResourceUpdated for session by provided sessionId.
Triggers ClientConnection.sendToolListChanged for session by provided sessionId.