claude-code - 💡(How to fix) Fix [BUG] User-level MCP servers don't load in worktree sessions [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#47733Fetched 2026-04-15 06:43:48
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×2

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.

Error Message

  1. The server binary runs fine when tested manually from the worktree directory (fastmcp run server.py starts without error). MCP servers silently fail to connect in worktree sessions. No error is shown. The tools simply don't appear.

Root Cause

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.

Fix Action

Fix / Workaround

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

Code Example

{
  "mcpServers": {
    "rescuetime": {
      "command": "fastmcp",
      "args": ["run", "/path/to/server.py"],
      "env": { "API_KEY": "..." }
    }
  }
}
RAW_BUFFERClick to expand / collapse

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.

extent analysis

TL;DR

Duplicate the MCP server configuration from ~/.claude/settings.json to the project-level .claude/settings.local.json to enable loading of user-level MCP servers in worktree sessions.

Guidance

  • Verify that the MCP server configuration is correctly formatted in both ~/.claude/settings.json and .claude/settings.local.json.
  • Check that the fastmcp command and server.py script are executable and properly configured in the worktree environment.
  • Test the MCP server manually in the worktree directory to ensure it runs without errors.
  • Consider automating the synchronization of user-level and project-level MCP server configurations to avoid manual duplication.

Example

No code snippet is provided as the issue is related to configuration files and environment settings.

Notes

This workaround may not be ideal, as it requires manual synchronization of configurations. A more permanent solution would involve modifying Claude Code to properly inherit user-level configurations in worktree sessions.

Recommendation

Apply the workaround by duplicating the MCP server configuration to the project-level .claude/settings.local.json, as this is the most straightforward way to enable loading of user-level MCP servers in worktree sessions.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] User-level MCP servers don't load in worktree sessions [2 comments, 2 participants]