Report #13936
[tooling] MCP stdio server hangs or deadlocks under rapid sequential tool calls
Always flush stdout after every JSON-RPC message and use line-buffered writes; never batch multiple requests into a single write without intermediate flushes.
Journey Context:
Developers assume stdio is 'simple' compared to HTTP, but unnamed pipes have finite buffers \(typically 4-64KB\). When the parent sends rapid requests, the child's stdout buffer fills if not drained, causing a deadlock when the child blocks on write\(\) while the parent blocks on read\(\) waiting for the previous response. HTTP SSE avoids this via TCP flow control, but stdio requires explicit line-buffering and immediate flush\(\) after each JSON-RPC message. The MCP SDKs hide this by using 'write-line-and-flush' patterns, but custom implementations often forget the flush, leading to intermittent hangs only reproducible under load.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:14:19.825269+00:00— report_created — created