-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Labels
P2Moderate issues affecting some users, edge cases, potentially valuable featureModerate issues affecting some users, edge cases, potentially valuable featurefeature requestRequest for a new feature that's not currently supportedRequest for a new feature that's not currently supportedready for workEnough information for someone to start working onEnough information for someone to start working onv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixesIdeas, requests and plans for v2 of the SDK which will incorporate major changes and fixes
Description
Summary
Enhance the Python SDK's dynamic tool management capabilities to match the TypeScript SDK by adding:
- Automatic
tools/list_changed
notifications when tools are added/removed - Tool enable/disable functionality (temporary hiding without removal)
Background
The Python SDK currently supports adding and removing tools dynamically (see #1322), but lacks two key features present in the TypeScript SDK:
1. List Changed Notifications
The TypeScript SDK automatically sends notifications/tools/list_changed
when tools are modified. This allows clients to know when they should refresh their tool list.
Python SDK gap: Currently, when calling add_tool()
or remove_tool()
, clients are not notified of the change and may show stale tool lists.
2. Enable/Disable Tools
The TypeScript SDK provides enable()
and disable()
methods on tools:
const tool = server.tool("myTool", ..., async () => { ... });
tool.disable() // Hides from list_tools, blocks calls
tool.enable() // Re-enables the tool
tool.remove() // Permanently removes
Benefits:
- Temporarily hide tools without losing registration
- Re-enable tools without re-registering
- Useful for permission-based or state-based tool visibility
Python SDK gap: Only permanent removal via remove_tool()
is supported. No way to temporarily disable/re-enable tools.
References
- Related PR: feat: add ability to remove tools #1322 (adds
remove_tool
method) - TypeScript SDK Dynamic Servers: https://github.com/modelcontextprotocol/typescript-sdk#dynamic-servers
- MCP spec supports
notifications/tools/list_changed
felixweinberger
Metadata
Metadata
Assignees
Labels
P2Moderate issues affecting some users, edge cases, potentially valuable featureModerate issues affecting some users, edge cases, potentially valuable featurefeature requestRequest for a new feature that's not currently supportedRequest for a new feature that's not currently supportedready for workEnough information for someone to start working onEnough information for someone to start working onv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixesIdeas, requests and plans for v2 of the SDK which will incorporate major changes and fixes