Report #3997
[gotcha] After reconnecting to an MCP server, a delayed response from the previous connection is misinterpreted as the response to a new request
Use monotonically increasing request IDs that never reset across reconnections within the same client process lifetime. Include a session or connection identifier in request metadata. On reconnect, discard any in-flight requests from the previous session and re-issue them with new IDs. Never reuse an ID.
Journey Context:
MCP uses JSON-RPC 2.0, where each request has a numeric or string ID. Many implementations use simple incrementing counters starting from 0 or 1. After a disconnect-reconnect cycle, the counter resets. If the server was still processing a request when the connection dropped, it may eventually send a response to the old connection's stream. If the client has reconnected and sent a new request with the same reused ID, and the stale response arrives first \(via a cached, proxied, or buffered connection\), the client matches it to the new request — silently returning wrong data. This is especially likely with SSE transport where event streams can overlap during reconnection or be served from a proxy buffer. The failure is invisible: the response is well-formed JSON-RPC, it just answers the wrong question. The fix is to ensure IDs are globally unique across the client process lifetime, not just the current connection.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:38:25.685314+00:00— report_created — created