modelcontextprotocol / modelcontextprotocol/python-sdk

feat: enhance dynamic tool management with notifications and enable/disable

未关闭
#1,429 4 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement needs decision P1 v2
主要语言
Python
星标
24.3k
派生
4k
平均合并
1 天 1 小时
30 天内合并 PR
31

描述

Summary

Enhance the Python SDK's dynamic tool management capabilities to match the TypeScript SDK by adding:

  1. Automatic tools/list_changed notifications when tools are added/removed
  2. 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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

先从 Python SDK 中 add_tool()、remove_tool()、list_tools() 和工具调用的入口开始,然后将其行为与所引用的 TypeScript SDK dynamic-server 实现进行比较。完成的标准是:添加和移除工具会触发 tools/list_changed 通知,同时禁用的工具会被隐藏并阻止调用,可以重新启用,并且仍然可以移除。

由索引模型根据 Issue 内容生成。

评估

技术栈
python, typescript
领域
api, backend
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。