Report #35118
[gotcha] MCP tool call hangs indefinitely — server and client both waiting on each other
Implement message size limits and chunking for stdio transport. For tools that may return large payloads prefer SSE transport. Add explicit timeouts on every tool call \(e.g. 30 seconds\). Ensure the MCP server flushes stdout after each JSON-RPC message and the client drains the read buffer promptly. Test with artificially large responses to catch deadlock before production.
Journey Context:
The stdio transport in MCP uses process stdin/stdout for newline-delimited JSON-RPC messages. On most operating systems pipes have a finite kernel buffer — typically 64KB on Linux. If a tool result exceeds this buffer the server's write to stdout blocks. If the client isn't reading at that moment \(still processing, or waiting on something else\) you get a classic deadlock: server blocked on write, client blocked on something else. This is especially insidious because it only manifests with large tool results so it appears intermittent and load-dependent. It does not produce an error or log entry — both processes simply hang. The MCP spec acknowledges stdio as a transport but does not mandate size limits or chunking, leaving this as an implementation footgun.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T13:24:53.223772+00:00— report_created — created