McpServer.Tool.Content.Resource (HTTP MCP Server v0.6.0)

View Source

Represents an embedded resource in a tool result.

Fields

  • uri - The URI of the resource (required)
  • text - Textual content of the resource (optional)
  • blob - Binary content of the resource, stored as-is (optional)
  • mime_type - MIME type of the resource (optional)

The blob data is stored as-is (not base64-encoded in the struct). Base64 encoding happens during JSON serialization.

Examples

iex> resource = McpServer.Tool.Content.Resource.new(uri: "file:///path/to/file.txt")
iex> resource.uri
"file:///path/to/file.txt"

iex> resource = McpServer.Tool.Content.Resource.new(
...>   uri: "file:///data.json",
...>   text: ~s({"key": "value"}),
...>   mime_type: "application/json"
...> )
iex> resource.text
~s({"key": "value"})

Summary

Functions

Creates a new Resource content struct.

Types

t()

@type t() :: %McpServer.Tool.Content.Resource{
  blob: binary() | nil,
  mime_type: String.t() | nil,
  text: String.t() | nil,
  uri: String.t()
}

Functions

new(opts)

@spec new(keyword()) :: t()

Creates a new Resource content struct.

Parameters

  • opts - Keyword list with required :uri field and optional :text, :blob, :mime_type fields

Examples

iex> McpServer.Tool.Content.Resource.new(uri: "file:///test.txt")
%McpServer.Tool.Content.Resource{uri: "file:///test.txt", text: nil, blob: nil, mime_type: nil}

iex> McpServer.Tool.Content.Resource.new(
...>   uri: "file:///test.txt",
...>   text: "content",
...>   mime_type: "text/plain"
...> )
%McpServer.Tool.Content.Resource{
  uri: "file:///test.txt",
  text: "content",
  blob: nil,
  mime_type: "text/plain"
}