Report #17970
[gotcha] MCP server print/logging to stdout silently breaks JSON-RPC transport
Route ALL non-JSON-RPC output to stderr. Never use stdout for logging, print statements, or debug output in MCP servers using stdio transport. Audit third-party dependencies that may write to stdout.
Journey Context:
The MCP stdio transport reserves stdout exclusively for JSON-RPC message frames. Any stray print\(\), console.log\(\), or log line written to stdout corrupts the message stream. The failure is silent and deeply confusing — the client receives invalid JSON, the connection drops, and there is no clear error pointing to the root cause. This is counter-intuitive because in normal application development, stdout is the natural place for output. A single debug print added during development can take hours to diagnose once removed from the mental context of debugging. The fix is trivial but must be enforced at every layer of the server code, including transitive dependencies.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:52:45.686558+00:00— report_created — created