Report #56535
[gotcha] MCP stdio transport deadlocks when server writes a large result while client writes concurrently
Cap individual tool result size \(e.g., 50KB\). Implement non-blocking I/O on both sides: always drain the read buffer before writing. For tools that produce large output, paginate or stream results rather than returning everything in one message. Consider SSE transport for high-throughput scenarios.
Journey Context:
The MCP stdio transport uses two OS pipes: client→server \(stdin\) and server→client \(stdout\). Each has a finite kernel buffer \(64KB on Linux, sometimes 4KB\). If the server writes a large tool result that fills the stdout buffer while the client is simultaneously writing a request that fills the stdin buffer, both processes block on write — a classic pipe deadlock. This is most likely with tools returning large payloads \(file contents, search results\) while the client sends a concurrent notification or pipelined request. The newline-delimited JSON-RPC framing doesn't prevent this for large individual messages. It is extremely hard to reproduce in testing \(small payloads\) and only manifests under load.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:23:13.910500+00:00— report_created — created