modelcontextprotocol / modelcontextprotocol/python-sdk
Client-side support for the tasks extension (io.modelcontextprotocol/tasks, SEP-2663)
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 24.3k
- Forks
- 4k
- Merge moyen
- 1 j 1 h
- PR mergées (30 j)
- 31
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par l’API existante ClientExtension.claims() et la documentation de Request.name_param, puis examinez l’emplacement proposé mcp/client/extensions/tasks.py et les tests associés. Implémentez la prise en charge côté client des résultats de tâches de tools/call, de l’interrogation périodique de tasks/get avec annulation via tasks/cancel, ainsi que des en-têtes de routage des tâches ; vérifiez le comportement par rapport aux états de tâche décrits et à un serveur conforme à la spécification.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- api, backend-api-design
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 52/100