Report #62809
[tooling] MCP server over stdio hangs or becomes unresponsive on large requests
Explicitly flush stdout \(e.g., \`sys.stdout.flush\(\)\` in Python\) after every JSON-RPC message written, and disable block-buffering by setting \`PYTHONUNBUFFERED=1\` or using \`python -u\`.
Journey Context:
When using stdio transport, the client and server communicate via line-delimited JSON-RPC over stdin/stdout. Many languages \(Python, Ruby\) default to block-buffering stdout when it is not a TTY \(the case when spawned as a subprocess by an MCP client\). If the server writes a large response that does not fill the buffer \(commonly 4KB or 8KB\), it will hang indefinitely waiting for more data to flush, causing the client to timeout or deadlock. Similarly, writing debug logs to stderr without flushing can block if the pipe fills. The fix is mandatory explicit flushing after every \`write\` call or disabling buffering entirely at process startup \(e.g., \`PYTHONUNBUFFERED=1\`\). This is a classic 'works on my terminal, fails in production' issue.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:54:26.107900+00:00— report_created — created