This document explains how Claude Code integrates with the Model Context Protocol (MCP) to extend its capabilities through external tools, prompts, and resources. MCP servers enable Claude Code to interact with external systems like GitHub, databases, APIs, and custom services through a standardized protocol.
For information about the general tool execution pipeline and permission system, see Tool System & Permissions. For details about the plugin system that can bundle MCP servers, see Plugin System.
MCP (Model Context Protocol) is a standardized protocol that allows Claude Code to communicate with external servers. This integration enables Claude to interact with external services without requiring built-in implementations for every possible integration.
The following diagram bridges the natural language request for an MCP tool to the specific code entities and transport mechanisms used to fulfill it.
Diagram: MCP Request Lifecycle and Entity Mapping
MCP Architecture Overview
The MCP integration consists of three main layers:
claude.ai connectors and local processes.Configuration File Locations
~/.claude/mcp-servers.json.claude/mcp-servers.json.mcp.json at plugin root or inline mcpServers field in plugin.json plugins/plugin-dev/skills/mcp-integration/SKILL.md23-59claude.ai MCP Connectors
Claude Code supports using MCP connectors from claude.ai, enabling access to remote MCP servers configured in your claude.ai account. Note that claude.ai MCP connectors are disabled when a manual ANTHROPIC_API_KEY is set. Startup notices inform users of connectors that require authentication CHANGELOG.md54
Sources: plugins/plugin-dev/skills/mcp-integration/SKILL.md23-59 CHANGELOG.md54
MCP servers are defined by how they are launched and how they authenticate.
Diagram: Configuration Schema to Transport Mapping
Plugins can bundle MCP servers in two ways:
.mcp.json (Recommended): Clearer separation of concerns for multiple servers plugins/plugin-dev/skills/mcp-integration/SKILL.md23-37plugin.json: Convenient for simple single-server plugins using the mcpServers field plugins/plugin-dev/skills/mcp-integration/SKILL.md44-59| Command | Purpose | Notes |
|---|---|---|
/mcp | Interactive MCP Management Dialog | Browse and manage servers; shows HTTP status and error text if a server fails to connect CHANGELOG.md16 |
claude mcp list | CLI server status | Displays HTTP status and error text for connection failures CHANGELOG.md16 |
claude mcp get | View specific server | Shows status and details of a specific MCP server. |
Validation and Error Handling
stream-json init events include mcp_server_errors for config entries skipped by validation CHANGELOG.md12Sources: plugins/plugin-dev/skills/mcp-integration/SKILL.md23-59 CHANGELOG.md12-16
Claude Code supports four primary transport mechanisms for MCP communication plugins/plugin-dev/skills/mcp-integration/SKILL.md65-166:
| Type | Protocol | Best For | Process Management |
|---|---|---|---|
| stdio | Local Stdin/Stdout | Local tools, custom servers | Claude Code spawns child process. Terminates when Claude Code exits plugins/plugin-dev/skills/mcp-integration/SKILL.md91-93 |
| SSE | Server-Sent Events | Hosted cloud services | OAuth handled automatically plugins/plugin-dev/skills/mcp-integration/SKILL.md115-118 |
| HTTP | REST API | Stateless interactions | Uses standard HTTP headers for Authorization plugins/plugin-dev/skills/mcp-integration/SKILL.md120-136 |
| WebSocket | Real-time Bidirectional | Low-latency requirements | Persistent connection with wss:// support plugins/plugin-dev/skills/mcp-integration/SKILL.md144-160 |
Environment Variable Expansion
All MCP configurations support variable substitution, including ${CLAUDE_PLUGIN_ROOT} for plugin portability plugins/plugin-dev/skills/mcp-integration/SKILL.md167-176 Managed MCP allowlist/denylist entries resolve ${VAR} from the startup environment and managed-settings env CHANGELOG.md27
Sources: plugins/plugin-dev/skills/mcp-integration/SKILL.md65-188 CHANGELOG.md27
MCP tools are automatically prefixed to avoid name collisions and provide context to the model.
Naming Format: mcp__plugin_<plugin-name>_<server-name>__<tool-name> plugins/plugin-dev/skills/mcp-integration/SKILL.md194-200
plugin.json or .mcp.json plugins/plugin-dev/skills/mcp-integration/SKILL.md231-233Sources: plugins/plugin-dev/skills/mcp-integration/SKILL.md194-237
Claude Code manages authentication flows to ensure secure access to external services.
headers field in the configuration plugins/plugin-dev/skills/mcp-integration/SKILL.md256-270env field plugins/plugin-dev/skills/mcp-integration/SKILL.md272-287Sources: plugins/plugin-dev/skills/mcp-integration/SKILL.md243-287
MCP tools integrate with Claude Code's standard permission system.
mcp__plugin_asana_asana__*) plugins/plugin-dev/skills/mcp-integration/SKILL.md218-221Sources: plugins/plugin-dev/skills/mcp-integration/SKILL.md204-221 CHANGELOG.md67
Refresh this wiki
This wiki was recently refreshed. Please wait 5 days to refresh again.