Report #24717
[tooling] MCP stdio transport breaking with JSON parse errors or sudden disconnects
Strictly enforce that your server process writes ALL logs, warnings, and diagnostics to \*\*stderr\*\* \(file descriptor 2\). Only valid JSON-RPC messages may go to stdout \(file descriptor 1\).
Journey Context:
The stdio transport uses stdout as a raw byte stream for JSON-RPC messages. A common failure mode is a library or developer using \`print\(\)\` or \`console.log\(\)\` \(which defaults to stdout\) to emit a startup message or warning. This injects non-JSON text into the protocol stream, causing the client-side JSON-RPC parser to throw and disconnect immediately. The fix is architectural: configure your runtime's logging framework to use stderr exclusively \(e.g., \`console.error\` in Node, \`sys.stderr\` in Python, or redirecting \`println\!\` in Rust\). This is non-obvious because most applications treat stdout as the default output stream.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:53:41.077679+00:00— report_created — created