Fix it
- Run the server command yourself, exactly as your config has it (same
command,argsandenv), in a terminal. If it prints an error and exits, that is your cause: a missing dependency, wrong path, missing API key or unsupported runtime version. - Move every log line to stderr. On stdio, stdout carries only protocol messages. Use
console.errorin Node,print(..., file=sys.stderr)in Python, and check dependencies that print banners. - Use absolute paths in
commandandargs. Relative paths resolve against the folder the client was started from, not the config file's folder. - Put required variables in the server's
envblock rather than relying on your shell's environment. - Read the client's log. In Claude Code:
/mcpfor status,claude mcp get <name>for theIssue:line, andclaude --debug=mcpto write the server's stderr to~/.claude/debug/<session-id>.txt. - If the server is just slow to start, raise the client's startup timeout. In Claude Code:
MCP_TIMEOUT=10000 claude(10 seconds).
What -32000 actually is
JSON-RPC 2.0 reserves codes -32000 to -32099 for implementation-defined server errors. The official MCP SDKs use -32000 for their own ConnectionClosed error: the TypeScript SDK (v1, ErrorCode.ConnectionClosed) and the Python SDK (CONNECTION_CLOSED = -32000, documented as "the connection closed before a response arrived; never emitted on the wire"). So the server didn't send this code. Your client raised it because the connection ended while it was waiting.
The TypeScript SDK v2 replaces the number with SdkErrorCode.ConnectionClosed, so code that checks error.code === -32000 silently stops matching after an upgrade.
Causes, and how to check
| Cause | How to spot it |
|---|---|
| Server crashes at startup | Running the command by hand (step 1) prints a stack trace or exits at once |
| Something printed to stdout | The client log shows SyntaxError: Unexpected token ... is not valid JSON; the quoted token is the first character of the stray line |
| Command not found / wrong path | Works from one folder but not another; relative paths in the config |
| Missing environment variable | Server exits complaining about a key; Claude Code warns about unset ${VAR} references in claude mcp list and /mcp |
| Startup slower than the client's timeout | Raising the startup timeout (step 6) makes it connect |
The protocol rule behind the stdout problem
The MCP specification's stdio transport: the client launches the server as a subprocess; messages are newline-delimited JSON-RPC and must not contain embedded newlines; the server must not write anything to stdout that is not a valid MCP message, and may write UTF-8 logs to stderr. One stray console.log breaks the stream.
Test the server outside your editor
The official MCP Inspector connects to a server and shows every message, which separates server bugs from client configuration:
npx @modelcontextprotocol/inspector
Remote (HTTP) servers
400with JSON-RPC-32000andBad Request: Mcp-Session-Id header is requiredcomes from the TypeScript SDK's HTTP server: the client didn't send the session ID it received at initialization. The spec requires clients to sendMCP-Session-Idon every later request.404on a request with a session ID means the server ended that session; the client must start a new one with a fresh initialize request.- Claude Code's
MCP server "<name>" connection closed before the tool call was answeredmeans the tool may have run. Check the target service before running it again.
Running Claude Code, Codex or Cursor on real repos, or shipping an AI agent? A Quick Review ($149 / ₹13,900, 1 working day) checks one repo, config or setup for leaked keys, risky agent permissions and MCP servers. Request a Quick Review
FAQ
What does MCP error -32000 mean?
In the official MCP SDKs, -32000 is the client-side ConnectionClosed error: the connection to the MCP server closed before a response arrived. The server did not send it.
Why does console.log break my MCP server?
On the stdio transport, stdout carries protocol messages, and the MCP spec says a server must not write anything else there. Log to stderr instead.
How do I see why an MCP server failed in Claude Code?
Run /mcp for its status, claude mcp get <name> for the Issue line, and claude --debug=mcp to capture the server's stderr in ~/.claude/debug/<session-id>.txt.
How do I increase the MCP startup timeout in Claude Code?
Set MCP_TIMEOUT in milliseconds when starting it, for example MCP_TIMEOUT=10000 claude.
Related errors
- Claude Code not working in VS Code
- Codex CLI: Error loading config.toml
- Claude Code: Failed to authenticate / 403
Sources
Read 29 Nov 2026. These tools change often: if a step no longer matches, the linked page wins.
- MCP specification: Transports (2025-11-25): modelcontextprotocol.io/specification/2025-11-25/basic/transports
- JSON-RPC 2.0 specification: www.jsonrpc.org/specification
- MCP TypeScript SDK: error codes (v1 to v2 reference): github.com/modelcontextprotocol/typescript-sdk/blob/main/skills/mcp-typescript-sdk-upgrade-to-v2/references/errors.md
- MCP TypeScript SDK: Troubleshooting: github.com/modelcontextprotocol/typescript-sdk/blob/main/docs/troubleshooting.md
- MCP Python SDK: mcp_types/jsonrpc.py: github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp-types/mcp_types/jsonrpc.py
- Claude Code docs: MCP: code.claude.com/docs/en/mcp
- Claude Code docs: Debug your configuration: code.claude.com/docs/en/debug-your-config
- Claude Code docs: Error reference: code.claude.com/docs/en/errors
- MCP Inspector: github.com/modelcontextprotocol/inspector
- MCP config checker: scan your mcp.json for hard-coded tokens, unpinned servers and risky access
- mcp.json config check: the same checks as a local Python check
- MCP server security scanner: check an MCP server's source before you install it
- MCP server safety directory: hand-checked grades for popular MCP servers