What is JSON-RPC? The messages behind MCP
By Flavio
JSON-RPC carries requests and responses between MCP clients and servers. Learn to read message IDs, methods, results, and errors in a real coding-agent trace.
JSON-RPC is a protocol for calling operations using JSON messages. In MCP, it gives each request a method name and an ID so the client can match the response to the call.
What is MCP? records a complete filesystem-server conversation. Start there for the runnable client and actual messages.
How JSON-RPC works
A request names a method, with arguments in params. Its response carries the same id, plus either result or error. A notification omits the ID and gets no response. These rules come from the JSON-RPC specification.
MCP defines the operations carried inside those messages. Its base protocol uses JSON-RPC message types. The transport determines how the messages travel.
In coding tools
The MCP guides for Claude Code, Codex, Cursor, and Grok Build describe connecting servers that expose tools. Their setup commands configure the connection; you don’t normally compose protocol messages in the chat.
Details checked against each vendor’s documentation in November 2026.
A real example
The filesystem trace records this error object after the client asks for a tool the server doesn’t have:
{
"code": -32602,
"message": "Tool delete_file not found"
}
This object sits inside the response’s error field. Its code and message explain why the server rejected the call. Read the full trace alongside the tool-errors entry to distinguish this from a tool returning a failed result.
When to use it
Read JSON-RPC traces when building an MCP server or debugging the client-server boundary. Match IDs before assuming which call failed, especially when several requests overlap.
For everyday coding, use the client’s server controls and logs. The server-building tutorial shows how an SDK handles the message plumbing.
Pitfalls
The "2.0" in jsonrpc identifies JSON-RPC. MCP has its own protocol revision, and your server package has its own version. The MCP tutorial explains those separately.
A response can contain result while the tool itself reports failure through isError. Check the contents before treating the operation as completed.
Related on flaviocopes.com
- What is MCP? includes the complete request and response trace.
- Build an MCP server implements the handlers behind those calls.
- Discover CLI tools for coding agents uses CLI Tools Cabinet for shell-command discovery, a separate interface from MCP messages.
Related glossary entries
- stdio (MCP transport): Stdio connects an MCP client to a server process through standard input and output. Learn when to use it, how coding tools configure it, and common mistakes.
- Streamable HTTP (MCP transport): Streamable HTTP connects MCP clients to a server endpoint using HTTP requests. Learn how coding tools use it, when it helps, and how it differs from stdio.
- MCP tool errors: MCP tool errors report failures inside a tool result. Learn how isError differs from a protocol error, with real validation and empty-search examples.
Want me to talk about your product? You can sponsor this site.