.mcp.json: add isolation option to prevent parent directory config inheritance

Resolved 💬 4 comments Opened Apr 2, 2026 by pekkaliu Closed May 10, 2026

Problem

When Claude Code is launched in a child directory that has its own .mcp.json and .git/, it still loads and merges .mcp.json from parent directories. This causes incorrect MCP server configuration when parent and child directories define the same servers with different headers.

Example setup

~/workspace/              ← git repo with .mcp.json (X-Org: parent-org)
└── project-a/            ← separate git repo with .mcp.json (X-Org: child-org)

Both directories have their own .git/ (separate repositories). When Claude Code starts in ~/workspace/project-a/, it loads both .mcp.json files. Same-named servers from the parent override the child's configuration.

Current workaround

Use different server names in child .mcp.json (e.g., my-server-child instead of my-server). This works but:

  • Doubles the number of MCP connections (both parent and child servers connect)
  • Creates inconsistent tool name prefixes
  • Requires duplicate permission entries in settings.local.json

Proposed solution

One or both of:

  1. mcpInherit: false — a field in .mcp.json that prevents loading parent directory configs:
{
  "mcpInherit": false,
  "mcpServers": { ... }
}
  1. Git root as project boundary — when a directory has its own .git/, treat it as an independent project and don't load .mcp.json from parent directories.

Expected behavior

Child directory .mcp.json should be self-contained when the child is its own git repository. Parent directory MCP servers should not load unless explicitly inherited.

Environment

  • Claude Code CLI (latest)
  • macOS
  • Nested git repositories with separate .mcp.json files

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗