modelcontextprotocol / modelcontextprotocol/python-sdk
feat: enhance dynamic tool management with notifications and enable/disable
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 24.3k
- Fork
- 4k
- Merge medio
- 1g 1h
- PR unite (30g)
- 31
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dai punti di ingresso del Python SDK per add_tool(), remove_tool(), list_tools() e l’invocazione degli strumenti, quindi confronta il loro comportamento con l’implementazione dynamic-server del TypeScript SDK a cui si fa riferimento. Il lavoro è completato quando gli strumenti aggiunti e rimossi attivano notifiche tools/list_changed, mentre gli strumenti disabilitati sono nascosti e bloccati, possono essere riabilitati e restano rimovibili.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python, typescript
- Ambito
- api, backend
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100