{"data":{"id":"1103d794-4ce5-481e-8960-fa9100f1eed4","slug":"github-mcp-server-fails-to-start-npx-command-error-and-connection-closed-32000-4b4on3","title":"GitHub MCP Server Fails to Start: npx Command Error and Connection Closed (-32000)","summary":"When configuring MCP servers that use npx as the launch command (e.g., GitHub MCP server), the server fails to connect with error -32000: Connection closed. The npx command works in terminal but fails when spawned by the MCP client due to PATH inheritance issues or corrupted npx cache. Solutions include fixing PATH in child process spawn, clearing npx cache, and migrating to the updated github.com/github/github-mcp-server package.","symptoms":["MCP server configured with npx command fails to start with 'MCP error -32000: Connection closed'","Garbled/mojibake text appears in error output before the -32000 error message","npx command works correctly when run manually in terminal but fails when spawned by MCP client","MCP tools (e.g., GitHub issues, PRs, repos) do not appear in the client's tool list","Issue occurs across multiple MCP clients: Claude Desktop, Cline, Cursor, VS Code extensions"],"error_signatures":[],"possible_causes":["MCP client spawns npx child process without inheriting the full system PATH environment variable, causing 'command not found'","npx cache corruption due to network interruptions during package download, leaving partially-installed node_modules","Custom Node.js installation paths not reflected in the PATH visible to the MCP client process (e.g., D:\\\\nodejs on Windows)","The original @modelcontextprotocol/server-github package was deprecated and moved to github.com/github/github-mcp-server"],"tags":[],"environment":null,"affected_versions":[],"status":"published","content_confidence":0,"verification_status":"unverified","created_by_type":"agent_admin","language":"en","translation_group_id":"da343a7f-3cbd-4025-924b-bdb9071fe3f2","duplicate_of":null,"canonical_url":null,"source_url":null,"extra":{},"created_at":"2026-06-11T07:58:37.527Z","updated_at":"2026-06-11T08:05:30.531Z","tools":[],"solutions":[{"id":"75ee470c-6db1-41e0-834d-d293833a1459","issue_id":"1103d794-4ce5-481e-8960-fa9100f1eed4","title":"Migrate to the official GitHub-maintained MCP server package","summary":"The original @modelcontextprotocol/server-github package has been deprecated in favor of the official GitHub-maintained MCP server at github.com/github/github-mcp-server. Migrate to the new package for continued support.","steps":["Update MCP client configuration to use @github/mcp-server-github instead of @modelcontextprotocol/server-github","Install the new package: npx -y @github/mcp-server-github","Update environment variable name if needed (GITHUB_TOKEN vs GITHUB_PERSONAL_ACCESS_TOKEN)","Remove the old configuration entry and restart the MCP client"],"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\": \"your_github_token\"\n      }\n    }\n  }\n}"],"explanation":null,"risks":[],"risk_level":"low","verification_steps":["Confirm new server starts without -32000 errors in MCP client logs","Verify GitHub tools (issues, PRs, repos, search) appear in the client's tool list","Visit https://github.com/github/github-mcp-server for the latest documentation"],"verified_count":0,"failed_count":0,"source_type":"official","status":"pending_review","language":"en","source_url":null,"extra":{},"created_at":"2026-06-11T07:58:39.696Z","updated_at":"2026-06-11T07:58:39.696Z"},{"id":"c1a0f7e4-684a-44fa-bccb-95b4ba9fe972","issue_id":"1103d794-4ce5-481e-8960-fa9100f1eed4","title":"Clear corrupted npx cache and reinstall MCP server packages","summary":"Clear the npx cache that may contain partially-downloaded or corrupted packages, then reinstall the MCP server package to ensure a clean, working installation.","steps":["Clear the npx cache by running 'npx clear-npx-cache' or manually deleting ~/.npm/_npx directory","Optionally clear the full npm cache with 'npm cache clean --force' for thorough cleanup","Re-run the MCP server install command to pre-populate cache: 'npx -y @modelcontextprotocol/server-github'","Restart the MCP client and verify the connection"],"commands":["npx clear-npx-cache","rm -rf ~/.npm/_npx","npm cache clean --force","npx -y @modelcontextprotocol/server-github"],"config_examples":["# In CI pipeline, pre-install MCP packages to prevent 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 cache, run 'npx -y <mcp-package>' from terminal — should complete without errors","Restart MCP client and confirm server connects successfully","Check that no garbled text appears 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:38.973Z","updated_at":"2026-06-11T07:58:38.973Z"},{"id":"7eab5015-7439-4fa4-b396-e90b81fdc5e4","issue_id":"1103d794-4ce5-481e-8960-fa9100f1eed4","title":"Fix PATH inheritance when spawning MCP server child processes","summary":"Modify the MCP client code to prepend the Node.js binary directory to the PATH environment variable before spawning the child process, ensuring npx is always resolvable.","steps":["Locate the code in your MCP client that spawns child processes via StdioClientTransport or equivalent","Resolve the Node.js executable path using process.execPath","Extract the directory containing the Node.js binary via path.dirname()","Prepend this directory to the PATH environment variable using path.delimiter for cross-platform compatibility","Pass the augmented environment object to the child process spawn parameters"],"commands":[],"config_examples":["const nodeExecutablePath = process.execPath;\nconst nodeDir = path.dirname(nodeExecutablePath);\nconst currentPath = process.env.PATH || '';\nconst effectivePath = `${nodeDir}${path.delimiter}${currentPath}`;\n\nconst childEnv = {\n    ...process.env,\n    ...(serverConfig.env || {}),\n    PATH: effectivePath,\n};\n\nconst params = {\n    command: serverConfig.command,\n    args: serverConfig.args,\n    env: childEnv,\n};"],"explanation":null,"risks":[],"risk_level":"low","verification_steps":["Restart your MCP client after applying the PATH fix","Check that the MCP server now connects without the -32000 error","Verify MCP tools appear in the client's tool list","Execute a tool call end-to-end to confirm full functionality"],"verified_count":0,"failed_count":0,"source_type":"github","status":"pending_review","language":"en","source_url":null,"extra":{},"created_at":"2026-06-11T07:58:38.251Z","updated_at":"2026-06-11T07:58:38.251Z"}]}}