Skip to content

Commit c4ff02d

Browse files
committed
SEP-2663: Send task status notifications on subscriptions/listen
1 parent ebe238a commit c4ff02d

2 files changed

Lines changed: 108 additions & 4 deletions

File tree

docs/seps/2663-tasks-extension.mdx

Lines changed: 54 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

seps/2663-tasks-extension.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,60 @@ export interface TaskStatusNotification extends JSONRPCNotification {
507507
}
508508
```
509509

510+
To begin listening for task status notifications, clients send a `subscriptions/listen` request to the server including a list of task IDs the client is interested in (see [SEP-2575](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2575)):
511+
512+
```typescript
513+
export interface SubscriptionsListenRequest extends Request {
514+
method: "subscriptions/listen";
515+
params: {
516+
// Other existing fields...
517+
notifications: {
518+
tasksStatus?: string[];
519+
// Other existing fields...
520+
};
521+
};
522+
}
523+
```
524+
525+
In its acknowledgement notification, the server includes the list of task IDs it has agreed to send task status notifications for, if any:
526+
527+
```typescript
528+
export interface SubscriptionsAcknowledgedNotification extends Notification {
529+
method: "notifications/subscriptions/acknowledged";
530+
params: {
531+
notifications: {
532+
/**
533+
* Subscribe to notifications/tasks/status for specific task IDs.
534+
*/
535+
tasksStatus?: string[];
536+
// Other existing fields...
537+
};
538+
};
539+
}
540+
```
541+
542+
If a client requests task status notifications but does not declare the `io.modelcontextprotocol/tasks` extension capability, the server **MUST** return a JSON-RPC error specifying the missing capabilities:
543+
544+
```jsonl
545+
{
546+
"jsonrpc": "2.0",
547+
"id": 12,
548+
"error": {
549+
// MISSING_REQUIRED_CLIENT_CAPABILITY
550+
"code": -32003,
551+
// Message provided for example purposes only. The content of this example message is non-normative.
552+
"message": "Missing required client capability",
553+
"data": {
554+
"requiredCapabilities": {
555+
"extensions": {
556+
"io.modelcontextprotocol/tasks": {}
557+
}
558+
}
559+
}
560+
}
561+
}
562+
```
563+
510564
Each notification carries a complete `DetailedTask` for the current status, identical to what `tasks/get` would have returned at that moment.
511565

512566
**Notification:**
@@ -539,8 +593,6 @@ The notification includes the full task object, allowing clients to access the c
539593

540594
Clients **MUST NOT** rely on receiving this notification, and **SHOULD** continue to poll via `tasks/get` to ensure they receive status updates.
541595

542-
In the Streamable HTTP transport, if a server sends this notification, it **MUST** send it on an SSE stream associated with a `tasks/get` request.
543-
544596
### Streamable HTTP: Routing Headers
545597

546598
When `tasks/get`, `tasks/update`, or `tasks/cancel` is sent over the Streamable HTTP transport, the client **MUST** set the `Mcp-Name` header (defined by [SEP-2243](./2243-http-standardization.md)) to the value of `params.taskId`. This allows transport intermediaries and load balancers to route subsequent requests for the same task to the server instance holding its state, which is typically required for correctness. The `Mcp-Method` header is set to the JSON-RPC method name per [SEP-2243](./2243-http-standardization.md).

0 commit comments

Comments
 (0)