Something went wrong. Try again.
mirror of github.com/PrefectHQ/fastmcp
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839---title: subscriptionssidebarTitle: subscriptions---
# `fastmcp.server.tasks.subscriptions`
Task subscription helpers for sending MCP notifications (SEP-1686).
Subscribes to Docket execution state changes and sends notifications/tasks/statusto clients when their tasks change state.
This module requires fastmcp[tasks] (pydocket). It is only imported when docket is available.
## Functions
### `subscribe_to_task_updates` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/server/tasks/subscriptions.py#L31" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonsubscribe_to_task_updates(task_id: str, task_key: str, session: ServerSession, docket: Docket, poll_interval_ms: int = 5000) -> None```
Subscribe to Docket execution events and send MCP notifications.
Per SEP-1686 lines 436-444, servers MAY send notifications/tasks/statuswhen task state changes. This is an optional optimization that reducesclient polling frequency.
**Args:**- `task_id`: Client-visible task ID (server-generated UUID)- `task_key`: Internal Docket execution key (includes session, type, component)- `session`: MCP ServerSession for sending notifications- `docket`: Docket instance for subscribing to execution events- `poll_interval_ms`: Poll interval in milliseconds to include in notifications