Overview
The Claude Agent SDK supports Model Context Protocol (MCP) servers for extending Claude’s capabilities with custom tools and resources.McpServerConfig
Union type for all MCP server configuration types.McpStdioServerConfig
Configuration for stdio-based MCP servers (most common).Literal['stdio']
Server type. Optional for backwards compatibility (defaults to
"stdio").str
required
Command to execute (e.g.,
"node", "python", "npx").list[str]
Command arguments.
dict[str, str]
Environment variables for the server process.
Example
McpSSEServerConfig
Configuration for Server-Sent Events (SSE) MCP servers.Literal['sse']
required
Server type.
str
required
SSE endpoint URL.
dict[str, str]
HTTP headers for the connection.
Example
McpHttpServerConfig
Configuration for HTTP-based MCP servers.Literal['http']
required
Server type.
str
required
HTTP endpoint URL.
dict[str, str]
HTTP headers for requests.
Example
McpSdkServerConfig
Configuration for in-process MCP servers using the Python MCP SDK.Literal['sdk']
required
Server type.
str
required
Server name identifier.
McpServer
required
MCP server instance from the
mcp package.Example
MCP Status Types
Types returned byClaudeSDKClient.get_mcp_status() for querying server connection status.
McpServerConnectionStatus
"connected"- Server is connected and ready"failed"- Connection failed (seeerrorfield)"needs-auth"- Server requires authentication"pending"- Connection in progress"disabled"- Server is disabled
McpServerStatus
Status information for a single MCP server.str
required
Server name as configured.
McpServerConnectionStatus
required
Current connection status.
McpServerInfo
Server information from MCP handshake (available when connected).
str
Error message (available when status is
"failed").McpServerStatusConfig
Server configuration (includes URL for HTTP/SSE servers).
str
Configuration scope (e.g.,
"project", "user", "local", "claudeai", "managed").list[McpToolInfo]
Tools provided by this server (available when connected).
McpStatusResponse
Response fromClaudeSDKClient.get_mcp_status().
Example
MCP Control Methods
The SDK provides methods for controlling MCP servers:Reconnect Server
Toggle Server
Send MCP Message
Loading MCP Servers from File
You can load MCP server configurations from a JSON file:Related Types
- ClaudeAgentOptions - Main configuration including MCP servers
- Errors - Error types for MCP connection failures