feat(mcpserver): expose public get_tool(name) on MCPServer - #3233
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
|
This PR has been closed automatically. It's still a draft, but we close those early so you don't put in more time only to have it closed the moment you mark it ready. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and this PR doesn't link an open issue yet.
You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way. CONTRIBUTING.md has the full reasoning, but in short:
Maintainers: reopen, remove |
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.