modelcontextprotocol / modelcontextprotocol/python-sdk

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

オープン
#3,226 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

P2 spec-2026-07-28 v2
主要言語
Python
スター
24.3k
フォーク
4k
平均マージ
1日 1時間
マージ済み PR(30日)
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. リポジトリをフォークし、ブランチを切って変更します。
  4. 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 を短くまとめたダイジェスト。