modelcontextprotocol / modelcontextprotocol/python-sdk
feat: enhance dynamic tool management with notifications and enable/disable
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 24.3k
- Forks
- 4k
- Ø Merge
- 1 T. 1 Std.
- Gemergte PRs (30 T.)
- 31
Beschreibung
Summary
Enhance the Python SDK's dynamic tool management capabilities to match the TypeScript SDK by adding:
- Automatic
tools/list_changednotifications 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: #1322 (adds
remove_toolmethod) - TypeScript SDK Dynamic Servers: https://github.com/modelcontextprotocol/typescript-sdk#dynamic-servers
- MCP spec supports
notifications/tools/list_changed
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit den Python-SDK-Einstiegspunkten für add_tool(), remove_tool(), list_tools() und die Tool-Aufrufe und vergleiche anschließend ihr Verhalten mit der referenzierten TypeScript SDK-Implementierung von dynamic-server. Als abgeschlossen gilt die Aufgabe, wenn hinzugefügte und entfernte Tools tools/list_changed-Benachrichtigungen auslösen, während deaktivierte Tools verborgen und blockiert werden, wieder aktiviert werden können und weiterhin entfernbar bleiben.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python, typescript
- Bereich
- api, backend
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100