Durable lifecycle helpers for the MCP Tasks extension.
create/3 inserts a task into the configured store before returning its
CreateTaskResult. Server callbacks can use get/2, update/3, and
cancel/2 for the modern task methods, while workers use the transition and
input-response helpers.
The current request principal, tenant, and endpoint are included in the
store owner automatically. A worker outside a server callback should retain
owner/1 from the creating request and pass it back with owner: owner.
Successful creates and wire-visible transitions asynchronously publish the
full modern state to authorized subscriptions/listen task filters. Pass a
non-default registry as subscription_registry: registry; use
notify: false only when the host owns publication.
Summary
Functions
Records a cooperative cancellation request and acknowledges it.
Returns whether cooperative cancellation was requested.
Atomically completes a working task.
Synchronously creates and stores a task before returning its wire handle.
Atomically fails a working task with a JSON-RPC error object.
Returns the authorized full wire state for one task.
Atomically marks a cooperatively stopped task as cancelled.
Builds the non-secret authorization owner for the current request.
Atomically changes a non-terminal task's status message.
Atomically moves a working task to input-required.
Atomically drains input responses accepted for a task worker.
Idempotently submits responses for currently outstanding task inputs.
Types
@type task_error() :: {:error, ExMCP.Tasks.Store.store_error() | :task_store_unavailable}
Functions
@spec cancel( String.t(), keyword() ) :: :ok | task_error()
Records a cooperative cancellation request and acknowledges it.
@spec cancellation_requested?( String.t(), keyword() ) :: {:ok, boolean()} | task_error()
Returns whether cooperative cancellation was requested.
@spec complete(String.t(), map(), keyword()) :: {:ok, ExMCP.Tasks.Task.t()} | task_error()
Atomically completes a working task.
@spec create(String.t(), map(), keyword()) :: {:ok, map()} | task_error()
Synchronously creates and stores a task before returning its wire handle.
@spec fail(String.t(), map(), keyword()) :: {:ok, ExMCP.Tasks.Task.t()} | task_error()
Atomically fails a working task with a JSON-RPC error object.
@spec get( String.t(), keyword() ) :: {:ok, map()} | task_error()
Returns the authorized full wire state for one task.
@spec mark_cancelled( String.t(), keyword() ) :: {:ok, ExMCP.Tasks.Task.t()} | task_error()
Atomically marks a cooperatively stopped task as cancelled.
@spec owner(keyword()) :: ExMCP.Tasks.Store.owner()
Builds the non-secret authorization owner for the current request.
@spec put_status_message(String.t(), String.t() | nil, keyword()) :: {:ok, ExMCP.Tasks.Task.t()} | task_error()
Atomically changes a non-terminal task's status message.
@spec require_input(String.t(), map(), keyword()) :: {:ok, ExMCP.Tasks.Task.t()} | task_error()
Atomically moves a working task to input-required.
@spec take_input_responses( String.t(), keyword() ) :: {:ok, map()} | task_error()
Atomically drains input responses accepted for a task worker.
@spec update(String.t(), map(), keyword()) :: :ok | task_error()
Idempotently submits responses for currently outstanding task inputs.