modelcontextprotocol / modelcontextprotocol/python-sdk

Client-side support for the tasks extension (io.modelcontextprotocol/tasks, SEP-2663)

未关闭
#3,226 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

P2 spec-2026-07-28 v2
主要语言
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/tasks in per-request capabilities,
  • claims resultType: "task" on tools/call,
  • resolves the claim by polling tasks/get (honoring pollIntervalMs, including mid-task changes),
  • maps failed → a raised error carrying the server's JSON-RPC error, and cancelled → a distinct error,
  • sends best-effort tasks/cancel when the caller's scope is cancelled (shielded), per the spec's cooperative-cancellation model,
  • sets Mcp-Name to the taskId on tasks/* requests via name_param (the SEP-2663 routing-header requirement — the Request.name_param docstring 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:

  1. Should input_required tasks surface through the existing elicitation callback plumbing (with tasks/update as the response channel), or is that a follow-up?
  2. Is transparent-polling-inside-call_tool the 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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 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

把新 issue 发到你的邮箱

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