fix: send sdkMcpServers field in initialize control request#637
Open
drillan wants to merge 1 commit intoanthropics:mainfrom
Open
fix: send sdkMcpServers field in initialize control request#637drillan wants to merge 1 commit intoanthropics:mainfrom
drillan wants to merge 1 commit intoanthropics:mainfrom
Conversation
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>
This was referenced Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Python SDK's
Query.initialize()does not include thesdkMcpServersfield 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: AddsdkMcpServersfield to initialize control request when SDK MCP servers are configuredtest_initialize_sdk_mcp_servers.py: 5 test cases covering all scenarios (present, empty, None, non-streaming, combined with agents)Test plan
pytest tests/test_initialize_sdk_mcp_servers.py)