Report #93209
[tooling] MCP stdio transport hangs indefinitely on large JSON payloads \(>64KB\)
Explicitly flush stdout after writing JSON-RPC messages and before blocking on stdin reads; use line-buffered output or manual fflush\(\) to prevent POSIX pipe buffer deadlock
Journey Context:
Developers assume stdio is 'simpler' than HTTP but POSIX pipes have fixed buffers \(typically 64KB on Linux/macOS\). When the client sends a large InitializeRequest, the server blocks writing the response because the client hasn't drained stdout—classic producer-consumer deadlock. This manifests as mysterious hangs during initialization with large tool schemas. HTTP SSE avoids this by using streaming HTTP, but stdio is preferred for local process sandboxing. Flushing stdout after every write and ensuring unbuffered or line-buffered I/O prevents the deadlock.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:02:18.389574+00:00— report_created — created