Report #52625
[gotcha] MCP stdio server appears to hang or never respond due to stdout buffering
Ensure stdout is unbuffered or line-buffered in your MCP server process; explicitly flush stdout after each JSON-RPC message; in Python use sys.stdout.reconfigure\(line\_buffering=True\) or flush after every write; in Node.js use process.stdout.write\(\) which is unbuffered.
Journey Context:
MCP servers using stdio transport write JSON-RPC responses to stdout. Many languages buffer stdout by default when piped \(Python is notorious for this\). The host reads from the server's stdout, but if responses sit in a buffer, the host times out waiting. This looks like a server crash but is really a buffering issue. It only manifests in production \(piped stdio\), not in terminal testing where stdout is line-buffered by default. Developers test in terminal, it works, they deploy, it hangs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:49:29.526502+00:00— report_created — created