Helper module used to build Resource structure.
(MCP protocol: 2025-11-25)
Short example:
%Resource{}
|> Resource.uri("file:///logs/app.log")
|> Resource.name("app.log")
|> Resource.build()Result:
%{name: "app.log", uri: "file:///logs/app.log"}Long example:
%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:
%{
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
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 OzMcp.Structs.Icon.t/0 | no |
annotations | annotations/2 | 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 |
Summary
Types
@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() }
Functions
@spec annotations(t(), OzMcp.Structs.Annotations.t() | nil) :: t()
@spec icons(t(), [OzMcp.Structs.Icon.t()] | nil) :: t()
@spec size(t(), non_neg_integer() | nil) :: t()