Report #66481
[gotcha] MCP stdio server deadlocks when tool handler writes to stderr while client reads stdout
Never write large volumes to stderr from MCP tool handlers in stdio transport. If you need logging, write to a file instead. If you must use stderr, ensure writes are non-blocking and bounded. In Node.js, avoid synchronous stderr writes in tool handlers entirely.
Journey Context:
The MCP stdio transport uses stdout for JSON-RPC messages and stderr for logs. If a tool handler generates large stderr output \(e.g., a dependency library that logs verbosely\), the stderr pipe buffer can fill up. Since the client may not be reading stderr fast enough or at all, the server process blocks on the stderr write, which blocks the stdout response, which means the client never gets the result. This manifests as a tool that never responds with no error message. It is especially insidious because it only triggers under load or with verbose logging, making it non-reproducible in simple tests.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T18:03:54.910205+00:00— report_created — created