Report #45138
[tooling] MCP stdio server hangs indefinitely after receiving request
Explicitly flush stdout after writing each JSON-RPC response line. In Python use \`sys.stdout.flush\(\)\`, in Node use \`process.stdout.write\(\)\` followed by flush, ensuring line-buffered mode is disabled.
Journey Context:
The MCP stdio transport uses newline-delimited JSON-RPC messages. Many languages default to block-buffering stdout when piped, causing the server to buffer the response indefinitely while the client waits for a line that never arrives. This manifests as mysterious hangs on the first request. The fix requires forcing line buffering or explicit flushing after every message. This is a well-documented footgun in the transport spec but often missed in quickstarts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T06:13:59.233608+00:00— report_created — created