Urchin.Content (Urchin v0.1.0)

Copy Markdown View Source

Builders for MCP content blocks and resource contents.

Content blocks (text, image, audio, resource_link, embedded) appear in tool-call results and prompt messages. Resource contents (text_resource, blob_resource) appear in resources/read results.

Every builder returns a plain map with atom keys, ready to be JSON-encoded. Optional members (annotations, _meta) are only included when provided.

Summary

Functions

An audio content block carrying base64-encoded data and its MIME type.

Binary resource contents (base64-encoded) for a resources/read result.

An embedded resource content block. resource_contents must be a map built by text_resource/3 or blob_resource/3 (or an equivalent shape).

An image content block carrying base64-encoded data and its MIME type.

A resource link content block. Accepts an Urchin.Resource struct or a map carrying at least :uri/:name.

A text content block.

Text resource contents for a resources/read result.

Types

block()

@type block() :: map()

contents()

@type contents() :: map()

opts()

@type opts() :: keyword()

Functions

audio(base64_data, mime_type, opts \\ [])

@spec audio(String.t(), String.t(), opts()) :: block()

An audio content block carrying base64-encoded data and its MIME type.

blob_resource(uri, base64_blob, opts \\ [])

@spec blob_resource(String.t(), String.t(), opts()) :: contents()

Binary resource contents (base64-encoded) for a resources/read result.

Options

  • :mime_type - MIME type of the resource
  • :meta - value for the _meta field

embedded(resource_contents, opts \\ [])

@spec embedded(contents(), opts()) :: block()

An embedded resource content block. resource_contents must be a map built by text_resource/3 or blob_resource/3 (or an equivalent shape).

image(base64_data, mime_type, opts \\ [])

@spec image(String.t(), String.t(), opts()) :: block()

An image content block carrying base64-encoded data and its MIME type.

resource_link(resource, opts \\ [])

@spec resource_link(Urchin.Resource.t() | map(), opts()) :: block()

A resource link content block. Accepts an Urchin.Resource struct or a map carrying at least :uri/:name.

text(text, opts \\ [])

@spec text(String.t(), opts()) :: block()

A text content block.

Options

  • :annotations - client annotations map
  • :meta - value for the _meta field

text_resource(uri, text, opts \\ [])

@spec text_resource(String.t(), String.t(), opts()) :: contents()

Text resource contents for a resources/read result.

Options

  • :mime_type - MIME type of the resource
  • :meta - value for the _meta field