type: rule
status: active
timestamp: 2026-06-27
tags: [mcp, scope, workspace-only, hard-rule]

MCP servers: use workspace scope, not global

Workspace-scoped MCP in committed .mcp.json. claude mcp add -s project. Default scope wrong

MCP scope: workspace, not global

Rule

When adding any MCP server for use in this workspace:

The claude mcp add command itself is fine. The -s flag is what matters.

Scope reference

Scope flagWrites toVisible toCommitted?
-s local (default)~/.claude.json projects[<cwd>].mcpServersJust you, on this machine, in this dir?
-s project<cwd>/.mcp.jsonAnyone who clones the repo?
-s user~/.claude.json mcpServers (top-level)Just you, every project on this machine?

Use -s project for everything workspace-related.

Why

  1. Reproducible across machines: clone the repo, MCPs come with it.
  2. No global pollution: ~/.claude.json stays minimal.
  3. Same principle as AGENTS.md: workspace-scoped configuration only.
  4. Visible in git: anyone reviewing the repo sees which MCPs are wired.

When to deviate

The exceptions are narrow:

Migration

If claude mcp add was used without -s project and the MCP landed in ~/.claude.json:

# Re-add with the right scope flag — this writes to .mcp.json
claude mcp add <name> -s project -- <command> <args...>

# Then remove the stray local-scope entry from ~/.claude.json
node -e "
const fs=require('fs'); const p=require('os').homedir()+'/.claude.json';
const j=JSON.parse(fs.readFileSync(p));
delete j.projects['C:/d/oriz'].mcpServers['<server-name>'];
fs.writeFileSync(p, JSON.stringify(j, null, 2));
"

Cross-refs


Edit on GitHub · Back to index