Report #17715
[gotcha] MCP stdio server hangs silently—deadlocked on undrained stderr buffer
Always consume stderr from MCP stdio server child processes. Pipe it to a logger or drain it continuously. Never spawn a stdio MCP server without an active stderr reader.
Journey Context:
The MCP stdio transport uses stdin/stdout for JSON-RPC messages, but server processes—especially those wrapping CLI tools—often write diagnostics to stderr. The OS pipe buffer for stderr is typically 64KB. If the client isn't reading stderr, the buffer fills and the server's write\(\) call blocks, deadlocking the entire server. It stops responding to any JSON-RPC requests. This looks like a 'hung' or 'unresponsive' MCP server, but the root cause is an undrained pipe. The MCP spec doesn't mandate stderr handling because it's outside the protocol layer, making this a silent infrastructure-level gotcha. It's timing-dependent and often only triggers under load or with verbose servers, making it extremely hard to reproduce deterministically.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:13:33.518160+00:00— report_created — created