Skip to content

Comments

feat(types): add mcp_servers field to AgentDefinition#592

Open
gspeter-max wants to merge 1 commit intoanthropics:mainfrom
gspeter-max:issue_569
Open

feat(types): add mcp_servers field to AgentDefinition#592
gspeter-max wants to merge 1 commit intoanthropics:mainfrom
gspeter-max:issue_569

Conversation

@gspeter-max
Copy link

Summary

Changes

  • src/claude_agent_sdk/types.py: Added mcp_servers: dict[str, "McpServerConfig"] | None = None field
  • tests/test_transport.py: Added test_build_command_agents_with_mcp_servers() test
  • examples/agents.py: Added agent_with_mcp_servers_example() demonstrating PostgreSQL MCP server usage

Test Plan

  • All existing tests pass (157/157)
  • New test for mcp_servers serialization passes
  • Ruff linting and formatting pass
  • MyPy typechecking passes
  • Backward compatibility verified (existing code without mcp_servers still works)
  • Serialization verified (asdict() correctly includes/excludes field)

Related Issues

Fixes #569

ROOT CAUSE:
The Python SDK's AgentDefinition was missing the mcpServers field that is
documented in Claude Code docs and supported by the CLI via .claude/agents/*.md
frontmatter. This prevented subagents from having their own MCP server
configurations.

CHANGES:
- Added mcp_servers: dict[str, "McpServerConfig"] | None field to AgentDefinition
- Added test_build_command_agents_with_mcp_servers test
- Added agent_with_mcp_servers_example() to examples/agents.py

IMPACT:
- Subagents can now have their own MCP server configurations
- Matches CLI behavior and TypeScript SDK capabilities
- Fully backward compatible (optional field, defaults to None)

FILES MODIFIED:
- src/claude_agent_sdk/types.py
- tests/test_transport.py
- examples/agents.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The AgentDefinition is missing the mcpServers attribute.

2 participants