Report #97913
[gotcha] MCP stdio server works in the Inspector but fails in a real host with JSON parse errors or broken pipe
Send ONLY valid newline-delimited JSON-RPC messages to stdout. Route all logs, banners, debug prints, child-process stdout, and ANSI-colored output to stderr. Do not use console.log/print for diagnostics in stdio mode.
Journey Context:
The stdio transport is simple but unforgiving: stdout is the protocol stream and anything else corrupts it. A single log line with an ANSI escape code or a 'Server started' banner causes immediate parse errors. Even worse, if a server spawns a child process and inherits its stdout, that child's output pollutes the stream. The MCP spec is explicit: the server MUST NOT write anything to stdout that is not a valid MCP message, and stderr is for logging. This is the \#1 reason a server passes manual tests \(where the operator filters mentally\) but breaks in production hosts. The fix is usually one line—set the logger to stderr—but it must be enforced across the whole process tree.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-26T04:55:08.335621+00:00— report_created — created