MCP Server Integration
Scopes and storage
| Scope | Stored in | Who gets it |
|---|---|---|
| local (default) | ~/.claude.json, under the project path | You, this project only |
| project | .mcp.json at the project root | Everyone who clones the repo (commit it) |
| user | ~/.claude.json | You, all projects |
Precedence, highest first: local, project, user, plugin-provided, claude.ai connectors. The whole entry from the winning source is used; fields are not merged across scopes. Managed servers rank above all of these.
Secrets: environment variable expansion
In .mcp.json: ${VAR} and ${VAR:-default}, allowed in command, args, env, url and headers. This is how a shared .mcp.json references tokens without containing them. An unset variable with no default loads with a warning and the literal ${VAR} text. Never put a real token in .mcp.json.
Transports
- http: recommended for remote servers; supports OAuth.
- stdio: a local process on your machine.
- sse: deprecated; prefer http.
- ws: persistent connection; header auth only.
Commands
claude mcp add --transport http <name> <url> · claude mcp add --transport stdio <name> -- <command> [args] (the -- separates Claude's flags from the server command) · --env KEY=value · --scope local|project|user · claude mcp list · claude mcp get · claude mcp remove · claude mcp add-json. Inside a session, /mcp shows status, authentication and reconnect.
Approval and trust
- Interactive sessions prompt for approval before using servers from a project's
.mcp.json. - In
claude -p, the Agent SDK and cloud sessions there is no prompt, so project servers load without asking. Block one everywhere withdisabledMcpjsonServers;--strict-mcp-configuses only servers from--mcp-config.
Using MCP content
- Tools appear as
mcp__<server>__<tool>; hook matchers and permission rules use this name (a regex such as^mcp__matches all MCP tools). - Resources are referenced with
@server:resource(for example@github:repos/owner/repo/issues). - Output limits: warning at 10,000 tokens, default maximum 25,000; raise with
MAX_MCP_OUTPUT_TOKENS. Startup timeoutMCP_TIMEOUT, tool timeoutMCP_TOOL_TIMEOUT. - Tool search (lazy loading of tool definitions) is on by default.
- Remote servers that return 401/403 need OAuth:
/mcporclaude mcp login <name>. Headless runs cannot complete OAuth; authenticate interactively first.
Choosing a server (design guidance)
Use an existing community or vendor server for standard integrations (GitHub, Slack, databases); build a custom server for internal systems or when you need tight control over tool design and output size.
Exam traps
- Committing a token in
.mcp.jsoninstead of${VAR}. - Putting a team-wide server in user scope, so teammates do not get it.
- Expecting scope fields to merge. The winning scope's entry replaces others.
- Assuming CI prompts for project-server approval. It does not.
- Using SSE for a new remote server.
References
- MCP in Claude Code — checked Oct 16, 2026
- Common workflows — checked Oct 16, 2026
Check your understanding
A server should be shared with the whole team via git. Scope and file?Show answerHide answer
Answer
Project scope,.mcp.json.How does a shared
.mcp.jsonreference an API token safely?Show answerHide answerAnswer
"Authorization": "Bearer ${API_KEY}"with the value in each developer's environment.Which scope wins when a name exists at local and user?Show answerHide answer
Answer
Local.