Skip to content

fix: Windows CLI detection and CLAUDE_CLI_PATH env var#44

Open
bluzername wants to merge 1 commit intosteipete:mainfrom
bluzername:fix/windows-cli-path-detection
Open

fix: Windows CLI detection and CLAUDE_CLI_PATH env var#44
bluzername wants to merge 1 commit intosteipete:mainfrom
bluzername:fix/windows-cli-path-detection

Conversation

@bluzername
Copy link
Copy Markdown

Problem

On Windows the MCP server cannot find Claude CLI because:

  1. It only checks ~/.claude/local/claude which is Unix-specific path, Windows npm install puts claude.cmd in AppData
  2. The CLAUDE_CLI_PATH env var mentioned in CLAUDE.md is not actually implemented (only CLAUDE_CLI_NAME exists)
  3. Windows .cmd and .exe extensions are not considered when looking for the binary

This makes the server completely unusable on Windows npm installations.

What I changed

Updated findClaudeCli() in src/server.ts to handle Windows properly:

  1. Added CLAUDE_CLI_PATH env var - checks this first, validates file exists, warns if not found but continues to other methods. This is what users expect based on the CLAUDE.md documentation
  2. Windows extension handling - on win32 platform, also checks for .cmd and .exe variants when looking at ~/.claude/local/claude
  3. Windows npm global paths - checks AppData/Roaming/npm/claude.cmd and .exe which is where npm global installs go on Windows
  4. Kept backward compatibility - CLAUDE_CLI_NAME still works same as before, CLAUDE_CLI_PATH just has higher priority

Also added tests for the new CLAUDE_CLI_PATH behavior (existing unit test file already had broken mocks before this change, so only added tests that follow same pattern).

How to use on Windows

Either:

{
  "env": {
    "CLAUDE_CLI_PATH": "C:\\Users\\me\\AppData\\Roaming\\npm\\claude.cmd"
  }
}

Or just let the auto-detection find it in the npm global path.

Testing

  • npm run build passes clean
  • e2e tests pass
  • validation tests pass
  • Added 2 new unit tests for CLAUDE_CLI_PATH (set+exists, set+missing)

Closes #39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Windows: ~/.claude/local/claude path not found, CLAUDE_CLI_PATH ignored

1 participant