[FEATURE] Better Monorepo Support
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other:
- Claude CLI version: 1.0.29<!-- output of
claude --version--> - Operating System: Linux
- Terminal: Ghostty
Bug Description
I have a monorepository and I put a .mcp.json and some common commands in .claude/commands; but the way we work within the monorepo is from within service directories.
It would be nice if Claude would detect shared MCP and Commands within a Git root, by searching up.
Commands in subdirectories should be working, is that not working for you?
Subdirectories are fine, but when I launch Claude in a subdirectory the MCP config and commands at the root of the repository are not loaded.
there are a few issues that I can see with monorepos:
- mcp config as mentionned above (and in #374)
- setting (like permissions) seem to behave like the mcp config => only current folder seem to be considered project scope
- setups that rely on shell hooks (direnv, mise-en-place) or have zoxide installed, see #2632
what seems to work well: hierarchical memory
- repo_root/CLAUDE.md
- repo_root/service_a/CLAUDE.md
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Workaround: MCP Server Isolation Using disabledMcpjsonServers
For those running multi-project workspaces or monorepos where different directories need different MCP servers, here's a pattern that works:
The Problem: MCP configs merge down the directory tree. If you have:
/workspace/.mcp.json ← defines "workspace-tools" server
/workspace/project-a/.mcp.json ← defines "project-a-tools" server
Opening Claude in project-a/ gives you BOTH servers. There's no "inherit": false flag.
The Solution:
Use disabledMcpjsonServers in the subdirectory's .claude/settings.local.json:
{
"disabledMcpjsonServers": ["workspace-tools"],
"enableAllProjectMcpServers": false
}
This explicitly blocks the parent's MCP server from loading in that directory.
Full Example:
/workspace/
├── .mcp.json ← workspace-level MCP
├── project-a/
│ ├── .mcp.json ← project-a MCP
│ └── .claude/
│ └── settings.local.json ← blocks workspace MCP
└── project-b/
└── .claude/
└── settings.local.json ← blocks workspace MCP
Caveats:
- Requires restart after config changes
- Not true isolation (AI could edit the settings file)
-
enableAllProjectMcpServers: falseprevents auto-enabling inherited servers
What would be better:
A native "inherit": false in .mcp.json, or scoped servers:
{
"mcpServers": {
"my-server": {
"command": "...",
"scope": "this-directory-only"
}
}
}
Hope this helps others until proper scoping is implemented!
I made a workaround for using hooks in monorepos: https://github.com/jack-michaud/claude-code-monorepo-hook-router/