Skip to content

command turns into cmd automatically and the mcp service fails to connect - Claude Code

Quick fix

Edit MCP config inside the cc-switch UI so it is not overwritten, and correct npx commands rewritten wrongly as cmd by hand.

Error output
同步到.claude.json的指令中commnd自动变成cmd,而官方仓库中参数是npx,导致claude code中mcp服务连接失败
English translation

In the command synced to .claude.json, command turns into cmd automatically while the official repository has npx, so the mcp service fails to connect in claude code

cc-switch takes over and overwrites the config in ~/.claude.json or .mcp.json. If you edit those files by hand externally (updating a key, for instance), switching provider overwrites your changes from the older config in its database. Separately, on Windows or WSL, cc-switch has a bug importing or syncing stdio-type MCP config where it rewrites npx as cmd /c npx, so Claude Code cannot connect to the MCP service. Some versions also lose .mcp.json or fail to sync config after switching model.

  1. Stop editing ~/.claude.json by hand. All MCP config and key updates have to go through the cc-switch UI, or remove the config from cc-switch to give up its takeover.

  2. For npx rewritten as cmd, change command back to npx by hand in the cc-switch MCP server management screen and remove the extra /c argument.

    // ~/.claude.json
    {
    "mcpServers": {
    "chrome-devtools": {
    "type": "stdio",
    "command": "npx",
    "args": [
    "chrome-devtools-mcp@latest",
    "--browser-url=http://127.0.0.1:9922"
    ],
    "env": {}
    }
    }
    }
  3. If MCP config does not sync or goes missing (no MCP visible in Codex, for example), quit Claude Code or Codex completely, open the MCP edit screen in cc-switch, click save without changing anything, and restart the app to force a sync.

ToolClaude Code
Version3.14.1 - 3.16.1
PlatformsWindowsmacOSLinux
I edited the key in ~/.claude.json by hand — why does it revert after switching provider?
cc-switch manages and overwrites ~/.claude.json. Update the config in the cc-switch UI, or remove the relevant config from cc-switch; otherwise hand edits are overwritten from the old data.
Using Claude Code in WSL, MCP config syncs but will not connect. What now?
Usually because cc-switch rewrote npx into the Windows cmd /c npx. Change the command back to npx by hand in cc-switch.
.mcp.json goes missing after switching model, or Codex shows no MCP config. How do I resolve it?
A known sync bug. Quit the app, edit and save the MCP config once in cc-switch (no actual change needed) to force a re-sync.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.