Report #39317
[tooling] MCP server over stdio hanging or messages not reaching client
When using stdio transport, explicitly flush stdout after every JSON-RPC message \(e.g., \`sys.stdout.flush\(\)\` in Python, \`process.stdout.write\` \+ \`flush\` in Node\); consider HTTP transport with SSE for high-frequency updates or large payloads
Journey Context:
The MCP stdio transport uses line-delimited JSON-RPC over stdout. Many developers assume stdout is unbuffered or line-buffered, but in practice, stdio buffering is implementation-dependent and often block-buffered when piped. This causes the server to appear 'stuck' waiting for a flush that never comes, or the client to hang waiting for a response that's sitting in a buffer. The fix is mandatory explicit flushing. Alternatively, HTTP with Server-Sent Events \(SSE\) avoids this entirely and is better for servers that need to push frequent resource updates or handle large binary payloads that would bloat stdio JSON encoding.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:28:05.963803+00:00— report_created — created