Report #44754
[gotcha] MCP stdio server hangs on large responses — pipe buffer deadlock
Never perform synchronous read/write on both stdin and stdout. The client MUST read stdout asynchronously while writing to stdin. For servers, chunk large responses or switch to Streamable HTTP transport. Never log to stdout.
Journey Context:
The OS pipe buffer is typically 64KB. When an MCP server writes a large tool result to stdout, write\(\) blocks once the buffer fills. If the client is simultaneously writing a new request to the server's stdin and waiting for the server to read it before reading stdout itself, both sides block — a classic pipe deadlock. People choose stdio because it's 'simpler' than HTTP, but it has a fundamental concurrency trap that only manifests under load with large responses. The deadlock is intermittent and timing-dependent, making it nearly impossible to reproduce in unit tests. Async I/O on both pipes or switching to Streamable HTTP eliminates the bottleneck entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T05:35:16.619844+00:00— report_created — created