/** * Constants and helpers for the JSON-RPC 2.0 / Model Context Protocol wire * format. Nothing in here knows about PlantUML. * @module mcp/protocol */ /** * Stateless protocol revisions: version and capabilities travel in the `_meta` * of every request, there is no `initialize` handshake. * @type {readonly string[]} */ export declare const MODERN_VERSIONS: readonly string[]; /** * Handshake-based revisions (`initialize` / `notifications/initialized`), * newest first. * @type {readonly string[]} */ export declare const LEGACY_VERSIONS: readonly string[]; /** Every revision this server speaks. */ export declare const SUPPORTED_VERSIONS: readonly string[]; /** Reserved `_meta` keys of the stateless revisions. */ export declare const META: Readonly<{ protocolVersion: "io.modelcontextprotocol/protocolVersion"; clientInfo: "io.modelcontextprotocol/clientInfo"; clientCapabilities: "io.modelcontextprotocol/clientCapabilities"; serverInfo: "io.modelcontextprotocol/serverInfo"; }>; /** JSON-RPC and MCP error codes used by this server. */ export declare const ERROR_CODES: Readonly<{ parseError: -32700; invalidRequest: -32600; methodNotFound: -32601; invalidParams: -32602; internalError: -32603; headerMismatch: -32020; unsupportedProtocolVersion: -32022; }>; /** * A JSON-RPC error that is sent back to the client. `httpStatus` is only used * by the HTTP transport. */ export declare class RpcError extends Error { code: number; data: unknown; httpStatus: number; /** * @param {number} code * @param {string} message * @param {{ data?: unknown, httpStatus?: number }} [details] */ constructor(code: number, message: string, details?: { data?: unknown; httpStatus?: number; }); } /** * @param {unknown} value * @returns {value is Record} */ export declare function isObject(value: unknown): value is Record; /** * Build an error response object. * @param {string | number | null} id * @param {number} code * @param {string} message * @param {unknown} [data] */ export declare function errorResponse(id: string | number | null, code: number, message: string, data?: unknown): { jsonrpc: string; id: string | number; error: { code: number; message: string; data?: undefined; } | { code: number; message: string; data: unknown; }; }; /** * Build a success response object. * @param {string | number} id * @param {Record} result */ export declare function resultResponse(id: string | number, result: Record): { jsonrpc: string; id: string | number; result: Record; }; /** * Remove control characters and cap the length of text that is echoed back to * a client (error messages, diagnostics). * @param {unknown} text * @param {number} [max] * @returns {string} */ export declare function clip(text: unknown, max?: number): string;