You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/specification/draft/basic/utilities/tasks.mdx
+37-30Lines changed: 37 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,7 +90,7 @@ Task-augmented requests follow a two-phase response pattern that differs from no
90
90
-**Normal requests**: The server processes the request and returns the actual operation result directly.
91
91
-**Task-augmented requests**: The server accepts the request and immediately returns a `CreateTaskResult` containing task metadata. The actual operation result becomes available later through `tasks/result` after the task completes.
92
92
93
-
To create a task, requestors send a request with the `modelcontextprotocol.io/task` key included in `_meta`. Requestors **MAY** include a `keepAlive` value representing how long after completion the requestor would like the task results to be kept for.
93
+
To create a task, requestors send a request with the `modelcontextprotocol.io/task` key included in `_meta`. Requestors **MAY** include a `ttl` value representing how long from task creation the requestor would like the task to be retained for.
94
94
95
95
**Request:**
96
96
@@ -106,7 +106,7 @@ To create a task, requestors send a request with the `modelcontextprotocol.io/ta
106
106
},
107
107
"_meta": {
108
108
"modelcontextprotocol.io/task": {
109
-
"keepAlive": 60000
109
+
"ttl": 60000
110
110
}
111
111
}
112
112
}
@@ -123,7 +123,8 @@ To create a task, requestors send a request with the `modelcontextprotocol.io/ta
123
123
"taskId": "786512e2-9e0d-44bd-8f29-789f320fe840",
124
124
"status": "working",
125
125
"statusMessage": "The operation is now in progress.",
126
-
"keepAlive": 60000,
126
+
"createdAt": "2025-11-25T10:30:00Z",
127
+
"ttl": 60000,
127
128
"pollInterval": 5000,
128
129
"_meta": {
129
130
"modelcontextprotocol.io/related-task": {
@@ -161,10 +162,11 @@ To retrieve the state of a task, requestors send a `tasks/get` request:
161
162
"id": 3,
162
163
"result": {
163
164
"taskId": "786512e2-9e0d-44bd-8f29-789f320fe840",
164
-
"keepAlive": 30000,
165
-
"pollInterval": 5000,
166
165
"status": "working",
167
166
"statusMessage": "The operation is now in progress.",
167
+
"createdAt": "2025-11-25T10:30:00Z",
168
+
"ttl": 30000,
169
+
"pollInterval": 5000,
168
170
"_meta": {
169
171
"modelcontextprotocol.io/related-task": {
170
172
"taskId": "786512e2-9e0d-44bd-8f29-789f320fe840"
@@ -300,13 +302,15 @@ To retrieve a list of tasks, requestors send a `tasks/list` request. This operat
300
302
{
301
303
"taskId": "786512e2-9e0d-44bd-8f29-789f320fe840",
302
304
"status": "working",
303
-
"keepAlive": 30000,
305
+
"createdAt": "2025-11-25T10:30:00Z",
306
+
"ttl": 30000,
304
307
"pollInterval": 5000
305
308
},
306
309
{
307
310
"taskId": "abc123-def456-ghi789",
308
311
"status": "completed",
309
-
"keepAlive": 60000
312
+
"createdAt": "2025-11-25T09:15:00Z",
313
+
"ttl": 60000
310
314
}
311
315
],
312
316
"nextCursor": "next-page-cursor"
@@ -434,11 +438,12 @@ stateDiagram-v2
434
438
1. When the requestor encounters the `input_required` status, it **SHOULD** call `tasks/result` prematurely.
435
439
1. When the receiver receives all required input, the task **SHOULD** transition out of `input_required` status (typically back to `working`).
436
440
437
-
### Keep-Alive and Resource Management
441
+
### TTL and Resource Management
438
442
439
-
1. Receivers **MAY** override the requested `keepAlive` duration.
440
-
1. Receivers **MUST** include the actual `keepAlive` duration (or `null` for unlimited) in `tasks/get` responses.
441
-
1. After a task reaches a terminal status (`completed`, `failed`, or `cancelled`) and its `keepAlive` duration has elapsed, receivers **MAY** delete the task and its results.
443
+
1. Receivers **MUST** include a `createdAt` timestamp (ISO 8601 format) in all task responses to indicate when the task was created.
444
+
1. Receivers **MAY** override the requested `ttl` duration.
445
+
1. Receivers **MUST** include the actual `ttl` duration (or `null` for unlimited) in `tasks/get` responses.
446
+
1. After a task's `ttl` duration has elapsed from creation, receivers **MAY** delete the task and its results, regardless of the task's status.
442
447
1. Receivers **MAY** include a `pollInterval` value (in milliseconds) in `tasks/get` responses to suggest polling intervals. Requestors **SHOULD** respect this value when provided.
443
448
444
449
### Result Retrieval
@@ -471,8 +476,8 @@ Task-augmented requests support progress notifications as defined in the progres
471
476
1. Upon receiving a valid cancellation request, receivers **SHOULD** attempt to stop the task's execution (best effort) and **MUST** transition the task to `cancelled` status before sending the response.
472
477
1. Once a task is cancelled, it **MUST** remain in `cancelled` status even if execution continues to completion or fails.
473
478
1. If the `delete` parameter is `true`, receivers **SHOULD** delete the task and all associated results and metadata after transitioning to `cancelled` status. Receivers **MAY** choose not to support deletion and ignore this parameter.
474
-
1. If the `delete` parameter is `false` or omitted, receivers **MUST** retain the task in `cancelled` status subject to the `keepAlive` duration.
475
-
1. Requestors **SHOULD** use the `delete` parameter to clean up tasks containing sensitive data promptly rather than relying solely on `keepAlive` expiration.
479
+
1. If the `delete` parameter is `false` or omitted, receivers **MUST** retain the task in `cancelled` status subject to the `ttl` duration.
480
+
1. Requestors **SHOULD** use the `delete` parameter to clean up tasks containing sensitive data promptly rather than relying solely on `ttl` expiration.
476
481
477
482
## Message Flow
478
483
@@ -483,8 +488,8 @@ sequenceDiagram
483
488
participant C as Client (Requestor)
484
489
participant S as Server (Receiver)
485
490
Note over C,S: 1. Task Creation
486
-
C->>S: Request with task metadata (taskId, keepAlive)
Note over C: Results retained for keepAlive period
612
+
Note over C: Results retained for ttl period from creation
608
613
```
609
614
610
615
### Task Cancellation Flow
@@ -634,7 +639,7 @@ sequenceDiagram
634
639
635
640
Note over C: Client receives confirmation
636
641
637
-
Note over S: After keepAlive period, task cleaned up
642
+
Note over S: After ttl period from creation, task cleaned up
638
643
```
639
644
640
645
### Task Cancellation with Deletion Flow
@@ -677,9 +682,10 @@ sequenceDiagram
677
682
A task represents the execution state of a request. The task metadata includes:
678
683
679
684
-`taskId`: Unique identifier for the task
680
-
-`keepAlive`: Time in milliseconds that results will be kept available after completion
681
-
-`pollInterval`: Suggested time in milliseconds between status checks
682
685
-`status`: Current state of the task execution
686
+
-`createdAt`: ISO 8601 timestamp when the task was created
687
+
-`ttl`: Time in milliseconds from creation before task may be deleted
688
+
-`pollInterval`: Suggested time in milliseconds between status checks
683
689
684
690
### Task Status
685
691
@@ -698,14 +704,14 @@ When augmenting a request with task execution, the `modelcontextprotocol.io/task
698
704
```json
699
705
{
700
706
"modelcontextprotocol.io/task": {
701
-
"keepAlive": 60000
707
+
"ttl": 60000
702
708
}
703
709
}
704
710
```
705
711
706
712
Fields:
707
713
708
-
-`keepAlive` (number, optional): Requested duration in milliseconds to retain results after completion
714
+
-`ttl` (number, optional): Requested duration in milliseconds to retain task from creation
709
715
710
716
### Related Task Metadata
711
717
@@ -812,9 +818,10 @@ When the underlying request does not complete successfully, the task moves to th
812
818
"jsonrpc": "2.0",
813
819
"id": 4,
814
820
"result": {
815
-
"taskId": "786512e2-9e0d-44bd-8f29-789f320fe840",
821
+
"taskId": "786512e2-9e0d-44bd-8f29-789f820fe840",
816
822
"status": "failed",
817
-
"keepAlive": 30000,
823
+
"createdAt": "2025-11-25T10:30:00Z",
824
+
"ttl": 30000,
818
825
"error": "Tool execution failed: API rate limit exceeded"
819
826
}
820
827
}
@@ -847,16 +854,16 @@ The `tasks/result` endpoint returns exactly what the underlying request would ha
847
854
848
855
<Warning>
849
856
850
-
Task results may persist longer than the original request execution time. For sensitive operations, requestors should carefully consider the security implications of extended result retention and may want to retrieve results promptly and request shorter `keepAlive` durations. Requestors are encouraged to use `tasks/cancel` with the `delete` parameter set to `true` to explicitly clean up tasks containing sensitive data rather than relying solely on `keepAlive` expiration.
857
+
Task results may persist for the duration specified by the TTL. For sensitive operations, requestors should carefully consider the security implications of extended task retention and may want to retrieve results promptly and request shorter `ttl` durations. Requestors are encouraged to use `tasks/cancel` with the `delete` parameter set to `true` to explicitly clean up tasks containing sensitive data rather than relying solely on `ttl` expiration.
851
858
852
859
</Warning>
853
860
854
861
1. Receivers **SHOULD**:
855
862
1. Enforce limits on concurrent tasks per requestor
856
-
1. Enforce maximum `keepAlive` durations to prevent indefinite resource retention
863
+
1. Enforce maximum `ttl` durations to prevent indefinite resource retention
857
864
1. Clean up expired tasks promptly to free resources
858
865
1. Receivers **SHOULD**:
859
-
1. Document maximum supported `keepAlive` duration
866
+
1. Document maximum supported `ttl` duration
860
867
1. Document maximum concurrent tasks per requestor
861
868
1. Implement monitoring and alerting for resource usage
0 commit comments