JSON-RPC 2.0 in MCP
Definition
MCP encodes all protocol messages as JSON-RPC 2.0. A request has a method, optional params, and an id. Responses match the id and contain either result or error. Notifications have no id and expect no response.
Message types
**Request**: `{ jsonrpc: '2.0', method: string, params?: object, id: string|number }`
**Response**: `{ jsonrpc: '2.0', result: unknown, id: string|number }` or `{ jsonrpc: '2.0', error: { code: number, message: string, data?: unknown }, id: string|number }`
**Notification**: `{ jsonrpc: '2.0', method: string, params?: object }` (no id)
Standard error codes
-32700 Parse error -32600 Invalid request -32601 Method not found -32602 Invalid params -32603 Internal error -32000 to -32099 Server-defined errors