FastestMCP.Resources.Content (fastest_mcp v0.1.2)

Copy Markdown View Source

Resource content helper with MIME and metadata support.

This helper exists for resource handlers that need explicit control over per-item MIME types and per-item metadata.

Accepted content forms:

  • UTF-8 binaries - treated as text
  • non-UTF-8 binaries - treated as binary blobs
  • maps, lists, tuples, and structs - JSON encoded as text

Use FastestMCP.Resources.Binary.new/2 when you need to force binary handling for data that happens to be valid UTF-8.

Summary

Functions

Normalizes content-like values into %FastestMCP.Resources.Content{}.

Builds a normalized resource content item.

Returns whether the content should be encoded as text in the transport payload.

Types

t()

@type t() :: %FastestMCP.Resources.Content{
  content: String.t() | binary(),
  meta: map() | nil,
  mime_type: String.t()
}

Functions

from(content)

Normalizes content-like values into %FastestMCP.Resources.Content{}.

new(content, opts \\ [])

Builds a normalized resource content item.

textual?(content)

Returns whether the content should be encoded as text in the transport payload.