OzMcp.Config.Resource.DSL (OzMcp v0.9.0)

Copy Markdown View Source

Compile-time macros of a resource module (use OzMcp.Config.Resource).

use OzMcp.Config.Resource imports the root macro resource/2 only. The nested macros are not imported: they work only inside their resource block. A nested macro at the root of the module gives a compile error (undefined function uri/1).

The macros generate list/0 of the resource behaviour. The module must define read/2. A module with the DSL cannot define list/0.

The macros

MacroBlockValueWire field
resource "name"rootnon-empty stringname
uriresourceabsolute URI with a scheme, unique in the moduleuri
titleresourcenon-empty stringtitle
descriptionresourcenon-empty stringdescription
mime_typeresource, iconnon-empty stringmimeType
sizeresourceinteger of 1 or more (bytes)size
required_scopesresourcelist of scope tokensnone (a 403 and a filtered resources/list)
annotationsresourceblockannotations
audienceannotationslist of "user" and "assistant"annotations.audience
priorityannotationsnumber from 0 to 1annotations.priority
last_modifiedannotationsISO 8601 date and time with an offset, for example 2025-01-12T15:00:58Zannotations.lastModified
iconresource (repeatable)blockone entry of icons
srciconhttps: URL, http: URL of a loopback host, or data: URIicons[].src
sizesiconlist of "any" and "WxH" stringsicons[].sizes
themeicon"light" or "dark"icons[].theme
meta key, valueresourcekey: string or atom, value: a JSON term_meta.<key>

A wrong value, a macro outside its block, or a property declared two times raises at compile time. The resource block requires a uri. With warn?: true (the default), a resource with no title or no description gives a compiler warning.

The guide Resources shows an example of the DSL.

Summary

Functions

annotations(list)

(macro)

audience(value)

(macro)

description(value)

(macro)

icon(list)

(macro)

last_modified(value)

(macro)

meta(key, value)

(macro)

mime_type(value)

(macro)

priority(value)

(macro)

required_scopes(value)

(macro)

resource(entity_name, list)

(macro)

size(value)

(macro)

sizes(value)

(macro)

src(value)

(macro)

theme(value)

(macro)

title(value)

(macro)

uri(value)

(macro)