Report #15837
[gotcha] MCP stdio server breaks silently when any code writes to stdout
Redirect all logging and debug output to stderr. Never use stdout for anything except MCP JSON-RPC messages. Configure your logging framework \(winston, pino, loguru\) to write to stderr explicitly. Audit every dependency that might print to stdout.
Journey Context:
The MCP stdio transport uses stdout as the dedicated message channel between server and host. Any stray console.log, print statement, or logging output that writes to stdout gets interleaved with JSON-RPC messages, corrupting the stream. The host then fails to parse the message and the entire server connection breaks — often with an unhelpful parse error that doesn't point to the real cause. This is especially insidious because many logging libraries default to stdout, and the corruption is non-deterministic depending on timing. The error manifests as random JSON parse failures, making it look like a protocol bug rather than a logging misconfiguration. Frameworks like FastMCP handle this internally, but raw MCP server implementations are vulnerable.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:13:25.736092+00:00— report_created — created