JSON-RPC 2.0: Requests, Responses, Errors, and Notifications
Why it exists
MCP messages use the JSON-RPC 2.0 envelope, making it predictable to match requests with responses and send one-way events.
Message types
- Request: Contains
id,method, and optionalparams; a response is expected. - Successful response: Contains the same
idplusresult. - Error response: Contains the same
idplus a structurederror. - Notification: Contains
methodand optionalparams, but noid; no response is returned.
{
"jsonrpc": "2.0",
"id": 7,
"method": "tools/list",
"params": {}
}{
"jsonrpc": "2.0",
"id": 7,
"result": { "tools": [] }
}Protocol error versus tool error
- A malformed request or unknown method may result in a JSON-RPC or protocol error.
- A valid tool call whose business action fails may return a tool result with
isError: true. - Actionable tool errors can help the model correct its behavior safely.
Debugging checklist
- Do the request and response IDs match?
- Has an
idaccidentally been included in a notification? - Does the method name exactly match the specification?
- Are logs corrupting the transport's stdout output?
Can you explain it without the notes?
JSON-RPC 2.0: Requests, Responses, Errors, and Notifications
Use your own words. Explain an example and one limitation before checking the explanation.
Check your explanation
Why it exists
Turn this concept into a clear answer.
Practice this conceptYOUR NEXT STEP
Keep connecting the ideas.
Next lesson: Initialization, Lifecycle, and Capability NegotiationAdapted from 20_MCP_SERVER.md · “3. JSON-RPC 2.0: Requests, Responses, Errors, and Notifications”. Examples are study fragments; framework behavior can depend on your version.