Spot the bug revealed by JSON-RPC tracing in this MCP exchange
Click any words you think contain an error. Click again to unmark.
The response carries id 2 but the request was id 1. JSON-RPC correlates by echoing the request id, so the client can never match this reply.
Picture a busy coffee counter where everyone orders at once. The barista hands each order a numbered ticket and calls that number when the drink is ready. You hold ticket 1, but the barista shouts 'order 2!' and sets down your latte. You have no way to know it is yours, so you keep waiting while the coffee goes cold on the counter. JSON-RPC works the same way. The client tags each request with an id and keeps a list of tickets it is still waiting on. The server must reply with the exact same id so the client can match the answer to the right question. Here the request used id 1 and the reply came back as id 2, so the client never finds a match and the call stalls.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: identify the id mismatch, explain the pending-request map and correlation, give the two server bugs that cause it, and note why tracing is the tool that catches it.
| Aspect | Correct response | Buggy response shown |
|---|---|---|
| id value | Echoes request id (1) | New value (2) |
| Client lookup | Finds pending entry for id 1 | Finds nothing for id 2 |
| Outcome | Call resolves with the result | Original call hangs and times out |
| Data payload | Alice's row, correct | Alice's row, still correct |
Real products, models, and research that use this idea.
- The mcp-inspector tool surfaces this by printing paired request and response frames so a mismatched id is visible at a glance.
- Claude Code and Cursor multiplex many concurrent tools/call requests over one stdio connection, so id correlation is what keeps replies from crossing wires.
- An MCP server built on a naive JSON-RPC library that auto-numbers outgoing messages will stamp wrong ids and cause intermittent client hangs.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you design the client's pending-request map to detect a mismatched or duplicate id early?
QHow do JSON-RPC notifications change the correlation story, and how should a client handle them?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Looking at the SQL or the result payload for the bug. The transport layer is broken first: the response id does not match the request id, so correlation fails.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.