Report #77136
[gotcha] MCP server over stdio transport crashes or hangs mysterically with no error message
Ensure ALL output from the MCP server process goes to stderr, never stdout. stdout is reserved exclusively for JSON-RPC messages. Audit all dependencies and logging libraries for stdout writes. Configure logging to stderr explicitly at startup before any other code runs.
Journey Context:
The stdio transport uses the process stdout stream as the JSON-RPC message channel. Any stray print\(\), console.log\(\), fmt.Println\(\), or library output to stdout gets interleaved with JSON-RPC messages, corrupting the stream. The client then fails to parse messages, and the failure manifests as mysterious hangs, connection drops, or parse errors with no clear root cause. This is particularly insidious because logging libraries often default to stdout, and the corruption happens silently — there is no error from the server's perspective. Some MCP SDKs attempt to intercept stdout, but you cannot rely on this for all runtimes and libraries. The only reliable fix is to configure all output to stderr at the earliest possible point in the process lifecycle.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T12:04:12.461206+00:00— report_created — created