Skip to content

fix: send sdkMcpServers field in initialize control request#637

Open
drillan wants to merge 1 commit intoanthropics:mainfrom
drillan:fix/initialize-sdk-mcp-servers
Open

fix: send sdkMcpServers field in initialize control request#637
drillan wants to merge 1 commit intoanthropics:mainfrom
drillan:fix/initialize-sdk-mcp-servers

Conversation

@drillan
Copy link

@drillan drillan commented Mar 5, 2026

Summary

The Python SDK's Query.initialize() does not include the sdkMcpServers field in the initialize control request. This causes the Claude Code CLI to never register SDK MCP servers, making their tools invisible to the model.

The TypeScript SDK correctly sends this field. This fix aligns the Python SDK with the TypeScript SDK behavior.

Supersedes #596 (which also included end_input fixes now covered by #630).

Relates to #597.

Changes

  • query.py: Add sdkMcpServers field to initialize control request when SDK MCP servers are configured
  • test_initialize_sdk_mcp_servers.py: 5 test cases covering all scenarios (present, empty, None, non-streaming, combined with agents)

Test plan

  • New tests pass (pytest tests/test_initialize_sdk_mcp_servers.py)
  • Full test suite passes (257 tests)
  • Lint clean (ruff check + ruff format)
  • Type check clean (mypy)

The Python SDK's Query.initialize() was not including the sdkMcpServers
field in the initialize control request. This caused the Claude Code CLI
to never register SDK MCP servers, making their tools invisible to the
model.

The TypeScript SDK (v0.2.49) correctly sends this field. This fix aligns
the Python SDK with the TypeScript SDK behavior, following the same
pattern as PR anthropics#468 which added the agents field to initialize.

Co-Authored-By: Claude Opus 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.

1 participant