Anubis. Server. Task
(anubis_mcp v1.6.1)
Copy Markdown
Represents an MCP task — a durable state machine wrapping a long-running request.
Spec reference: https://modelcontextprotocol.io/specification/2025-11-25/basic/utilities/tasks.
Tasks are receiver-owned: when a server accepts a task-augmented request (e.g.
tools/call with a task field), it generates a task id, runs the work
asynchronously, and exposes the lifecycle through the tasks/get,
tasks/result, and tasks/cancel operations.
Summary
Functions
Generates a cryptographically-strong task id.
Builds a fresh task in :working status.
Returns true when the task is in a terminal status.
Wraps the task projection inside the CreateTaskResult envelope returned to
the requestor at task creation time.
Builds the wire-format Task projection used by tasks/* responses and the
notifications/tasks/status notification. Excludes the underlying result.
Transitions the task into a new status. The caller is responsible for
enforcing the FSM (working ↔ input_required → terminal).
Types
@type status() :: :working | :input_required | :completed | :failed | :cancelled
@type t() :: %Anubis.Server.Task{ created_at: DateTime.t(), error: Anubis.MCP.Error.t() | nil, id: String.t(), last_updated_at: DateTime.t(), method: String.t(), original_params: map() | nil, poll_interval: pos_integer() | nil, request_id: String.t() | integer(), result: term() | nil, session_id: String.t(), status: status(), status_message: String.t() | nil, ttl: pos_integer() | nil }
Functions
@spec generate_id() :: String.t()
Generates a cryptographically-strong task id.
Per spec: receivers MUST use enough entropy to prevent guessing when no authorization context is bound to the task.
Builds a fresh task in :working status.
Returns true when the task is in a terminal status.
Wraps the task projection inside the CreateTaskResult envelope returned to
the requestor at task creation time.
Builds the wire-format Task projection used by tasks/* responses and the
notifications/tasks/status notification. Excludes the underlying result.
Transitions the task into a new status. The caller is responsible for
enforcing the FSM (working ↔ input_required → terminal).