[BUG] Worktree-session feature doesn't carry project-scoped MCP config/auth from originalCwd to worktreePath
Preflight
- [x] Searched existing issues; distinct from #58226 (
.mcp.jsondiscovery) and #32220 (EnterWorktreereinit). Both closed without addressing parent-session MCP/auth inheritance. - [x] Single bug.
- [x] Latest version.
What's Wrong
When Claude Code's worktree-session feature spawns a child session (the one with the worktree-state jsonl record), the child is filed under ~/.claude/projects/<sanitized-worktreePath>/ and looks up MCP config via ~/.claude.json → .projects[<worktreePath>]. The parent session's MCP config (under .projects[<originalCwd>]) doesn't propagate, and any project-scoped OAuth credentials granted under the originalCwd identity aren't accessible.
Result: MCP servers visible and authenticated in the parent session are missing or unauthenticated in the child worktree session.
Steps to Reproduce
- From
/home/user/projects/my-repo, runclaude; configure a project-scoped OAuth MCP server (e.g.claude mcp add clickup --transport http https://mcp.clickup.com/mcp); complete the OAuth flow. - Verify it works in this parent session via
/mcpand a tool call. - From within that session, enter a worktree via Claude Code's worktree-session feature (
EnterWorktreetool //worktreecommand / equivalent). - The child session's first jsonl record contains:
``json``
{
"type": "worktree-state",
"worktreeSession": {
"originalCwd": "/home/user/projects/my-repo",
"worktreePath": "/home/user/projects/my-repo/.claude/worktrees/<name>",
"originalBranch": "<parent-branch>",
"sessionId": "<parent-session-uuid>"
},
"sessionId": "<child-session-uuid>"
}
/mcpin the child session shows the server is unconfigured/unauthenticated for this scope. Tool calls fail or re-trigger OAuth.
Expected
Worktree-session transitions should treat the originalCwd's .projects[…] entry as the inherited base for MCP config and OAuth state. Either copy on transition, or resolve mcpServers and credentials via worktreeSession.originalCwd rather than current cwd.
Actual
Worktree-session child is keyed by worktreePath. No inheritance from originalCwd. User must reconfigure and re-authenticate per worktree.
Evidence
The session jsonl record type: "worktree-state" ties parent session, worktreePath, and originalCwd together — Claude Code already knows the originalCwd at child-session start. The information needed to do the inheritance is right there in the record; it's just not used for MCP resolution.
Verified locally:
- Parent session at
originalCwdhas~/.claude.json.projects["<originalCwd>"].mcpServers = { clickup: {...} }populated and working. - Child worktree session has
~/.claude.json.projects["<worktreePath>"]entry missing entirely. - Recent sessions across multiple repos: only the worktree-session child has the divergent project key; all sibling sessions are filed under the main path and work normally.
Impact
For developers using worktrees as their primary parallel-work mechanism (Claude Code's own tooling encourages this), every new worktree-session triggers a re-auth dialog for each project-scoped OAuth MCP server. Scales as O(repos × concurrent worktrees) of redundant OAuth flows.
User-global remote MCP servers (claude.ai family — Gmail, Calendar, Drive) work correctly across worktree transitions because they're not project-scoped. Only project-scoped servers exhibit this.
Related
- #58226 (closed) —
.mcp.jsondiscovery in worktree checkout; distinct from this issue. - #32220 (closed) —
EnterWorktreemid-session reinit for path-sensitive MCPs; related but doesn't cover parent-session MCP/auth inheritance specifically. - Both leave the worktree-session ⇄ originalCwd inheritance gap untouched, which is the root cause for project-scoped MCP servers.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗