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

Persistence contract for the MCP Tasks extension.

A store must make `create/3` durable before returning success and must apply
ownership checks to every operation. Implementations should make lifecycle
operations atomic across every node that can serve the same task ID.

ExMCP ships `ExMCP.Tasks.Store.ETS` as a bounded, node-local reference
implementation. Deployments that require task survival across server or
node restarts should configure a database-backed implementation.

# `owner`

```elixir
@type owner() :: %{
  principal_id: String.t() | nil,
  tenant_id: String.t() | nil,
  audience: String.t() | nil
}
```

# `store_error`

```elixir
@type store_error() ::
  :already_exists
  | :invalid_task
  | :invalid_input_responses
  | :invalid_transition
  | :not_found_or_unauthorized
  | :store_full
  | :ttl_out_of_range
  | term()
```

# `transition`

```elixir
@type transition() ::
  {:complete, map()}
  | {:fail, map()}
  | {:require_input, map()}
  | {:status_message, String.t() | nil}
  | :cancelled
```

# `cancellation_requested?`

```elixir
@callback cancellation_requested?(String.t(), owner(), keyword()) ::
  {:ok, boolean()} | {:error, store_error()}
```

# `create`

```elixir
@callback create(ExMCP.Tasks.Task.t(), owner(), keyword()) ::
  {:ok, ExMCP.Tasks.Task.t()} | {:error, store_error()}
```

# `fetch`

```elixir
@callback fetch(String.t(), owner(), keyword()) ::
  {:ok, ExMCP.Tasks.Task.t()} | {:error, store_error()}
```

# `request_cancel`

```elixir
@callback request_cancel(String.t(), owner(), keyword()) :: :ok | {:error, store_error()}
```

# `submit_input`

```elixir
@callback submit_input(String.t(), map(), owner(), keyword()) ::
  :ok | {:error, store_error()}
```

# `take_input_responses`

```elixir
@callback take_input_responses(String.t(), owner(), keyword()) ::
  {:ok, map()} | {:error, store_error()}
```

# `transition`

```elixir
@callback transition(String.t(), transition(), owner(), keyword()) ::
  {:ok, ExMCP.Tasks.Task.t()} | {:error, store_error()}
```

---

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