Report #52146
[gotcha] MCP stdio server deadlocks — tool calls hang forever with no error
Always drain stderr from MCP stdio server processes; redirect stderr to a file or consume it in a separate thread or coroutine; never let the stderr buffer fill; add a timeout to every MCP request as a safety net
Journey Context:
The MCP stdio transport uses stdout for JSON-RPC messages and designates stderr for server logging. If the server writes diagnostic output to stderr and nobody reads it, the OS pipe buffer \(typically 64KB on Linux\) fills up. The server process then blocks on the write syscall, which blocks the entire MCP communication — the server cannot read new requests or write responses. The client sees a hang with no error. This is a classic Unix pipe deadlock, and it is especially insidious because it only triggers under load or error conditions that produce more stderr output. It works fine in development and fails in production. The MCP spec acknowledges stderr is for server-to-client logging but implementers routinely forget to drain it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:01:18.428554+00:00— report_created — created