claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] User-level MCP servers don't load in worktree sessions

Open adelaidasofia opened this issue 7 months ago • 5 comments

Description

MCP servers configured in ~/.claude/settings.json (user-level) do not load when Claude Code is running inside a git worktree (e.g., claude -w <worktree>). The servers start fine when tested manually and work in regular (non-worktree) sessions.

Steps to Reproduce

  1. Add an MCP server to ~/.claude/settings.json:
{
  "mcpServers": {
    "rescuetime": {
      "command": "fastmcp",
      "args": ["run", "/path/to/server.py"],
      "env": { "API_KEY": "..." }
    }
  }
}
  1. Start a regular Claude Code session in a repo -- MCP tools appear in deferred tools list. Works.
  2. Start a worktree session: claude -w my-worktree (or enter an existing worktree)
  3. MCP tools do NOT appear. ToolSearch returns no matches for the server name.
  4. The server binary runs fine when tested manually from the worktree directory (fastmcp run server.py starts without error).

Expected Behavior

User-level MCP servers from ~/.claude/settings.json should load regardless of whether the session is in a worktree or the main working tree.

Actual Behavior

MCP servers silently fail to connect in worktree sessions. No error is shown. The tools simply don't appear.

Environment

  • Claude Code version: latest (April 2026)
  • macOS (Darwin 25.4.0, arm64)
  • Git worktrees created via claude -w or manually via git worktree add
  • FastMCP 3.2.3 (also reproduced with a uv run based community MCP server)

Additional Context

This is related to a known pattern where worktree sessions also silently skip UserPromptSubmit hooks. It appears worktree sessions may not fully inherit user-level configuration. Project-level settings (.claude/settings.local.json) ARE read, but user-level MCP servers are not connected.

Workaround: duplicate the MCP config into the project-level .claude/settings.local.json, but this is fragile and requires manual sync.

adelaidasofia avatar Apr 14 '26 04:04 adelaidasofia

Found 1 possible duplicate issue:

  1. https://github.com/anthropics/claude-code/issues/38914

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Apr 14 '26 04:04 github-actions[bot]

Not a duplicate. #38914 is about user-level permissions not inheriting in worktree sessions; this issue is about user-level MCP servers silently failing to connect. Same root cause (worktree config inheritance), but different subsystem and different fix surface. Linking as related.

adelaidasofia avatar Apr 14 '26 05:04 adelaidasofia

Is this still not fixed? Worktrees are incredibly important and not being able to use MCPs within Worktrees is crippling to the harness' functionality.

chris-castillo-dev avatar May 05 '26 22:05 chris-castillo-dev

+1 on this, I'm likely having the same issue with the laravel-boost MCP.

works without a -w <worktree> flag:

  ❯ /mcp                                                                                                                                                                                                                                                                                                                                                                                                                                     
  
  Laravel-boost MCP Server
  
  Status:           ✔ connected

doesn't work with a -w <worktree> flag:

❯ /mcp                                                                                                                                                                                                                                                                                                                                                                                                                                     
  ⎿  Failed to reconnect to laravel-boost: -32000

dominickbrasileiro avatar Jun 02 '26 17:06 dominickbrasileiro

+1 this is super disruptive

bobweishar avatar Jun 10 '26 16:06 bobweishar

Is this still not fixed? Worktrees are incredibly important and not being able to use MCPs within Worktrees is crippling to the harness' functionality.

3 months and no update to this issue? Has this even been confirmed as a bug and added to an action list?

chris-castillo-dev avatar Jul 13 '26 16:07 chris-castillo-dev