OzMcp.Structs.CallToolResult (OzMcp v0.9.0)

Copy Markdown View Source

Helper module used to build CallToolResult structure.

(MCP protocol: 2025-11-25)

Short example:

%CallToolResult{}
  |> CallToolResult.content([
    %TextContent{}
    |> TextContent.text("Hello, world!")
  ])
  |> CallToolResult.build()

Result:

%{content: [%{type: "text", text: "Hello, world!"}]}

Long example:

%CallToolResult{}
  |> CallToolResult.content([
    %TextContent{}
    |> TextContent.text("Hello, world!"),
    %ImageContent{}
    |> ImageContent.data("iVBORw0KGgoAAAANSUhEUg==")
    |> ImageContent.mime_type("image/png")
  ])
  |> CallToolResult.structured_content(%{"result" => "ok"})
  |> CallToolResult.is_error(false)
  |> CallToolResult._meta(%{"key" => "value"})
  |> CallToolResult.extras(%{"durationMs" => 12, "cost" => 0.25})
  |> CallToolResult.build()

Result:

%{
  :content => [
    %{type: "text", text: "Hello, world!"},
    %{
      data: "iVBORw0KGgoAAAANSUhEUg==",
      type: "image",
      mimeType: "image/png"
    }
  ],
  :_meta => %{"key" => "value"},
  :structuredContent => %{"result" => "ok"},
  :isError => false,
  "cost" => 0.25,
  "durationMs" => 12
}

Specification: CallToolResult

Fields

FieldSetterTypeRequired
contentcontent/2[content()]yes
_meta_meta/2mapno
structuredContentstructured_content/2mapno
isErroris_error/2booleanno
extrasextras/2mapno

Summary

Types

content()

@type content() :: OzMcp.Structs.ContentBlock.t()

t()

@type t() :: %OzMcp.Structs.CallToolResult{
  _meta: map() | nil,
  content: [content()],
  extras: map() | nil,
  isError: boolean() | nil,
  structuredContent: map() | nil
}

Functions

build(struct)

@spec build(t()) :: map()

content(struct, value)

@spec content(t(), [content()]) :: t()

extras(struct, value)

@spec extras(t(), map() | nil) :: t()

is_error(struct, value)

@spec is_error(t(), boolean() | nil) :: t()

structured_content(struct, value)

@spec structured_content(t(), map() | nil) :: t()