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:Tool discovery
Tool discovery
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.
Resource browsing
Resource browsing
Lists and reads MCP-exposed resources using
ListMcpResourcesTool and ReadMcpResourceTool. Resources can be documents, data files, or any content the server exposes.Dynamic tool loading
Dynamic tool loading
ToolSearchTool enables deferred discovery — tools are loaded at runtime rather than at startup, reducing initialization overhead for servers with large tool catalogs.Authentication
Authentication
McpAuthTool handles MCP server authentication flows, including OAuth and custom auth schemes. The approval flow is managed in src/services/mcpServerApproval.tsx.Connectivity monitoring
Connectivity monitoring
The
useMcpConnectivityStatus hook tracks the health of MCP server connections and surfaces connectivity errors to the user.Server mode
When launched viasrc/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.
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.
Related tools
| Tool | Purpose |
|---|---|
MCPTool | Invoke a tool on a connected MCP server |
ListMcpResourcesTool | List all resources available from connected MCP servers |
ReadMcpResourceTool | Read a specific resource from an MCP server |
McpAuthTool | Authenticate with an MCP server |
ToolSearchTool | Discover 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.
src/services/mcp/