Evidence-first authority page
How to Fix MCP Non-JSON Lines / Parsing Errors
Why MCP stdio connections break with a JSON parsing error, and how to find and eliminate the non-protocol output causing it.
Direct answer
An MCP stdio JSON parsing error almost always means something other than a protocol message was written to stdout — a print statement, a startup banner, a dependency's own logging — which the client tries to parse as a protocol frame and fails. Find and redirect that output to stderr to fix it.
Last reviewed 2026-08-29
This page remains noindex while its page-level source receipts are completed and verified. It is available for review, not presented as publication-ready authority.
How to find the offending output
Run the server binary directly and pipe its stdout to a file, then inspect that file for anything that isn't a JSON-RPC message — this isolates the problem to the server process itself rather than the client's parsing logic. A common culprit is a third-party library the server depends on writing its own log lines to stdout by default, invisibly, unless explicitly configured otherwise.
The fix
- Explicitly configure any logging library used by the server to write to stderr, not the default in many languages/frameworks which can be stdout.
- Remove or silence any startup banner, version print, or debug statement in the server's entry point.
- If using a third-party server you didn't write, check its issue tracker — stdout pollution is a common, previously-reported bug class for MCP servers.