[BUG] MCP servers from .mcp.json not loaded when using --worktree flag
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When using claude --worktree, MCP servers defined in a committed .mcp.json file are not available in the session, even though the file is physically present in the worktree checkout.
It appears MCP config discovery and server initialization happens based on the original repo directory before the worktree is set up, and doesn't re-run after the worktree becomes the working directory.
Steps to Reproduce
- Have a repo with a committed
.mcp.json(e.g.demo-app/.mcp.json) - Run
claude --worktree - The file exists in the worktree (confirmed via
ls), but the MCP server is not configured/available
Example repo: https://github.com/mxschmitt/aicouncil-talk-e2e-testing-with-ai/blob/main/demo-app/.mcp.json
Expected Behavior
MCP servers defined in .mcp.json files should be discovered and initialized relative to the worktree's working directory, so they work the same as when running claude directly in the repo.
Actual Behavior
MCP servers are not loaded. The .mcp.json is ignored despite being present in the worktree.
Related Issues
- #32220 — MCP servers should reinitialize when session enters a git worktree (closed as stale, not fixed)
- #12885 — working directory mismatch with worktrees
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗