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

Helper module used to build `Resource` structure.

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

## Short example:

```elixir
%Resource{}
  |> Resource.uri("file:///logs/app.log")
  |> Resource.name("app.log")
  |> Resource.build()
```

Result:

```elixir
%{name: "app.log", uri: "file:///logs/app.log"}
```

## Long example:

```elixir
%Resource{}
  |> Resource.uri("file:///logs/app.log")
  |> Resource.name("app.log")
  |> Resource.title("Application log")
  |> Resource.description("Main application log file")
  |> Resource.mime_type("text/plain")
  |> Resource.size(1024)
  |> Resource.annotations(
    %Annotations{}
    |> Annotations.audience(["assistant"])
  )
  |> Resource.build()
```

Result:

```elixir
%{
  name: "app.log",
  size: 1024,
  description: "Main application log file",
  title: "Application log",
  uri: "file:///logs/app.log",
  annotations: %{audience: ["assistant"]},
  mimeType: "text/plain"
}
```

The `required_scopes` field holds the scopes that a principal must hold to
use the resource. OzMcp uses them for the check of `resources/read` and
`resources/subscribe` and for the filter of `resources/list`. They are
never sent to the client.

Specification: [Resource](https://modelcontextprotocol.io/specification/2025-11-25/schema#resource)

## Fields

| Field | Setter | Type | Required |
|---|---|---|---|
| `uri` | `uri/2` | absolute URI | yes |
| `name` | `name/2` | string | yes |
| `title` | `title/2` | string | no |
| `description` | `description/2` | string | no |
| `mimeType` | `mime_type/2` | string | no |
| `_meta` | `_meta/2` | map | no |
| `icons` | `icons/2` | list of `t:OzMcp.Structs.Icon.t/0` | no |
| `annotations` | `annotations/2` | `t:OzMcp.Structs.Annotations.t/0` | no |
| `size` | `size/2` | non-negative integer | no |
| `required_scopes` | `required_scopes/2` | list of scopes, never sent | no |
| `extras` | `extras/2` | map | no |

# `t`

```elixir
@type t() :: %OzMcp.Structs.Resource{
  _meta: map() | nil,
  annotations: OzMcp.Structs.Annotations.t() | nil,
  description: String.t() | nil,
  extras: map() | nil,
  icons: [OzMcp.Structs.Icon.t()] | nil,
  mimeType: String.t() | nil,
  name: String.t(),
  required_scopes: [String.t()],
  size: non_neg_integer() | nil,
  title: String.t() | nil,
  uri: String.t()
}
```

# `annotations`

```elixir
@spec annotations(t(), OzMcp.Structs.Annotations.t() | nil) :: t()
```

# `build`

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

# `description`

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

# `extras`

```elixir
@spec extras(t(), map() | nil) :: t()
```

# `icons`

```elixir
@spec icons(t(), [OzMcp.Structs.Icon.t()] | nil) :: t()
```

# `mime_type`

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

# `name`

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

# `required_scopes`

```elixir
@spec required_scopes(t(), [String.t()]) :: t()
```

# `size`

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

# `title`

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

# `uri`

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

---

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