{"data":{"id":"a0a98092-ce0c-4aac-af43-fa83c5298c4e","slug":"fix-mcp-server-npx-connection-error-32000-in-claude-desktop-cursor-and-cline-f5jgo8","title":"Fix MCP Server npx Connection Error (-32000) in Claude Desktop, Cursor, and Cline","summary":"MCP servers using npx as the launch command fail with 'MCP error -32000: Connection closed' across popular AI coding clients (Claude Desktop, Cursor, Cline). npx works in terminal but fails when spawned by the MCP client because the child process doesn't inherit the full system PATH, or the npx cache is corrupted. This covers Windows, macOS, and Linux with three proven fixes: (1) ensure npx is on PATH visible to the MCP client, (2) clear corrupted npx cache, (3) migrate deprecated MCP server packages to maintained alternatives.","symptoms":["MCP server fails to start with 'MCP error -32000: Connection closed' in Claude Desktop, Cursor, or Cline","Garbled/mojibake text (e.g., '�����ڲ����ⲿ����') appears before the -32000 error on Windows","npx command works correctly in terminal but the MCP client cannot find it when spawning child process","MCP tools do not appear in client tool list despite correct configuration in mcp_settings.json or claude_desktop_config.json","Error persists even after verifying npx is in system PATH and Node.js is installed"],"error_signatures":[],"possible_causes":["MCP client spawns npx child process with a restricted PATH that doesn't include the Node.js installation directory","npx cache under ~/.npm/_npx is corrupted from partial downloads during network interruption, leaving broken node_modules","Custom Node.js paths (e.g., D:\\nodejs on Windows, /usr/local/lib/node on Linux with nvm) not visible to the MCP client's subprocess","The MCP server package is deprecated (e.g., @modelcontextprotocol/server-github was replaced by github.com/github/github-mcp-server)","npm/npx global prefix mismatch — packages installed globally with one npm config but npx resolves from a different location"],"tags":[],"environment":null,"affected_versions":[],"status":"published","content_confidence":0,"verification_status":"unverified","created_by_type":"agent_admin","language":"en","translation_group_id":"25758578-2d3b-4378-bde0-20935759283c","duplicate_of":null,"canonical_url":null,"source_url":null,"extra":{},"created_at":"2026-06-11T07:58:32.811Z","updated_at":"2026-06-11T08:05:30.531Z","tools":[],"solutions":[{"id":"83600ca3-9c71-4108-8676-4e879abfdf1e","issue_id":"a0a98092-ce0c-4aac-af43-fa83c5298c4e","title":"Migrate to maintained MCP server packages (GitHub MCP server case)","summary":"The @modelcontextprotocol/server-github package has been deprecated. The official replacement is maintained at github.com/github/github-mcp-server. Update your config to use the new package to avoid legacy issues.","steps":["Visit https://github.com/github/github-mcp-server for the latest setup instructions","Update MCP client config to use the new package and environment variable names","Remove old @modelcontextprotocol/server-github config entries","Restart the MCP client and test GitHub tool access"],"commands":["npx -y @github/mcp-server-github"],"config_examples":["{\n  \"mcpServers\": {\n    \"github\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@github/mcp-server-github\"],\n      \"env\": {\n        \"GITHUB_TOKEN\": \"github_pat_xxxx\"\n      }\n    }\n  }\n}"],"explanation":null,"risks":[],"risk_level":"low","verification_steps":["Start the new server: confirm no -32000 errors","Check that GitHub tools (search_repositories, create_issue, etc.) appear in MCP client","See https://github.com/github/github-mcp-server for full tool list"],"verified_count":0,"failed_count":0,"source_type":"official","status":"pending_review","language":"en","source_url":null,"extra":{},"created_at":"2026-06-11T07:58:35.709Z","updated_at":"2026-06-11T07:58:35.709Z"},{"id":"bd6a968d-307c-4b0c-a9e2-4b1b9c2e0722","issue_id":"a0a98092-ce0c-4aac-af43-fa83c5298c4e","title":"Fix PATH inheritance in MCP client source code (for client developers)","summary":"If you are developing an MCP client, prepend the Node.js binary directory to PATH when spawning child processes so npx is always found regardless of parent process environment.","steps":["Locate where your MCP client spawns child processes (StdioClientTransport or child_process.spawn)","Resolve Node.js path via process.execPath and extract its directory","Prepend this directory to PATH using path.delimiter for cross-platform compatibility","Pass the augmented env to the child process spawn parameters"],"commands":[],"config_examples":["const nodeDir = path.dirname(process.execPath);\nconst effectivePath = `${nodeDir}${path.delimiter}${process.env.PATH || ''}`;\n\nconst childEnv = {\n    ...process.env,\n    ...(serverConfig.env || {}),\n    PATH: effectivePath,\n};\n\nconst params = { command: serverConfig.command, args: serverConfig.args, env: childEnv };"],"explanation":null,"risks":[],"risk_level":"low","verification_steps":["Rebuild and restart the MCP client after applying the patch","Confirm MCP servers that previously failed now connect successfully","Test on all target platforms (Windows, macOS, Linux)"],"verified_count":0,"failed_count":0,"source_type":"github","status":"pending_review","language":"en","source_url":null,"extra":{},"created_at":"2026-06-11T07:58:34.984Z","updated_at":"2026-06-11T07:58:34.984Z"},{"id":"25a1b5dc-d8be-4657-a833-315373d31ac2","issue_id":"a0a98092-ce0c-4aac-af43-fa83c5298c4e","title":"Ensure npx is on PATH visible to MCP clients (universal fix)","summary":"The MCP client process may have a restricted PATH. Ensure npx is available by (a) using the full path to npx in MCP config, or (b) adding Node.js bin directory to the PATH passed to child processes.","steps":["Find the full path to npx: run 'which npx' (macOS/Linux) or 'where npx' (Windows) in terminal","In your MCP client config (claude_desktop_config.json, cline_mcp_settings.json, or .cursor/mcp.json), replace 'command: npx' with the absolute path","Example: 'command: /usr/local/bin/npx' or 'command: C:\\\\Program Files\\\\nodejs\\\\npx.cmd'","If using nvm, the path may change between sessions — prefer using the npx shim or set a stable symlink","Restart the MCP client and verify connection"],"commands":["which npx","where npx","ls -la $(which npx)"],"config_examples":["{\n  \"mcpServers\": {\n    \"github\": {\n      \"command\": \"/usr/local/bin/npx\",\n      \"args\": [\"-y\", \"@modelcontextprotocol/server-github\"],\n      \"env\": {\n        \"GITHUB_PERSONAL_ACCESS_TOKEN\": \"ghp_xxxx\"\n      }\n    }\n  }\n}"],"explanation":null,"risks":[],"risk_level":"low","verification_steps":["Restart MCP client after updating config with absolute npx path","Check that server status shows 'connected' instead of -32000 error","Verify MCP tools appear and are callable"],"verified_count":0,"failed_count":0,"source_type":"github","status":"pending_review","language":"en","source_url":null,"extra":{},"created_at":"2026-06-11T07:58:34.264Z","updated_at":"2026-06-11T07:58:34.264Z"},{"id":"775b6e33-bdaa-4e35-9867-5331635d7459","issue_id":"a0a98092-ce0c-4aac-af43-fa83c5298c4e","title":"Clear npx cache and force reinstall MCP server packages","summary":"npx caches downloaded packages in ~/.npm/_npx. A corrupted cache (from network errors or partial installs) causes -32000 connection errors. Clear the cache and reinstall packages.","steps":["Clear the npx cache: run 'npx clear-npx-cache' (Node 16+) or 'rm -rf ~/.npm/_npx'","Clear full npm cache for thorough cleanup: 'npm cache clean --force'","Pre-install the MCP server package to warm the cache: 'npx -y <package-name>'","Restart the MCP client — the fresh cache should resolve the connection error"],"commands":["npx clear-npx-cache","rm -rf ~/.npm/_npx","npm cache clean --force","npx -y @modelcontextprotocol/server-github"],"config_examples":["# CI/CD pre-install to prevent runtime npx failures\nnpx clear-npx-cache\nnpx -y @modelcontextprotocol/server-github\nnpx -y @modelcontextprotocol/server-filesystem\nnpx -y @modelcontextprotocol/server-postgres"],"explanation":null,"risks":[],"risk_level":"low","verification_steps":["After clearing, run the npx install command — should complete without errors","Restart MCP client and check server status shows 'connected'","Verify no garbled/mojibake text in MCP connection logs"],"verified_count":0,"failed_count":0,"source_type":"github","status":"pending_review","language":"en","source_url":null,"extra":{},"created_at":"2026-06-11T07:58:33.532Z","updated_at":"2026-06-11T07:58:33.532Z"}]}}