/** * JSON-RPC 2.0 over stdio, by hand, because of what this package is. * * The obvious implementation imports `@modelcontextprotocol/sdk`. It was written * that way first, and thirteen tests passed against a real process. Then * `publish.test.js` refused it: *every* publishable package in this repository * carries no runtime dependencies, and the reason `security.test.js` gives is * "the core and the CLI process untrusted text; every runtime dependency is code * that would run on that text with no review from this project." * * That argument applies here with **more** force than anywhere else in the * repository, not less. An MCP server reads prompts handed to it by a model, in a * process the user did not start by hand, and the SDK plus its own dependency * tree is a large amount of somebody else's code sitting on that path. Relaxing * the invariant at the exact point it matters most would have been the wrong * trade, so the invariant won and this file exists. * * **What that costs, stated plainly.** A hand-written protocol is where subtle * incompatibility lives. This implements the parts a tools-only server needs — * `initialize`, `notifications/initialized`, `tools/list`, `tools/call`, and * `ping` — and nothing else. No resources, no prompts, no sampling, no * completion, no server-initiated requests. A client asking for any of those gets * a proper `-32601 Method not found` rather than silence. It has been driven by a * raw newline-delimited client in the tests; it has not been driven by every real * MCP client in existence, and that is the honest limit of the claim. */ /** The version this server implements. Echoed back when the client asks for it. */ export declare const PROTOCOL_VERSION = "2025-06-18"; export interface JsonRpcRequest { jsonrpc: '2.0'; id?: string | number | null; method: string; params?: unknown; } /** Standard JSON-RPC codes, plus the one MCP adds for bad tool arguments. */ export declare const ERROR: { readonly parse: -32700; readonly invalidRequest: -32600; readonly methodNotFound: -32601; readonly invalidParams: -32602; readonly internal: -32603; }; export interface ToolDefinition { name: string; title: string; description: string; /** JSON Schema, written out, since there is no schema library to build one. */ inputSchema: Record; /** * Validates and coerces the arguments, or throws with a message the model can * act on. Returns the text to send back. */ run: (args: Record) => string; } /** Thrown by a tool when its arguments are wrong. Distinguished from a crash. */ export declare class InvalidArguments extends Error { } export interface ServerInfo { name: string; version: string; instructions: string; } /** * Handles one decoded message and returns the response, or `null` for a * notification. * * Pure: takes a message, returns a message. The transport below is what touches * streams, so every dispatch rule here is testable without a process. */ export declare function handle(message: unknown, tools: readonly ToolDefinition[], info: ServerInfo): object | null; /** * Reads newline-delimited JSON from a stream and writes replies to another. * * Line-delimited rather than the Content-Length framing LSP uses, because that is * what MCP's stdio transport specifies. A message may not contain a raw newline, * which `JSON.stringify` guarantees. */ export declare function serve(input: NodeJS.ReadableStream, output: NodeJS.WritableStream, tools: readonly ToolDefinition[], info: ServerInfo): void; //# sourceMappingURL=rpc.d.ts.map