/** * MCP Protocol - JSON-RPC 2.0 over stdio for Model Context Protocol. * * Implements the low-level transport for MCP communication: * - Message framing (Content-Length headers) * - JSON-RPC request/response/notification * - Error codes per MCP spec */ export interface JSONRPCRequest { jsonrpc: '2.0'; id: string | number; method: string; params?: Record; } export interface JSONRPCResponse { jsonrpc: '2.0'; id: string | number | null; result?: any; error?: JSONRPCError; } export interface JSONRPCNotification { jsonrpc: '2.0'; method: string; params?: Record; } export interface JSONRPCError { code: number; message: string; data?: any; } export type JSONRPCMessage = JSONRPCRequest | JSONRPCResponse | JSONRPCNotification; export declare const ErrorCodes: { readonly ParseError: -32700; readonly InvalidRequest: -32600; readonly MethodNotFound: -32601; readonly InvalidParams: -32602; readonly InternalError: -32603; readonly ToolNotFound: -32001; readonly ToolExecutionError: -32002; readonly ServerNotInitialized: -32003; }; export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes]; export declare function createRequest(id: string | number, method: string, params?: Record): JSONRPCRequest; export declare function createResponse(id: string | number | null, result: any): JSONRPCResponse; export declare function createErrorResponse(id: string | number | null, code: number, message: string, data?: any): JSONRPCResponse; export declare function createNotification(method: string, params?: Record): JSONRPCNotification; /** * Encode a JSON-RPC message with Content-Length header for stdio transport. */ export declare function encodeMessage(msg: JSONRPCMessage): string; /** * Parse incoming data stream, extracting complete JSON-RPC messages. * Returns parsed messages and any remaining buffer. */ export declare function parseMessages(buffer: string): { messages: JSONRPCMessage[]; remaining: string; }; /** * Validate a JSON-RPC request. */ export declare function validateRequest(msg: any): msg is JSONRPCRequest; /** * Check if a message is a notification (no id). */ export declare function isNotification(msg: any): msg is JSONRPCNotification; /** * Check if a message is a response. */ export declare function isResponse(msg: any): msg is JSONRPCResponse; //# sourceMappingURL=mcp-protocol.d.ts.map