High-level MCP server facade for registering tools, resources, and prompts, and dispatching protocol requests with schema validation.
export class McpServer {
/**
* The underlying {@linkcode Server} instance, useful for advanced operations like sending notifications.
*/
public readonly server: Server;
private _registeredResources: { [uri: string]: RegisteredResource } = {};
private _registeredResourceTemplates: {
[name: string]: RegisteredResourceTemplate;
} = {};
private _registeredTools: { [name: string]: RegisteredTool } = {};
private _registeredPrompts: { [name: string]: RegisteredPrompt } = {};
/**
* Per-tool JSON-converted `inputSchema`, memoized so the SEP-2243
* registration-time scan and the pre-dispatch validation step share one
* conversion instead of paying it twice per request under the
* per-request-factory `createMcpHandler` model.
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key