Skip to main content
Claude Code has full bidirectional support for the Model Context Protocol (MCP). It acts as an MCP client — consuming tools and resources from external MCP servers — and can also run as an MCP server, exposing its own tools to other AI agents. The MCP integration lives in src/services/mcp/.

Client mode

When connecting to external MCP servers, Claude Code provides the following capabilities:

Tool discovery

Enumerates all tools exposed by connected MCP servers and makes them available in the tool-call loop.

Resource browsing

Lists and reads MCP-exposed resources, allowing Claude to reference external data sources.

Dynamic tool loading

ToolSearchTool discovers and loads deferred tools from MCP servers at runtime without restarting.

Authentication

McpAuthTool handles MCP server authentication flows, including OAuth and token-based auth.

Connectivity monitoring

The useMcpConnectivityStatus hook tracks connection health for all registered MCP servers.

Server mode

Claude Code can be launched as an MCP server via src/entrypoints/mcp.ts. In this mode, it exposes its own tools and resources over the MCP protocol, allowing other AI agents or automation systems to use Claude Code as a tool backend.
# Launch Claude Code in MCP server mode
claude --mcp
Server mode is intended for agent-to-agent workflows where another system needs to invoke Claude Code’s tools programmatically.

MCP tools

Invokes a tool on a connected MCP server. Takes the server name, tool name, and tool arguments as input.
Lists all resources available on a connected MCP server. Returns resource URIs and metadata.
Reads the contents of a specific MCP resource by URI.
Initiates and completes the authentication flow for an MCP server that requires credentials.
Discovers deferred tools from MCP servers at runtime. Used for servers that expose large or dynamic tool sets.

Configuration

MCP servers are configured using the /mcp slash command or by editing the settings file directly. The server approval flow is implemented in src/services/mcpServerApproval.tsx.
1

Open MCP configuration

Run /mcp in the Claude Code REPL to open the MCP management interface.
2

Add a server

Provide the server’s connection details (transport type, URL or command, and any required environment variables).
3

Approve the server

Claude Code will prompt you to approve the new server before connecting. This approval is stored in your settings.
4

Use server tools

Once connected, the server’s tools appear in Claude’s tool-call loop automatically.

Use cases

Connect Claude Code to MCP servers that expose domain-specific tools — databases, internal APIs, code analysis services, or any MCP-compatible tool provider.
Claude Code (client) ──► External MCP Server
                          - Database queries
                          - Internal API calls
                          - Custom tool logic

Build docs developers (and LLMs) love