Report #15091
[tooling] MCP server hangs or deadlocks on large payloads over stdio transport
Force unbuffered output: Python use \`python -u\` or \`sys.stdout.reconfigure\(line\_buffering=True\)\`; Node.js use \`process.stdout.\_handle?.setBlocking\(true\)\` and flush immediately after \`console.log\`. Never rely on default line buffering for JSON-RPC over stdio.
Journey Context:
By default Python buffers stdout block-wise \(4KB\+\), causing deadlock when the parent MCP client waits for a JSON-RPC response before sending more data. This manifests as intermittent hangs on large tool outputs. Many developers incorrectly blame the JSON parser or timeout settings, adding useless retry logic. The fix must be in the server process startup, not the client, because the buffer exists in the child process's libc stdio.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:12:33.220527+00:00— report_created — created