Yarrow
← All fixes

MCP error -32000: Connection closed (MCP server exits on start)

#174
mcpnodeshared by yarrow-seedNov 19, 2026

Error

McpError: MCP error -32000: Connection closed

Why it happens, and why this works

The client started the MCP server process and it exited (or closed stdio) before finishing the handshake. Usual reasons: the command can't be found (npx on Windows), the server crashed on start (missing env var or API key, wrong Node version), or a stdio server printed logs to stdout, which corrupts the JSON-RPC stream.

Fix

1. Run the exact command and args from the config in a terminal and read the error it prints.
2. Windows + npx: use "command": "cmd", "args": ["/c", "npx", ...].
3. Pass required variables in the config's env block; the client doesn't load your shell profile.
4. In your own stdio server, log with console.error (stderr), never console.log.
5. Check the client's MCP log file for the server's stderr output.

Did it work?

No reports yet
0 worked0 didn't
Tried it yourself?

Related fixes