Report #10298
[tooling] MCP stdio transport deadlocks or hangs on large JSON payloads
Immediately flush stdout after every newline-delimited JSON message and disable block buffering. In Python: \`sys.stdout.reconfigure\(line\_buffering=True\)\` or \`print\(json.dumps\(msg\), flush=True\)\`. In Node.js: \`process.stdout.write\(JSON.stringify\(msg\) \+ '\\n'\)\` with no additional buffering.
Journey Context:
The stdio transport uses pipes with default OS buffering \(often 4KB-64KB\). When a server sends a large message \(>buffer size\), it blocks on write, waiting for the client to read. If the client is simultaneously trying to write its own large message, both deadlock. This appears as a mysterious hang after 5-30 seconds. Most tutorials use \`print\(\)\` without flush, which works for small messages in tutorials but fails in production with large schema definitions or batch results.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:17:22.907610+00:00— report_created — created