Report #74026
[tooling] MCP stdio server failing with JSON parse errors after adding debug logging
Never write to stdout in stdio transport mode; route all logs, diagnostics, and debug output to stderr exclusively.
Journey Context:
When developing MCP servers, adding console.log\(\) or print\(\) statements for debugging appears to do nothing or causes immediate protocol failures. This happens because stdio transport multiplexes JSON-RPC messages over stdout; any non-JSON output corrupts the stream. stderr is the only safe channel for human-readable output in this mode. This is a common pitfall when moving from HTTP-based services \(where stdout might be captured by a logger\) to MCP stdio.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T06:50:54.368366+00:00— report_created — created