modelcontextprotocol / modelcontextprotocol/python-sdk
Client-side support for the tasks extension (io.modelcontextprotocol/tasks, SEP-2663)
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 24.3k
- 派生
- 4k
- 平均合并
- 1 天 1 小时
- 30 天内合并 PR
- 31
描述
v2 removed the experimental tasks API in favor of the SEP-2663 extension (io.modelcontextprotocol/tasks), but the SDK currently ships no client-side way to consume task-augmented servers: a tools/call that returns resultType: "task" fails result validation unless every consumer hand-writes a ResultClaim.
The extension surface (ClientExtension.claims()) supports this cleanly. I have a working implementation (~120 lines + tests, exercised against a spec-conformant 2026-07-28 server with server-directed task creation) that:
- advertises
io.modelcontextprotocol/tasksin per-request capabilities, - claims
resultType: "task"ontools/call, - resolves the claim by polling
tasks/get(honoringpollIntervalMs, including mid-task changes), - maps
failed→ a raised error carrying the server's JSON-RPC error, andcancelled→ a distinct error, - sends best-effort
tasks/cancelwhen the caller's scope is cancelled (shielded), per the spec's cooperative-cancellation model, - sets
Mcp-Nameto the taskId ontasks/*requests vianame_param(the SEP-2663 routing-header requirement — theRequest.name_paramdocstring in mcp-types already anticipates this).
Happy to send a PR — proposed location mcp/client/extensions/tasks.py. Two design questions I'd like a maintainer opinion on before polishing:
- Should
input_requiredtasks surface through the existing elicitation callback plumbing (withtasks/updateas the response channel), or is that a follow-up? - Is transparent-polling-inside-
call_toolthe right default, or should the extension also expose the raw task handle for callers that want to manage polling themselves (e.g. UI progress)?
One porting note: the natural base for the wire models is MCPModel (camelCase alias generator), which mcp_types doesn't currently re-export — part of the value of upstreaming is resolving that properly.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从现有的 ClientExtension.claims() API 和 Request.name_param 文档开始,然后检查建议的 mcp/client/extensions/tasks.py 位置及相关测试。实现客户端对 tools/call 返回的任务结果、通过 tasks/cancel 取消的 tasks/get 轮询以及任务路由标头的支持;根据所描述的任务状态和符合规范的服务器确认行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- api, backend-api-design
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 52/100