← knowledge.oriz.in

MCP servers: use workspace scope, not global

rule mcpscopeworkspace-onlyhard-rule

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 flag Writes to Visible to Committed?
-s local (default) ~/.claude.json projects[<cwd>].mcpServers Just you, on this machine, in this dir ?
-s project <cwd>/.mcp.json Anyone 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