Repository navigation
Implement SEP-1686: Tasks #421
Description
This is a tracking issue for implementation of SEP-1686.
Summary
This SEP introduces the task primitive and task ID to support workflow-based operations in MCP, enabling call-now, fetch-later execution patterns across all request types. Tasks are durable state machines with five states (working, input_required, completed, failed, cancelled) that allow requestors to augment requests with task metadata for deferred result retrieval via polling. This addresses critical use cases for long-running operations such as data analysis pipelines, enterprise automation, code migrations, test execution, deep research, and multi-agent systems where immediate responses are impractical and result retention is needed for client-driven status checking.
The Kotlin SDK currently has no support for tasks or async execution patterns. This implementation will require extensive changes including: new task primitive types (Task, CreateTaskResult, TaskStatus enum), task-related request/response types for tasks/get, tasks/result, tasks/list, and tasks/cancel operations, capability declarations in ClientCapabilities and ServerCapabilities structured by request category (tools.call, sampling.createMessage, elicitation.create), optional task field in existing request parameters to support task-augmented execution, metadata handling for io.modelcontextprotocol/related-task associations, TTL-based resource management, status polling mechanisms, DSL builders for task operations, and comprehensive test coverage. The implementation must be backward compatible, allowing receivers to ignore task metadata if not supported, and providing flexibility for receivers to support both traditional immediate execution and task-augmented patterns.
- Add types:
TaskTaskStatusTaskMetadataRelatedTaskMetadataCreateTaskResultListTasksRequestListTasksResultGetTaskRequestGetTaskResultGetTaskPayloadRequestGetTaskPayloadResultCancelTaskRequestCancelTaskResultTaskStatusNotificationTaskStatusNotificationParams
- Add methods to
Method.Defined. - Update serializers and DSL builders.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
He-Pin commentedon Nov 21, 2025
Yes, the changeset is quite large, in modelcontextprotocol/java-sdk#671 ,
I just done the schema part, and Kotlin does not support
union typetoo, not sure how it to express theCallToolResult | CreateTaskResultLucaButBoring commentedon Nov 21, 2025
Relaying here from
#general-sdk-dev:LucaButBoring commentedon Nov 24, 2025
One very last change (we're doing a hard cutoff on additional changes here): adding a
lastUpdatedAtto theTaskobject: modelcontextprotocol/modelcontextprotocol#1875devcrocod commentedon Nov 25, 2025
@He-Pin
Сan address this by introducing a common supertype that encapsulates both variants. Then we can handle their serialization and deserialization manually. We’ve used the same approach for the other union types as well
He-Pin commentedon Nov 25, 2025
another way is using
CallToolAuxResult, which contains thetask, I checked the current java-sdk'sJSONRpcResponsewhich containsJSONRPCError, so I think put thetaskinsideCallToolResultshould be fine too.What's the shared interface name,
CallToolStreamingMessage?feat: add tasks models (#566)
kpavlov commentedon Apr 2, 2026
See also #567
feat: SEP-1686 Tasks (#844)