OzMcp.Structs.Resource (OzMcp v0.9.0)

Copy Markdown View Source

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

FieldSetterTypeRequired
uriuri/2absolute URIyes
namename/2stringyes
titletitle/2stringno
descriptiondescription/2stringno
mimeTypemime_type/2stringno
_meta_meta/2mapno
iconsicons/2list of OzMcp.Structs.Icon.t/0no
annotationsannotations/2OzMcp.Structs.Annotations.t/0no
sizesize/2non-negative integerno
required_scopesrequired_scopes/2list of scopes, never sentno
extrasextras/2mapno

Summary

Types

t()

@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

annotations(struct, value)

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

build(struct)

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

description(struct, value)

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

extras(struct, value)

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

icons(struct, value)

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

mime_type(struct, value)

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

name(struct, value)

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

required_scopes(struct, value)

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

size(struct, value)

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

title(struct, value)

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

uri(struct, value)

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