MCP Integration
Claude Code as MCP Host
The Model Context Protocol (MCP) is the open standard through which Claude Code communicates with external tools. Claude Code acts as an MCP host -- it establishes connections to MCP servers, each providing specific capabilities: filesystem access, database queries, API calls, and much more.
Each MCP server offers a set of tools that Claude can automatically use. You configure the servers once, and Claude decides on its own when to use which tool.
The Three Transport Types
Click a layer to see details
Tap a layer to see details
MCP supports three different ways for Claude Code to communicate with an MCP server:
stdio -- Local Process
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"]
}
}
}
The server runs as a local process on your machine. Communication happens via stdin/stdout -- fast, direct, and without networking. Ideal for tools that access local files or system resources.
http -- Remote Server (recommended)
{
"mcpServers": {
"analytics": {
"url": "https://mcp.example.com/analytics"
}
}
}
The server runs remotely and communicates via HTTP. This is the recommended transport for cloud services, team infrastructure, and production APIs. OAuth authentication is handled automatically.
sse -- Server-Sent Events (deprecated)
{
"mcpServers": {
"legacy": {
"url": "https://old-server.example.com/sse",
"transport": "sse"
}
}
}
SSE was the original remote transport. It still works but is no longer recommended. New integrations should use http.
iWhich Transport to Choose?
Local tools (filesystem, Git, databases on your own machine) use stdio. Everything that runs remotely (cloud APIs, team services) uses http. SSE only for existing legacy servers.
Tool Search: Deferred Loading
One of the most important performance features for MCP is Deferred Loading (also called Tool Search). The problem without Deferred Loading:
| MCP Server | Tokens at Start (without) | Tokens at Start (with) |
|---|---|---|
| GitHub | ~77,000 | ~8,700 |
| Linear | ~45,000 | ~5,200 |
| Jira | ~62,000 | ~6,800 |
Without Deferred Loading, all tool definitions are loaded into the context at startup -- including tools you'll never need in the current session. With a GitHub MCP server alone, that's 25% of the entire context budget.
With Deferred Loading, Claude loads tool definitions only when they're actually needed. This not only saves tokens but also improves accuracy:
- Opus 4: Accuracy rises from 49% to 74% (historical benchmark)
- Opus 4.5: Accuracy rises from 79% to 88% (historical benchmark)
Why does accuracy improve? Fewer irrelevant tool definitions in the context means less distraction -- Claude can focus better on the actually relevant tools.
*Always Enable It
Deferred Loading has virtually no downsides. The minimal delay when first calling a tool is negligible compared to the enormous token savings. Enable it for every MCP server.
Configuration Scopes
MCP servers can be configured at three levels:
Project Level: .mcp.json
{
"mcpServers": {
"project-db": {
"command": "npx",
"args": ["mcp-server-postgres", "postgresql://localhost/mydb"]
}
}
}
This file sits in the project root and is shared via Git. Ideal for project-specific tools that the whole team needs.
User Level: ~/.claude.json
Personal MCP servers available across all projects -- for example, your personal note-taking system or a private API access.
Enterprise: Managed Configuration
IT administrators can centrally prescribe MCP servers via managed-mcp.json. This configuration is automatically distributed to all developers in the company and cannot be overridden locally.
!Security with Project-Level Configuration
Since .mcp.json is shared via Git, make sure not to store any secrets (API keys, passwords) in this file. Use environment variables or the user-level scope for sensitive configurations instead.
MCP Elicitation
MCP servers can request structured user input during execution. This means: An MCP tool doesn't need to have all information upfront; instead, it can ask Claude to prompt the user for missing details.
Example: A deployment tool starts, recognizes that the target environment wasn't specified, and asks Claude to ask the user: "Which environment should be deployed to -- staging or production?"
Subagent-Specific MCP
In agent definitions (.claude/agents/), you can define MCP servers as frontmatter that are only available to that specific agent:
---
mcpServers:
project-db:
command: npx
args: ["mcp-server-postgres", "postgresql://localhost/mydb"]
---
You are a database analyst. Use the project-db tools...
The main agent and other agents don't see these MCP servers -- only the defined agent has access.
Hook Matchers for MCP Tools
Hooks can react to specific MCP tool calls. The naming scheme for the matcher is:
mcp__<server-name>__<tool-name>
Example: A hook that triggers on every GitHub PR create:
{
"hooks": {
"PreToolUse": [
{
"matcher": "mcp__github__create_pull_request",
"command": "scripts/validate-pr.sh"
}
]
}
}
Summary
MCP is the backbone of Claude Code's tool integration. Three transport types cover local and remote scenarios, Deferred Loading dramatically saves context budget, and the various configuration scopes enable flexible setups from individual developers to enterprise. In the next section, we'll look at how to source plugins and MCP servers from the marketplace and the community.