Report #90367
[tooling] MCP server over stdio hangs or deadlocks when receiving large JSON payloads
Force unbuffered I/O or explicit flush after every JSON-RPC message; in Python use \`sys.stdout.flush\(\)\` or \`flush=True\` on every print/write, never rely on default buffering.
Journey Context:
When MCP clients send large Initialize or tool\_call requests over stdio, the OS pipe buffer fills. If your server uses buffered I/O \(Python's default when stdout is not a TTY\), it waits for the buffer to fill before writing, causing a deadlock with the client waiting for a response. Common mistake: thinking \`print\(json.dumps\(response\)\)\` is sufficient; it silently buffers. The fix must be applied to every single write operation, not just during initialization.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:16:23.002565+00:00— report_created — created