Windows: duplicate project entries from inconsistent path normalization
Bug
On Windows, ~/.claude.json accumulates duplicate project entries for the same directory because paths aren't normalized before being used as JSON keys. This causes API Error: 400 "tools: Tool names must be unique" when any MCP tool is invoked, because Claude Code initializes the full MCP server set once per matching ancestor project entry.
Reproduction
- Open a project from the VS Code extension (creates entry with forward slashes:
E:/Claude Code Projects/HAAS Alert) - Open the same project from the CLI (creates entry with backslashes:
E:\Claude Code Projects\HAAS Alert) - Both entries persist as separate JSON keys
- On next session, Claude Code walks up the directory tree, matches both entries, and initializes MCP servers twice
- Every MCP tool appears in duplicate → 400 error on any MCP tool call
Evidence
Three duplicate pairs found in my ~/.claude.json:
| Same Directory | Entry 1 | Entry 2 | Difference |
|---|---|---|---|
| HAAS Alert | E:\Claude Code Projects\HAAS Alert | E:/Claude Code Projects/HAAS Alert | \ vs / |
| Jira Management | E:\...\Jira Management | e:\...\Jira Management | E: vs e: |
| C:\Users\emers | C:\Users\emers | C:/Users/emers | \ vs / |
The backslash entries lack reactVulnerabilityCache (older), while forward-slash entries have it (newer), confirming they were created by different code paths at different times.
Impact
All MCP tools become unusable — WCP, Git MCP, Greptile, Playwright, Puppeteer, Atlassian, etc. The entire deferred tool list is doubled. No MCP operation works until the duplicates are manually merged in the JSON file.
Suggested Fix
Normalize paths before using them as project keys:
- Lowercase drive letter (
E:→e:) - Consistent separator (pick one, probably forward slash)
- Resolve
.and..segments
Apply normalization both when creating new project entries and when looking up existing ones.
Workaround
Manually merge duplicate entries in ~/.claude.json using a script, then restart Claude Code.
Environment
- Windows 11 Pro 10.0.26100
- Claude Code accessed via both VS Code extension and CLI
- Multiple global MCP servers configured (WCP, Git MCP, Atlassian, Puppeteer, Snowflake)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗