claude-agent-sdk-python icon indicating copy to clipboard operation
claude-agent-sdk-python copied to clipboard

create_sdk_mcp_server() passes unsupported version parameter to Server.__init__()

Open WarrenZhu050413 opened this issue 2 months ago • 0 comments

Bug Report: create_sdk_mcp_server() passes unsupported version parameter causing TypeError

Summary

Agent deployment fails with TypeError: Server.__init__() got an unexpected keyword argument 'version' when using create_sdk_mcp_server(). The SDK passes a version parameter to MCP's Server class, but Server.__init__() only accepts name in all released versions of the mcp package (0.9.1 through 1.21.0).

Environment

  • SDK Version: claude-agent-sdk 0.1.6 (Python)
  • MCP Version: mcp 0.9.1 (also tested with 1.21.0 - same issue)
  • Python Version: 3.11.13
  • OS: macOS (Darwin 24.6.0)

Expected Behavior

Agent deployment should work without errors when using create_sdk_mcp_server() to create SDK MCP servers with custom tools.

Actual Behavior

Deployment crashes with:

TypeError: Server.__init__() got an unexpected keyword argument 'version'

This occurs because:

  1. SDK's create_sdk_mcp_server() calls Server(name, version=version) (source)
  2. But MCP's Server.__init__(self, name: str) only accepts name - no version parameter

Root Cause Analysis

SDK Code (claude_agent_sdk/__init__.py):

def create_sdk_mcp_server(
    name: str, version: str = "1.0.0", tools: list[SdkMcpTool[Any]] | None = None
) -> McpSdkServerConfig:
    from mcp.server import Server
    # ...
    server = Server(name, version=version)  # ❌ version not supported!

MCP Server Class (all versions 0.9.1 → 1.21.0):

class Server:
    def __init__(self, name: str):  # Only accepts name!
        self.name = name
        # ...

Verified signatures:

  • mcp==0.9.1: Server.__init__(self, name: str)
  • mcp==1.21.0: Server.__init__(self, name: str) (unchanged)

The version parameter has never been supported by the MCP Server class.

Minimal Reproduction

from claude_agent_sdk import tool, create_sdk_mcp_server

@tool("test_tool", "A test tool", {"input": str})
async def test_tool(args: dict) -> dict:
    return {"content": [{"type": "text", "text": "Test"}]}

# This line fails with TypeError
server = create_sdk_mcp_server(
    name="test_server",
    version="1.0.0",  # ← SDK passes this to Server() but it's not accepted
    tools=[test_tool]
)

Full Error:

Traceback (most recent call last):
  File "src/claude_agent_sdk/__init__.py", line 147, in create_sdk_mcp_server
    server = Server(name, version=version)
TypeError: Server.__init__() got an unexpected keyword argument 'version'

WarrenZhu050413 avatar Nov 12 '25 01:11 WarrenZhu050413