Skip to content

fix(mcp): find ~/.claude.json project servers on Windows when the key uses forward slashes - #98

Open
XinQijj wants to merge 1 commit into
qybaihe:mainfrom
XinQijj:fix/claude-json-windows-project-keys
Open

XinQijj wants to merge 1 commit into
qybaihe:mainfrom
XinQijj:fix/claude-json-windows-project-keys

Conversation

@XinQijj

@XinQijj XinQijj commented Dec 2, 2026 •

Copy link
Copy Markdown

Summary

On Windows, "detect configs" never finds the MCP servers a project has in ~/.claude.json, unless that project's key happens to use backslashes.

hub.ts looks the workspace up with projects[root], and root comes from realpath: C:\Users\me\app. Claude Code on Windows writes project keys with forward slashes (C:/Users/me/app); older versions used backslashes. On the machine I tested on, 5 of the 8 project keys in ~/.claude.json use forward slashes, so those projects' servers were never offered for import.

Before / after. I ran the real detectConfigs with a temporary home folder whose ~/.claude.json has one project with one server, keyed with each kind of separator:

Key in ~/.claude.json main this PR
C:\Users\…\proj ["projtool"] ["projtool"]
C:/Users/…/proj [] ["projtool"]

Change. A new helper, findClaudeProjectEntries(projects, root, platform) in configParser.ts:

  • On win32: compares keys as Windows paths: either separator, any case, with or without a trailing slash. It returns every matching entry with the exact key first, so a project keyed both ways (for example, after a Claude Code upgrade) yields both. The hub already removes duplicate server names.
  • Elsewhere: keeps the exact-key lookup, since paths there are case-sensitive.

hub.ts loops over the entries instead of reading projects[root].

Test. The new case in configParser.test.ts passes the platform explicitly, so the Windows comparison runs on all three CI systems. It covers forward slashes, a different case, trailing separators, a project keyed both ways, a different folder, and exact-only matching on Linux.

Checklist

  • npm run typecheck passes
  • npm test passes: 878 passed and 2 skipped on Windows 11. One test failed, proxyTransport.test.ts "connects to an IPv6 SOCKS proxy with a bare socket hostname"; it fails the same way on main because the test machine refuses IPv6 loopback connections. npm run build passes.
  • No real tokens, cookies, or personal identifiers included in code, tests, or docs

… uses forward slashes

Config detection looked up the workspace in ~/.claude.json's `projects`
with `projects[root]`, where `root` comes from realpath (C:\Users\me\app).
Claude Code on Windows writes project keys with forward slashes
(C:/Users/me/app), older versions with backslashes, so the lookup missed
every project written the newer way and its MCP servers were never
offered for import.

findClaudeProjectEntries compares keys as Windows paths on win32 (either
separator, any case, optional trailing slash) and returns every matching
entry, the exact key first, so a project keyed both ways yields both.
Other platforms keep the exact-key lookup.
@XinQijj
XinQijj force-pushed the fix/claude-json-windows-project-keys branch from 17cb3ef to f6c021e Compare December 2, 2026 14:19

This branch has not been deployed

No deployments
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.

1 participant