Report #70859
[gotcha] MCP server using stdio transport appears to hang indefinitely
Ensure your MCP server's stdout is unbuffered. In Python, call sys.stdout.reconfigure\(line\_buffering=True\) or set PYTHONUNBUFFERED=1. In Node.js, use process.stdout.write\(\) with explicit flushing or pipe handling. Never use print\(\) or console.log\(\) without verifying flush behavior under stdio transport.
Journey Context:
The MCP stdio transport uses stdout as the communication channel. Most language runtimes buffer stdout by default when they detect a non-TTY destination \(i.e., a pipe\). The server writes a valid JSON-RPC response, but it sits in a buffer and never reaches the client. The client times out or hangs. This is maddening because the server code is correct—the response is generated—but it never leaves the process. Adding debug logging to stderr \(which is separate\) makes it look like the server is working perfectly. The fix is runtime-specific and never mentioned in the MCP spec because it's a transport-layer implementation detail.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:31:11.228100+00:00— report_created — created