modelcontextprotocol / modelcontextprotocol/python-sdk
feat: enhance dynamic tool management with notifications and enable/disable
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 24.3k
- Forks
- 4k
- Merge médio
- 1d 1h
- PRs com merge (30d)
- 31
Descrição
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
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece pelos pontos de entrada do Python SDK para add_tool(), remove_tool(), list_tools() e a invocação de ferramentas; em seguida, compare o comportamento deles com a implementação dynamic-server do TypeScript SDK referenciada. Considera-se concluído quando as ferramentas adicionadas e removidas acionarem notificações tools/list_changed, enquanto as ferramentas desabilitadas permanecerem ocultas e bloqueadas, puderem ser reabilitadas e continuarem removíveis.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python, typescript
- Domínio
- api, backend
- Tipo de issue
- Funcionalidade
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 38/100