From 242c7197b633f2b270780eaa7ee5c6158ebca808 Mon Sep 17 00:00:00 2001 From: Dickson Tsai Date: Wed, 25 Jun 2025 00:59:44 -0700 Subject: [PATCH] Update MCP types to align with what Claude Code expects --- src/claude_code_sdk/types.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/claude_code_sdk/types.py b/src/claude_code_sdk/types.py index 21ae8ff..bd3c726 100644 --- a/src/claude_code_sdk/types.py +++ b/src/claude_code_sdk/types.py @@ -11,11 +11,32 @@ PermissionMode = Literal["default", "acceptEdits", "bypassPermissions"] # MCP Server config -class McpServerConfig(TypedDict): - """MCP server configuration.""" +class McpStdioServerConfig(TypedDict): + """MCP stdio server configuration.""" - transport: list[str] - env: NotRequired[dict[str, Any]] + type: NotRequired[Literal["stdio"]] # Optional for backwards compatibility + command: str + args: NotRequired[list[str]] + env: NotRequired[dict[str, str]] + + +class McpSSEServerConfig(TypedDict): + """MCP SSE server configuration.""" + + type: Literal["sse"] + url: str + headers: NotRequired[dict[str, str]] + + +class McpHttpServerConfig(TypedDict): + """MCP HTTP server configuration.""" + + type: Literal["http"] + url: str + headers: NotRequired[dict[str, str]] + + +McpServerConfig = McpStdioServerConfig | McpSSEServerConfig | McpHttpServerConfig # Content block types