feat: add public get_mcp_status() method to ClaudeSDKClient#516
Merged
ashwin-ant merged 1 commit intomainfrom Jan 26, 2026
Merged
feat: add public get_mcp_status() method to ClaudeSDKClient#516ashwin-ant merged 1 commit intomainfrom
ashwin-ant merged 1 commit intomainfrom
Conversation
Add a public API for querying live MCP server connection status,
following the same pattern as interrupt(), set_permission_mode(),
set_model(), and rewind_files().
This allows callers to check MCP server health without reaching into
private SDK internals (client._query._send_control_request), which
is fragile and breaks on SDK updates.
- Query.get_mcp_status(): sends {"subtype": "mcp_status"} control request
- ClaudeSDKClient.get_mcp_status(): public wrapper with connection check
:house: Remote-Dev: homespace
4fa9e1b to
beaf88d
Compare
ashwin-ant
approved these changes
Jan 26, 2026
phil65
added a commit
to phil65/claude-agent-sdk-python
that referenced
this pull request
Jan 29, 2026
Backport of anthropics#516 Adds get_mcp_status() to query MCP server connection status including: - Server name - Connection status (connected, pending, failed, needs-auth, disabled)
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.
Motivation
The Claude Investigator app, which uses the python claude agent SDK, needs to query MCP server connection status (example here). Currently it does this by reaching into private SDK internals:
This is fragile — any SDK refactor silently breaks the caller, and the
hasattrguard means failures degrade silently to no MCP status reporting.Changes
Add a public
get_mcp_status()method following the exact same pattern asinterrupt(),set_permission_mode(),set_model(), andrewind_files():Query.get_mcp_status()— sends{"subtype": "mcp_status"}control request via_send_control_requestClaudeSDKClient.get_mcp_status()— public wrapper with connection check, docstring with Returns and Example sectionsCallers can now simply do:
Testing
The method delegates entirely to the existing
_send_control_requestinfrastructure which is already tested. The new code is a 3-line wrapper with no branching logic.