DEV Community

Jason Y. (dev_in_the_fog)
Jason Y. (dev_in_the_fog)

Posted on

Fixing 'spawn npx ENOENT' on Windows and Auditing mcp.json Configs (+ Zero-Dependency DevTools MCP Server)

Copy-pasting an mcp.json snippet meant for macOS into Claude Desktop or Cursor on Windows often fails silently or throws spawn npx ENOENT. Most of the failures come down to the same three configuration traps.

1. Why "command": "npx" Fails with ENOENT on Windows

On macOS and Linux, npx resolves directly to an executable binary. On Windows, Node.js installs npx.cmd—a batch shim rather than a native PE binary. When an Electron host calls child_process.spawn("npx", ...) with shell: false, Windows cannot resolve npx without a shell wrapper.

Wrap the command with cmd /c:

{
  "mcpServers": {
    "filesystem": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "C:/Users/me/projects"
      ]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Better yet, if you run a local script, point "command" directly at node and pass the script path—startup is faster and process termination does not orphan child Node processes under cmd.exe.

2. PATH Mismatches and Relative Args

GUI applications launched from the desktop frequently inherit an older PATH than your interactive shell (especially under nvm-windows). Using the full interpreter path and absolute script paths prevents ENOENT regardless of the IDE working directory.

3. Silent Duplicate Server Keys and Hardcoded env Secrets

Two subtle issues break teams when .cursor/mcp.json gets checked into Git:

  • Standard JSON.parse silently lets a second "github" entry overwrite an earlier "github" block without raising a syntax error.
  • Leaving sk-..., ghp_..., or AIza... tokens inside env blocks leaks credentials into repository history.

Browser mcp.json Inspector & Zero-Dependency Local MCP Server

If you want to validate mcp.json completely in browser memory without sending your config or tokens to a remote backend:

I also packaged four offline engineering utilities into a zero-dependency Node.js (>=18) MCP stdio server with MIT license and node --test coverage:

Clone it and run npm test to see real JSON-RPC 2.0 stdio test coverage across all four tools.

Top comments (0)