Skip to Content
SubsystemsMCP IntegrationMCP Integration

MCP Integration

Source: src/services/mcp/ (24 files)

Overview

The Model Context Protocol (MCP) is an open standard for AI tool interoperability. Claude Code implements a full MCP client that connects to external MCP servers to extend its tool capabilities.

Architecture

Key Files

FilePurpose
client.tsCore MCP client implementation
config.tsServer configuration loading
auth.tsAuthentication handling
channelPermissions.tsPermission management for MCP tools
elicitationHandler.tsInteractive prompts from MCP servers
InProcessTransport.tsIn-process server transport
SdkControlTransport.tsSDK-based transport

Server Configuration

MCP servers are defined in settings with:

{ "mcpServers": { "server-name": { "command": "npx", "args": ["-y", "@org/mcp-server"], "env": { "API_KEY": "..." } } } }

Capabilities

MCP servers can provide:

  • Tools — Executable functions with JSON Schema parameters
  • Resources — Readable data sources (files, APIs, databases)
  • Prompts — Pre-defined prompt templates for common tasks

Connection Lifecycle

  1. Discovery — Load server configs from settings
  2. Launch — Start server processes (or connect to running servers)
  3. Handshake — Exchange capabilities via MCP protocol
  4. Registration — Register server tools as available Claude Code tools
  5. Execution — Forward tool calls to servers, return results
  6. Cleanup — Gracefully shut down servers on exit

Deep Dive

  • Client Architecture — MCP client internals, transport abstractions (stdio, SSE, in-process)
  • Server Lifecycle — Discovery, launch, handshake, capability exchange, and cleanup
  • Tool Registration — How MCP server tools become Claude Code tools, schema mapping, and permission integration
Last updated on