fix: Claude Code registrations invisible to CheckStatus (duplicate path-variant keys, git worktrees)#1280
Conversation
ReadUserScopeConfig merged duplicate normalized project keys from
~/.claude.json ("D:/Dev/X" vs "D:\Dev\X") last-entry-wins, on the
assumption the last is most recent. JSON property order is not
correlated with recency across variants: when the last duplicate is a
stale entry without mcpServers it shadows the real registration, and
CheckStatus reports NotConfigured despite a working
`claude mcp add --scope local` setup (observed live 2026-07-20).
Merge by preferring the entry that actually carries a UnityMCP
registration (then any mcpServers, then last-wins as before).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`claude mcp add --scope local` keys the registration in ~/.claude.json by the git MAIN repo root. When the Unity project is a linked worktree (e.g. C:/Dev/stay-booping -> repo C:/Dev/stay) that key is a sibling path, so ReadUserScopeConfig's ancestor walk never finds it and CheckStatus reports NotConfigured while the CLI itself resolves the worktree fine (`claude mcp list` shows Connected). Parse the main root from the worktree's .git pointer file and retry the walk from there. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughClaude user-scope configuration lookup now ranks duplicate project entries, stops searches at configured project boundaries, and supports linked git worktrees by retrying from the main repository root. ChangesClaude configuration resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Warning |
Description
Using claude multi-agent, I often have worktrees open in Unity while also having changes to a branch. In these circumstances,
ReadUserScopeConfigcan reportNotConfiguredfor a workingclaude mcp add --scope localregistration —claude mcp listshows UnityMCP Connected, but the MCP for Unity window says Claude Code isn't configured. Two independent causes, both observed live on Windows 11 on 2026-07-20:~/.claude.jsonaccumulates duplicateprojectskeys for the same directory in different separator forms (D:/Dev/XvsD:\Dev\X). The reader merges duplicates last-entry-wins on the assumption the last is most recent, but JSON property order is not correlated with recency across variants — a stale variant withoutmcpServerscan shadow the real entry.claude mcp add --scope localkeys the registration by the git main repo root. For a Unity project in a linked worktree (e.g.C:/Dev/stay-booping→ repoC:/Dev/stay) that key is a sibling path, so the reader's ancestor walk can never reach it. The CLI resolves worktrees symmetrically, so the registration genuinely works — only the status check is blind.Type of Change
Changes Made
All in
MCPForUnity/Editor/Clients/McpClientConfiguratorBase.cs:RegistrationRank: UnityMCP > anymcpServers> none; last-wins preserved among equal ranks)..gitpointer file (gitdir: <root>/.git/worktrees/<name>, relative paths resolved) and retry the walk from there (newGetGitMainRepoRoot). Regular checkouts (.gitdirectory) are unaffected.FindUnityServerFromWalkso both starting points share it; existing semantics preserved, including "stop at the first project entry found even without UnityMCP".Compatibility / Package Source
#beta,#main, tag, branch, orfile:):https://github.com/conjoyco/unity-mcp.git?path=/MCPForUnity#v10.1.0-conjoyco.1(branchfix/claude-config-key-matching, cut fromv10.1.0)Packages/packages-lock.json(if using a Git package URL):2d00ed2e877fdeb103fa64e3b0ed72f5c112a857Testing/Screenshots/Recordings
cd Server && uv run pytest tests/ -v)Live verification against both original failures (details in Additional Notes):
CheckStatuson the worktree project returnedNotConfiguredbefore the patch andConfiguredafter, with identical inputs (claude mcp listConnected throughout).mcpServersordered after the real forward-slash key) — patched reader still reportsConfigured. No regression on a project with a single clean key.Documentation Updates
tools/UPDATE_DOCS_PROMPT.md(recommended)Related Issues
Relates to #664 (the
--scope localregistration path this reader parses).Additional Notes
RegistrationRank/GetGitMainRepoRootif you'd like it as part of this PR.v10.1.0; happy to rebase ontobetaif preferred — both commits are self-contained in one file and should cherry-pick cleanly.~/.claude.jsonwith different cwd string forms, and worktree-based Unity projects are common in multi-branch workflows.🤖 Generated with Claude Code
Summary by CodeRabbit