Skip to main content

Module task_manager

Module task_manager 

Source
Available on crate feature server only.
Expand description

Server-side runtime for the MCP Tasks extension (SEP-2663, io.modelcontextprotocol/tasks).

TaskManager owns the durable state for tasks a server has materialized in response to task-eligible requests (currently tools/call). It:

  • spawns the underlying operation and tracks its lifecycle as a DetailedTask (working → terminal, optionally via input_required),
  • answers tasks/get with the current state (including in-flight inputRequests and terminal result/error payloads),
  • accepts tasks/update inputResponses and routes them to the running operation (ignoring unknown or already-answered keys per spec),
  • handles cooperative tasks/cancel,
  • enforces TTL-based expiry (ttl_ms), marking overdue tasks failed.

Tasks are only durably observable once TaskManager::spawn returns, satisfying the spec requirement that a server not return CreateTaskResult before tasks/get for that id would resolve.

Structs§

TaskContext
Handle passed to a running task operation, allowing it to surface server-to-client requests (elicitation, sampling, roots) mid-task and await the client’s tasks/update response.
TaskManager
Server-side task store and executor for the SEP-2663 Tasks extension.
TaskOptions
Options controlling a spawned task.

Enums§

TaskExit
How a task operation finished without producing a result.

Constants§

DEFAULT_POLL_INTERVAL_MS
Default suggested polling interval, in milliseconds.
DEFAULT_TASK_TTL_MS
Default TTL (5 minutes, in milliseconds) applied when none is specified.

Functions§

current_timestamp
Helper to generate an ISO 8601 timestamp for task metadata.

Type Aliases§

TaskFuture
Boxed future representing the async operation backing a task.