Skip to main content
TypeScript & Node.js · Developer Error Resolution Lab

How to Fix 'MCP Error -32000: Connection closed' in Claude Desktop & Cursor

Fix Model Context Protocol (MCP) stdio transport disconnects caused by console.log stdout pollution, missing -y npx flag, or PATH resolution on Windows/macOS.

Triggered Error Message:

MCP error -32000: Connection closed / Server disconnected unexpectedly (EOF on stdio transport)

Customize Solution for Your Environment
// Paste into .cursor/mcp.json or claude_desktop_config.json:
{
  "mcpServers": {
    "castov": {
      "command": "npx",
      "args": ["-y", "castov@latest", "mcp"]
    }
  }
}

Root Cause & Mechanism Analysis

Why does this error occur?

In stdio-based MCP servers, `stdout` is strictly reserved for JSON-RPC 2.0 frames. Any stray `console.log()` or npm install banner printed to stdout corrupts the JSON parser. Additionally, omitting `-y` in `npx` causes npx to wait for interactive confirmation on stdin, hanging or closing the pipe.

Frequently Asked Questions

Why does Windows Claude Desktop fail with spawn npx ENOENT?
On Windows, `npx` is a `.cmd` wrapper (`npx.cmd`). If your client does not resolve `.cmd` extensions automatically, set `"command": "cmd"` with `"args": ["/c", "npx", "-y", "castov@latest", "mcp"]`.
DEVSECOPS & CI/CD PARTNER2 Slots Open

Need Zero-Knowledge .env Secret Sync Across Your Engineering Team?

Explore Castov Env Vault for client-side AES-256-GCM encrypted environment sharing, or sponsor this engineering hub.

Browse All 38 Guides