Report #95470
[gotcha] MCP tool calls hang indefinitely or return empty results with stdio transport
Ensure MCP server implementations explicitly flush stdout after writing each JSON-RPC message. In Python, call sys.stdout.flush\(\) after every write, or set line buffering at startup. In Node.js, process.stdout.write\(\) is unbuffered by default but verify any wrapper streams are flushed. In Go, call os.Stdout.Sync\(\) after writes.
Journey Context:
The MCP stdio transport relies on newline-delimited JSON over stdout. Most languages buffer stdout by default when it is not connected to a TTY—and MCP servers are launched as subprocesses with piped stdout, not terminal stdout. This means the server writes a response that sits in a buffer and never reaches the client. It manifests as tools that 'never respond' or have intermittent failures. It is especially insidious because it can work in manual testing \(where you might run the server in a terminal with line-buffered stdout\) but fails in production \(where the client launches the server as a subprocess with piped stdout\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:49:32.676712+00:00— report_created — created