Report #91362
[gotcha] MCP server hangs silently — stray stdout output corrupts the JSON-RPC stream
Never write to stdout in an MCP stdio server — not even debug logging, not even a stray print statement. Route all logs to stderr or a file. Audit every dependency for stdout writes. Add stdout guards that throw if anything outside the MCP framework writes to stdout.
Journey Context:
The MCP stdio transport uses stdout as the sole communication channel for JSON-RPC messages. The protocol is strictly message-framed over stdout. If the server process writes anything to stdout that isn't a valid JSON-RPC message — a debug print, a deprecation warning, a stack trace from a library — the client's message parser breaks. The client then either fails to parse the next real message or waits indefinitely for a valid frame. This is especially painful because the server was 'working' and suddenly stops after a code change adds a stray console.log. There's no error, no stack trace on the client side — just silence. The server appears to hang forever.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T11:56:37.781381+00:00— report_created — created