Skip to content

Commit 14c8fb3

Browse files
committed
Align types.py with official MCP schema for tasks
- Remove taskId from CancelledNotificationParams (removed in spec PR #1833) - Update requestId docstring with MUST/MUST NOT requirements from spec - Add missing docstrings for TaskMetadata, RelatedTaskMetadata.taskId, and Task.pollInterval to match schema.ts
1 parent 973641c commit 14c8fb3

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/mcp/types.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,15 @@
4747

4848

4949
class TaskMetadata(BaseModel):
50+
"""
51+
Metadata for augmenting a request with task execution.
52+
Include this in the `task` field of the request parameters.
53+
"""
54+
5055
model_config = ConfigDict(extra="allow")
5156

5257
ttl: Annotated[int, Field(strict=True)] | None = None
58+
"""Requested duration in milliseconds to retain task from creation."""
5359

5460

5561
class RequestParams(BaseModel):
@@ -536,6 +542,7 @@ class RelatedTaskMetadata(BaseModel):
536542

537543
model_config = ConfigDict(extra="allow")
538544
taskId: str
545+
"""The task identifier this message is associated with."""
539546

540547

541548
class Task(BaseModel):
@@ -568,6 +575,7 @@ class Task(BaseModel):
568575
"""Actual retention duration from creation in milliseconds, null for unlimited."""
569576

570577
pollInterval: Annotated[int, Field(strict=True)] | None = None
578+
"""Suggested polling interval in milliseconds."""
571579

572580

573581
class CreateTaskResult(Result):
@@ -1709,13 +1717,16 @@ class CancelledNotificationParams(NotificationParams):
17091717
"""Parameters for cancellation notifications."""
17101718

17111719
requestId: RequestId | None = None
1712-
"""The ID of the request to cancel."""
1720+
"""
1721+
The ID of the request to cancel.
1722+
1723+
This MUST correspond to the ID of a request previously issued in the same direction.
1724+
This MUST be provided for cancelling non-task requests.
1725+
This MUST NOT be used for cancelling tasks (use the `tasks/cancel` request instead).
1726+
"""
17131727
reason: str | None = None
17141728
"""An optional string describing the reason for the cancellation."""
17151729

1716-
taskId: str | None = None
1717-
"""Deprecated: Use the `tasks/cancel` request instead of this notification for task cancellation."""
1718-
17191730
model_config = ConfigDict(extra="allow")
17201731

17211732

0 commit comments

Comments
 (0)