Report #13651
[tooling] MCP stdio server intermittently throws 'Parse error' or 'Invalid Request' despite valid JSON-RPC
Redirect all logging \(console.log, print\) to stderr before starting the server; never write to stdout except valid JSON-RPC messages
Journey Context:
The stdio transport uses newline-delimited JSON-RPC over stdout. Many languages default stdout for logging, and a single 'console.log' or 'print' debugging statement interleaves non-JSON text into the stream, causing the client to throw parse errors that appear as generic JSON-RPC failures. This is notoriously hard to debug because the error points to 'invalid JSON' rather than 'unexpected stdout write'. The fix is to configure the runtime's logging framework to use stderr exclusively before the MCP server starts, ensuring stdout is a pristine JSON-RPC channel.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T19:18:39.269875+00:00— report_created — created