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).Server type. Optional for backwards compatibility (defaults to
"stdio").Command to execute (e.g.,
"node", "python", "npx").Command arguments.
Environment variables for the server process.
Example
McpSSEServerConfig
Configuration for Server-Sent Events (SSE) MCP servers.Server type.
SSE endpoint URL.
HTTP headers for the connection.
Example
McpHttpServerConfig
Configuration for HTTP-based MCP servers.Server type.
HTTP endpoint URL.
HTTP headers for requests.
Example
McpSdkServerConfig
Configuration for in-process MCP servers using the Python MCP SDK.Server type.
Server name identifier.
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.Server name as configured.
Current connection status.
Server information from MCP handshake (available when connected).
Error message (available when status is
"failed").Server configuration (includes URL for HTTP/SSE servers).
Configuration scope (e.g.,
"project", "user", "local", "claudeai", "managed").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