/** * Model Context Protocol vocabulary shared by every transport. * * Nothing here knows about stdio, HTTP, the filesystem or the network: these * are the JSON-RPC shapes, the protocol revisions this server speaks, and the * helpers that turn a tool outcome into an MCP tool result. Keeping them free of * Node-only imports is what lets the Cloudflare Worker bundle the same code. */ /** Protocol revisions this server answers with; the newest is the default. */ export declare const PROTOCOL_VERSIONS: readonly ["2024-11-05", "2025-03-26", "2025-06-18", "2025-11-25"]; export type ProtocolVersion = (typeof PROTOCOL_VERSIONS)[number]; export declare const LATEST_PROTOCOL: ProtocolVersion; /** * Revision a Streamable HTTP server assumes when a client omits the * `MCP-Protocol-Version` header, as the 2025-06-18 transport specifies. */ export declare const DEFAULT_HTTP_PROTOCOL: ProtocolVersion; export declare function isSupportedProtocol(value: unknown): value is ProtocolVersion; /** * JSON-RPC batching exists only in revision 2025-03-26 (and is tolerated for * 2024-11-05 clients); revision 2025-06-18 removed it. Revisions are ISO dates, * so string order is chronological order. */ export declare function protocolAllowsBatching(version: ProtocolVersion): boolean; export interface JsonRpcRequest { jsonrpc: '2.0'; id?: string | number | null; method: string; params?: Record; } export interface JsonRpcResponse { jsonrpc: '2.0'; id: string | number | null; result?: unknown; error?: { code: number; message: string; }; } /** JSON-RPC 2.0 error codes this server emits. */ export declare const JSON_RPC_ERRORS: { readonly parse: -32700; readonly invalidRequest: -32600; readonly methodNotFound: -32601; readonly invalidParams: -32602; }; export declare function rpcError(id: string | number | null, code: number, message: string): JsonRpcResponse; export interface ToolResult { content: { type: 'text'; text: string; }[]; isError?: boolean; } /** A successful tool result carrying text, or JSON pretty-printed as text. */ export declare const text: (value: unknown) => ToolResult; /** A tool-level failure: the model sees it and can correct its call. */ export declare const failure: (value: unknown) => ToolResult; /** * A tool argument the caller got wrong. Its message is written for the caller, * so every transport may show it, unlike an arbitrary runtime error. */ export declare class ToolArgumentError extends TypeError { readonly name = "ToolArgumentError"; } /** * Map a thrown error to a tool failure. A compiler error keeps its code, JSON * path and diagnostics so the caller can fix the spec; anything else reports * only its message. */ export declare function toolErrorResult(error: unknown): ToolResult; /** * Map a thrown error to a tool failure a hosted server may show a stranger. * Compiler errors and argument errors keep their message, because the caller * needs it to fix the call; anything else (a storage, binding or runtime fault) * becomes a generic `INTERNAL_ERROR`, so no internal message leaves the server. */ export declare function publicToolErrorResult(error: unknown): ToolResult; //# sourceMappingURL=mcp-protocol.d.ts.map