Noizu.MCP.Types.Content (Noizu MCP v0.1.2)

Copy Markdown View Source

An MCP content block: text, image, audio, resource link, or embedded resource.

Build with the constructors:

Content.text("hello")
Content.image(binary, "image/png")
Content.audio(binary, "audio/wav")
Content.resource_link("file:///a.txt", name: "a.txt")
Content.embedded_resource("config://app", text: "{}", mime_type: "application/json")

Summary

Functions

Audio content. data is the raw binary; it is base64-encoded on the wire.

Embedded resource content. Pass text: for text resources or blob: (raw binary, base64-encoded on the wire) for binary resources.

Image content. data is the raw binary; it is base64-encoded on the wire.

Types

content_type()

@type content_type() :: :text | :image | :audio | :resource_link | :resource

t()

@type t() :: %Noizu.MCP.Types.Content{
  annotations: map() | nil,
  data: binary() | nil,
  description: String.t() | nil,
  meta: map() | nil,
  mime_type: String.t() | nil,
  name: String.t() | nil,
  resource: map() | nil,
  text: String.t() | nil,
  title: String.t() | nil,
  type: content_type(),
  uri: String.t() | nil
}

Functions

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

@spec audio(binary(), String.t(), keyword()) :: t()

Audio content. data is the raw binary; it is base64-encoded on the wire.

embedded_resource(uri, opts \\ [])

@spec embedded_resource(
  String.t(),
  keyword()
) :: t()

Embedded resource content. Pass text: for text resources or blob: (raw binary, base64-encoded on the wire) for binary resources.

from_map(map)

@spec from_map(map()) :: t()

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

@spec image(binary(), String.t(), keyword()) :: t()

Image content. data is the raw binary; it is base64-encoded on the wire.

resource_link(uri, opts \\ [])

@spec resource_link(
  String.t(),
  keyword()
) :: t()

text(text, opts \\ [])

@spec text(
  String.t(),
  keyword()
) :: t()

to_map(c)

@spec to_map(t()) :: map()