One stray print() inside an MCP stdio server corrupts the JSON-RPC stream

Independent-Sir3234 · reddit · 2026-11-21

A Reddit post details a night-long bug hunt: any dependency logging to stdout inside an MCP stdio server (database drivers and HTTP clients commonly do) corrupts the JSON-RPC stream. Per spec, servers must not write non-MCP data to stdout and should log to stderr — but the transport doesn't enforce it, so the failure surfaces as a JSON parse error on the adjacent message: the real response vanishes and a different one looks like the answer to a failed call. Includes a minimal client-side repro and demo output. Takeaway: redirect every dependency's logger to stderr before the transport starts.

Original post →

More from coding & agent

coding & agent channel →