Report #2226
[gotcha] MCP stdio server hangs or messages never arrive despite being sent
Flush stdout after every newline-delimited JSON-RPC message; never write non-protocol data to stdout \(use stderr for logs\); disable block buffering by running in a TTY, using line buffering, or calling fflush/flush; verify no embedded newlines in messages.
Journey Context:
stdio is the default MCP transport, but libc buffers stdout by block when connected to a pipe. A server that does not flush after each message leaves data in its buffer until it exits or fills the buffer, so the client appears to hang. The spec requires newline-delimited messages and that servers must not write non-MCP data to stdout. Logs belong on stderr. This bites C/C\+\+/Rust servers especially; Python's print usually flushes but not always.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T10:09:41.160228+00:00— report_created — created