# `ExMCP.Tasks`
[🔗](https://github.com/azmaveth/ex_mcp/blob/v1.0.0/lib/ex_mcp/tasks.ex#L1)

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.

# `task_error`

```elixir
@type task_error() ::
  {:error, ExMCP.Tasks.Store.store_error() | :task_store_unavailable}
```

# `cancel`

```elixir
@spec cancel(
  String.t(),
  keyword()
) :: :ok | task_error()
```

Records a cooperative cancellation request and acknowledges it.

# `cancellation_requested?`

```elixir
@spec cancellation_requested?(
  String.t(),
  keyword()
) :: {:ok, boolean()} | task_error()
```

Returns whether cooperative cancellation was requested.

# `complete`

```elixir
@spec complete(String.t(), map(), keyword()) ::
  {:ok, ExMCP.Tasks.Task.t()} | task_error()
```

Atomically completes a working task.

# `create`

```elixir
@spec create(String.t(), map(), keyword()) :: {:ok, map()} | task_error()
```

Synchronously creates and stores a task before returning its wire handle.

# `fail`

```elixir
@spec fail(String.t(), map(), keyword()) :: {:ok, ExMCP.Tasks.Task.t()} | task_error()
```

Atomically fails a working task with a JSON-RPC error object.

# `get`

```elixir
@spec get(
  String.t(),
  keyword()
) :: {:ok, map()} | task_error()
```

Returns the authorized full wire state for one task.

# `mark_cancelled`

```elixir
@spec mark_cancelled(
  String.t(),
  keyword()
) :: {:ok, ExMCP.Tasks.Task.t()} | task_error()
```

Atomically marks a cooperatively stopped task as cancelled.

# `owner`

```elixir
@spec owner(keyword()) :: ExMCP.Tasks.Store.owner()
```

Builds the non-secret authorization owner for the current request.

# `put_status_message`

```elixir
@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.

# `require_input`

```elixir
@spec require_input(String.t(), map(), keyword()) ::
  {:ok, ExMCP.Tasks.Task.t()} | task_error()
```

Atomically moves a working task to input-required.

# `take_input_responses`

```elixir
@spec take_input_responses(
  String.t(),
  keyword()
) :: {:ok, map()} | task_error()
```

Atomically drains input responses accepted for a task worker.

# `update`

```elixir
@spec update(String.t(), map(), keyword()) :: :ok | task_error()
```

Idempotently submits responses for currently outstanding task inputs.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
