"Unexpected token … is not valid JSON" from a custom MCP server
Claude DesktopCursorClaude Code
The error
SyntaxError: Unexpected token 'S', "Server sta"... is not valid JSON
Why it happens
With the stdio transport, stdout is reserved for JSON-RPC messages. Any console.log / print() to stdout corrupts the stream.
How to fix it
- Log to stderr instead
Node: useconsole.error. Python:print(..., file=sys.stderr)or theloggingmodule.// Node console.error("Server started"); # Python import sys print("Server started", file=sys.stderr) - Silence noisy dependencies
Libraries that print banners or progress bars to stdout must be silenced or redirected. - Claude Code froze while a server printed a lot? Update
Claude Code 2.1.332 (November 24, 2026) fixed the terminal freezing, and ignoring Ctrl+C, while a local MCP server floods its standard output. Updating stops the freeze, but the server still has to keep stdout for JSON-RPC messages only.claude update
Related servers
Dev Tools● Maintained
Everything (test server)
Official test server that exercises every MCP feature (prompts, tools, resources, sampling and more). It is meant for people building MCP clients, not
★ 92.4k · updated 2026-11-27
Memory & Reasoning● Maintained
Sequential Thinking
Official reference server with a single tool for step-by-step, revisable problem solving. Version 2.2.0 (Nov 18, 2026, reference servers v2.5.0) can a
★ 92.4k · updated 2026-11-18
Building your own server and want to share it over a URL? See where to host a remote MCP server.