Claude Code MCP disconnects as soon as it starts on Windows, especially when the local MCP server starts with 'npx', first check if the 'cmd /c' wrapper is missing. The Anthropic documentation clearly warns that under native Windows, local MCP servers using 'npx' usually need to be executed correctly via 'cmd /c'.
Determine whether you are Windows or WSL first
If you are running Claude Code in WSL, troubleshoot by Linux path and Linux Node environment. The focus is on whether 'which node' and 'which npm' point inside WSL.
If you're running in native Windows, the problem may be with command parsing. Many MCP configuration examples write 'npx server-name', which may not be executed directly by Claude Code as expected in Windows.
How to change the configuration
Change the command from calling 'npx' directly to calling it via 'cmd /c'. The idea is to let the Windows Command Interpreter be responsible for finding and executing npx. The specific field names depend on your MCP configuration format, but the core is that the command is 'cmd', and the arguments include '/c', 'npx', and the server package name.
After making changes, restart Claude Code and use '/mcp' to check the connection status. Don't just look at whether the configuration file is saved, but whether the service is really connected.
Troubleshoot these issues as well
Node is not installed, npm is not in the PATH, the company agent intercepts npm, and MCP server requires environment variables but does not pass them, all of which will cause the connection to be disconnected. Run the same command manually in a normal terminal to confirm that it can start, and then hand it over to Claude Code.
If the server requires an API key, don't write the key into the chat message, it should be placed in the environment variable or security configuration.
The most stable approach
Windows natively checks 'cmd /c' first, WSL prioritizes Linux Node paths. Then use '/mcp' to see the status, and use the normal terminal to reproduce the startup command. As long as you check "can the command run" and "whether the Claude Code can be connected" separately, MCP disconnection will be much easier to fix.