Feature Request: Share MCP authentication across git worktrees
Problem
When using git worktrees for parallel development, MCP server authentication doesn't carry over between worktrees. Each worktree prompts for re-authentication even though:
- MCP OAuth credentials are stored at the user level (
~/.claude/.credentials.json) - The
.mcp.jsonserver definitions are identical (same repo, just different worktree paths)
Root Cause
Credentials in ~/.claude/.credentials.json are keyed by serverName|hash (e.g., linear|638130d5ab3558f4). This hash appears to incorporate the project path, so a worktree at ../wt-1/ generates a different hash than ./wt2-2/ and doesn't find existing credentials.
Use Case
Many teams use git worktrees to run multiple Claude Code sessions in parallel on different features. Having to re-authenticate 5-7 MCP servers in each new worktree creates significant friction.
Proposed Solutions
-
Worktree detection: When Claude Code detects it's running in a git worktree, use the main repository's path for credential hash computation instead of the worktree path.
-
Config option: Add a setting like
mcpCredentialRootthat specifies which path to use for credential lookup, allowing users to point all worktrees to a shared credential scope. -
Content-based hashing: If the hash was based on
.mcp.jsoncontents + server URL (rather than file path), worktrees with identical configs would naturally share credentials.
Environment
- macOS (though likely affects all platforms)
- Using HTTP-based MCP servers (Linear, Honeycomb, Figma, Neon, Sentry, etc.)
- Git worktrees created via
git worktree add
Workaround
Currently, users must run /mcp and re-authenticate each server in every new worktree, which is tedious but functional.