Skip to main content
Claude Code has a dual role in the MCP ecosystem: it can consume tools and resources from external MCP servers (client mode) and it can expose its own tools to other agents (server mode).

Dual role overview

MCP client

Connects to external MCP servers to discover and invoke their tools, browse resources, and handle authentication.

MCP server

Exposes Claude Code’s own tools via the MCP protocol so other AI agents can use Claude Code as a tool server.

Client features

When acting as an MCP client, Claude Code connects to one or more MCP servers and provides the following capabilities:
Enumerates all tools advertised by connected MCP servers. Discovered tools are surfaced alongside built-in tools and are available to the model during a session.
Lists and reads MCP-exposed resources using ListMcpResourcesTool and ReadMcpResourceTool. Resources can be documents, data files, or any content the server exposes.
ToolSearchTool enables deferred discovery — tools are loaded at runtime rather than at startup, reducing initialization overhead for servers with large tool catalogs.
McpAuthTool handles MCP server authentication flows, including OAuth and custom auth schemes. The approval flow is managed in src/services/mcpServerApproval.tsx.
The useMcpConnectivityStatus hook tracks the health of MCP server connections and surfaces connectivity errors to the user.

Server mode

When launched via src/entrypoints/mcp.ts, Claude Code runs as an MCP server. In this mode, it exposes its own tools and resources over the MCP protocol, allowing other AI agents or orchestration systems to invoke Claude Code capabilities programmatically.
# Launch Claude Code as an MCP server
claude --mcp-server
Server mode is intended for multi-agent pipelines where Claude Code acts as a capable sub-agent. All standard tools (file editing, shell execution, search, etc.) are available to the calling agent.
ToolPurpose
MCPToolInvoke a tool on a connected MCP server
ListMcpResourcesToolList all resources available from connected MCP servers
ReadMcpResourceToolRead a specific resource from an MCP server
McpAuthToolAuthenticate with an MCP server
ToolSearchToolDiscover deferred tools from MCP servers at runtime

Configuration

MCP servers are configured via the /mcp command or in your settings files. Each server entry specifies the transport (stdio or HTTP), the command or URL, and any environment variables needed.
# Open the MCP server configuration interface
/mcp
After adding a new MCP server, use ToolSearchTool or restart the session to ensure all tools from the new server are discovered and available.
Source location: src/services/mcp/

Build docs developers (and LLMs) love