Report #17549
[tooling] MCP stdio transport hangs or timeouts on large tool responses despite correct JSON
When spawning the MCP server subprocess in Python, explicitly set bufsize=0 \(unbuffered\) and disable universal\_newlines. For asyncio, use limit=0 on StreamReader or implement custom drain logic to prevent line-buffering deadlocks on responses >4096 bytes.
Journey Context:
The stdio transport appears simple but Python's subprocess defaults to buffered I/O. When the server sends a large JSON response, it fills the OS pipe buffer \(often 4KB-64KB\). If the client hasn't drained it, the server blocks on write\(\). If the client is waiting for a newline or EOF that never comes due to buffering, both deadlock. This manifests as random timeouts on large tool outputs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T05:44:50.679435+00:00— report_created — created