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 viasrc/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.
Server mode is intended for agent-to-agent workflows where another system needs to invoke Claude Code’s tools programmatically.
MCP tools
MCPTool
MCPTool
Invokes a tool on a connected MCP server. Takes the server name, tool name, and tool arguments as input.
ListMcpResourcesTool
ListMcpResourcesTool
Lists all resources available on a connected MCP server. Returns resource URIs and metadata.
ReadMcpResourceTool
ReadMcpResourceTool
Reads the contents of a specific MCP resource by URI.
McpAuthTool
McpAuthTool
Initiates and completes the authentication flow for an MCP server that requires credentials.
ToolSearchTool
ToolSearchTool
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.
Add a server
Provide the server’s connection details (transport type, URL or command, and any required environment variables).
Approve the server
Claude Code will prompt you to approve the new server before connecting. This approval is stored in your settings.
Use cases
- Connecting to external servers
- Exposing Claude Code to agents
Connect Claude Code to MCP servers that expose domain-specific tools — databases, internal APIs, code analysis services, or any MCP-compatible tool provider.
Related
/mcpcommand — Manage MCP server connections- Tools reference — Full catalog of tools, including MCP-related tools
- Architecture — How MCP fits into the core pipeline