/** * Shared JSON-RPC types and utilities for MCP servers * * @module cli/mcp/jsonrpc */ import type { InferSchema } from "../../src/extensions/schema/index.js"; /** * JSON-RPC 2.0 request (validated at runtime for external input) */ export declare const getJSONRPCRequestSchema: () => import("../../src/internal-agents/schema.js").Schema; id: import("../../src/internal-agents/schema.js").Schema; method: import("../../src/internal-agents/schema.js").Schema; params: import("../../src/internal-agents/schema.js").Schema; }>>; export declare const JSONRPCRequestSchema: import("../../src/internal-agents/schema.js").Schema; id: import("../../src/internal-agents/schema.js").Schema; method: import("../../src/internal-agents/schema.js").Schema; params: import("../../src/internal-agents/schema.js").Schema; }>>; export type JSONRPCRequest = InferSchema>; /** * JSON-RPC 2.0 response */ export interface JSONRPCResponse { jsonrpc: "2.0"; id?: string | number | null; result?: unknown; error?: { code: number; message: string; data?: unknown; }; } /** * JSON-RPC standard error codes */ export declare const JSONRPC_ERRORS: { readonly PARSE_ERROR: -32700; readonly INVALID_REQUEST: -32600; readonly METHOD_NOT_FOUND: -32601; readonly INVALID_PARAMS: -32602; readonly INTERNAL_ERROR: -32603; }; /** * Error with a JSON-RPC error code attached. * Preserves stack traces unlike throwing plain objects. */ export declare class JsonRpcError extends Error { readonly code: number; constructor(code: number, message: string); } /** * Create a JSON-RPC parse error response */ export declare function parseError(_error?: unknown): JSONRPCResponse; /** * Create a JSON-RPC invalid-request response without reflecting validator * diagnostics back to an untrusted client. */ export declare function invalidRequestError(_error?: unknown): JSONRPCResponse; /** * Create a generic JSON-RPC internal-error response for failures outside a * method handler's normal error boundary. */ export declare function internalError(id: string | number | null | undefined): JSONRPCResponse; /** * Create a JSON-RPC success response */ export declare function successResponse(id: string | number | undefined, result: unknown): JSONRPCResponse; /** * Create a JSON-RPC error response */ export declare function errorResponse(id: string | number | undefined, e: unknown, code?: number): JSONRPCResponse; /** * Supported MCP protocol versions (newest first). * Shared across all CLI MCP servers so the version list is maintained in one place. */ export declare const MCP_SUPPORTED_VERSIONS: [string, ...string[]]; /** * Safely extract a record from unknown params (mirrors src/mcp toParamsRecord). */ export declare function toParamsRecord(params: unknown): Record; /** * Negotiate MCP protocol version: echo the client's version if supported, * otherwise fall back to the newest supported version. */ export declare function negotiateVersion(params: unknown): string; /** * Build a complete MCP initialize result with negotiated version, * capabilities, serverInfo, and instructions. */ export declare function buildInitializeResult(params: unknown, serverInfo: { name: string; title: string; version: string; description: string; }, instructions: string): Record; /** * Validate and extract tools/call params */ export declare const getToolsCallParamsSchema: () => import("../../src/internal-agents/schema.js").Schema; arguments: import("../../src/internal-agents/schema.js").Schema | undefined>; }>>; export declare const ToolsCallParamsSchema: import("../../src/internal-agents/schema.js").Schema; arguments: import("../../src/internal-agents/schema.js").Schema | undefined>; }>>; /** * Validate and extract prompts/get params */ export declare const getPromptsGetParamsSchema: () => import("../../src/internal-agents/schema.js").Schema; }>>; export declare const PromptsGetParamsSchema: import("../../src/internal-agents/schema.js").Schema; }>>; /** * Validate and extract resources/read params */ export declare const getResourcesReadParamsSchema: () => import("../../src/internal-agents/schema.js").Schema; }>>; export declare const ResourcesReadParamsSchema: import("../../src/internal-agents/schema.js").Schema; }>>; //# sourceMappingURL=jsonrpc.d.ts.map