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 摘要。