Problem
claude_code_sdk/types.py imports McpServer only under TYPE_CHECKING, but McpSdkServerConfig uses it as a type annotation. Pydantic 2.12+ requires this type at runtime.
Error
PydanticUserError: Settings is not fully defined; you should define McpServer, then call Settings.model_rebuild().
Location
types.py:11-12 and types.py:182:
if TYPE_CHECKING:
from mcp.server import Server as McpServer # line 11-12
class McpSdkServerConfig(TypedDict):
instance: "McpServer" # line 182 - fails at runtime
Fix
if TYPE_CHECKING:
from mcp.server import Server as McpServer
else:
McpServer = Any
Environment
- claude-code-sdk: 0.0.25
- pydantic: 2.12.5
- Python: 3.11