Skip to content

MCP server fails to spawn npx (ENOENT) inside Claude Desktop — needs absolute path override #6

Description

@14113

First of all, thanks for this nice MCP server! Great work.

Description / Problem Statement
When deploying the rohlik-mcp server under Claude Desktop, it fails with the error:

spawn npx ENOENT
Server disconnected. Transport closed unexpectedly.

Even though npx, node, and npm are correctly installed and available in the user shell (which npx returns a valid path). This indicates that the Claude Desktop runtime environment’s PATH does not include the directory where npx resides.

Steps to Reproduce

  1. Use default MCP server config pointing "command": "npx"
  2. Run Claude Desktop (or invoke the MCP)
  3. Observe spawn npx ENOENT errors in the logs
  4. Change config to use absolute path to npx (e.g. /Users/adam/.local/share/mise/installs/node/22.14.0/bin/npx)
  5. Restart Claude Desktop
  6. MCP server initializes correctly and connects

Observed Behavior

  • The system errors out with spawn npx ENOENT.
  • The MCP server never properly launches via the wrapper.
  • After overriding command with absolute path, the MCP server works.

Expected Behavior

  • The MCP wrapper should resolve/locate npx correctly within the environment where Claude Desktop invokes it.
  • Fallback or detection logic should allow using an absolute path if npx isn’t in the default PATH.

Suggested Fix / Improvements

  • Inform about this in the README
  • Add logic to detect npx via environment variables or a fallback search (e.g. which npx) if spawn "npx" fails.
  • Allow specifying an absolute path for the command in config (already working as workaround).

Environment Details

  • macOS (or environment using Claude Desktop)
  • Node.js v22.14.0
  • npm 10.9.2
  • npx is located at /Users/adam/.local/share/mise/installs/node/22.14.0/bin/npx
  • MCP config works when overriding "command" to that absolute path

Full Stack / Log Snippet

2025-10-11T08:17:57.102Z [info] [rohlik] Using MCP server command: npx with args and path: { … }
2025-10-11T08:17:57.103Z [error] [rohlik] spawn npx ENOENT
2025-10-11T08:17:57.104Z [error] [rohlik] spawn npx ENOENT
2025-10-11T08:17:57.105Z [info] [rohlik] Server transport closed
…
2025-10-11T08:18:37.323Z [error] [rohlik] spawn npx ENOENT
…
Server disconnected. For troubleshooting guidance, see debugging docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions