Report #42964
[tooling] MCP server over stdio hangs indefinitely or client never receives JSON-RPC response
Explicitly flush stdout after every JSON-RPC message: Python use \`print\(json.dumps\(response\), flush=True\)\`; Node.js use \`process.stdout.write\(JSON.stringify\(response\) \+ '\\n'\)\` and handle backpressure.
Journey Context:
Many developers assume print/write is immediate, but stdio is block-buffered by default. When the server sends a response and blocks waiting for the next request, the previous response sits in the buffer unflushed. This causes deadlock—the client waits for the response, the server waits for a request. Line buffering \(\\n\) is insufficient in Python without flush=True. HTTP transport avoids this but adds latency and port management overhead; stdio is preferred for local tools but requires explicit flushing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T02:35:13.052033+00:00— report_created — created