# `OzMcp.Structs.Task`
[🔗](https://github.com/oz-elixir/oz_mcp/blob/v0.9.0/lib/oz_mcp/structs/task.ex#L1)

Helper module used to build `Task` structure.

_(MCP protocol: 2025-11-25)_

## Short example:

```elixir
%Task{}
  |> Task.task_id("task-123")
  |> Task.status(:working)
  |> Task.created_at("2025-01-12T15:00:58Z")
  |> Task.last_updated_at("2025-01-12T15:01:12Z")
  |> Task.ttl(60_000)
  |> Task.build()
```

Result:

```elixir
%{
  status: "working",
  ttl: 60000,
  taskId: "task-123",
  createdAt: "2025-01-12T15:00:58Z",
  lastUpdatedAt: "2025-01-12T15:01:12Z"
}
```

Specification: [Task](https://modelcontextprotocol.io/specification/2025-11-25/basic/utilities/tasks)

## Fields

| Field | Setter | Type | Required |
|---|---|---|---|
| `taskId` | `task_id/2` | string | yes |
| `status` | `status/2` | status() | yes |
| `statusMessage` | `status_message/2` | string | no |
| `createdAt` | `created_at/2` | string | yes |
| `lastUpdatedAt` | `last_updated_at/2` | string | yes |
| `ttl` | `ttl/2` | non-negative integer | no |
| `pollInterval` | `poll_interval/2` | non-negative integer | no |

# `status`

```elixir
@type status() :: :working | :input_required | :completed | :failed | :cancelled
```

# `t`

```elixir
@type t() :: %OzMcp.Structs.Task{
  createdAt: String.t(),
  lastUpdatedAt: String.t(),
  pollInterval: non_neg_integer() | nil,
  status: status(),
  statusMessage: String.t() | nil,
  taskId: String.t(),
  ttl: non_neg_integer() | nil
}
```

# `build`

```elixir
@spec build(t()) :: map()
```

# `created_at`

```elixir
@spec created_at(t(), String.t()) :: t()
```

# `last_updated_at`

```elixir
@spec last_updated_at(t(), String.t()) :: t()
```

# `poll_interval`

```elixir
@spec poll_interval(t(), non_neg_integer() | nil) :: t()
```

# `status`

```elixir
@spec status(t(), status()) :: t()
```

# `status_message`

```elixir
@spec status_message(t(), String.t() | nil) :: t()
```

# `task_id`

```elixir
@spec task_id(t(), String.t()) :: t()
```

# `ttl`

```elixir
@spec ttl(t(), non_neg_integer() | nil) :: t()
```

---

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