feat(mcpserver): expose public get_tool(name) on MCPServer - #3232
Closed
arimu1 wants to merge 1 commit into
Closed
Conversation
Add MCPServer.get_tool to retrieve a registered tool by name without using the private _tool_manager, completing the add/remove CRUD surface. Fixes modelcontextprotocol#3162
Author
|
Recreating as non-draft (API could not convert draft→ready under current token permissions). |
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
Adds a public
MCPServer.get_tool(name) -> Tool | Nonethat delegates to the existingToolManager.get_tool, so callers can look up a registered tool without using the private_tool_manager.This completes the public tool registration surface next to
add_tool()/remove_tool().Use case (from #3162): after registration, update a tool's
inputSchema(e.g. attachoneOf/ discriminated action schemas) via the returned tool's mutableparametersdict.Fixes #3162
Notes on issue discussion
Maintainer asked whether customizing
inputSchemaat registration time would be enough. This PR still implements the issue's proposed API (get_tool) because:add/get/remove)input_schema=override onadd_tool/@toolremains a possible follow-up and is orthogonalTest plan
test_get_tool_returns_registered_tool_or_nonetest_get_tool_exposes_mutable_parameters_for_schema_updatesTestServerToolsadd/remove tests still passruff+pyrightclean on touched filesAI disclosure
Assisted by AI (Grok / Cursor) for implementation and tests; human-reviewed before submit.