OzMcp.Structs.Tool (OzMcp v0.9.0)

Copy Markdown View Source

Helper module used to build Tool structure.

(MCP protocol: 2025-11-25)

Short example:

%Tool{}
  |> Tool.name("get_date")
  |> Tool.title("Get the current date (new)")
  |> Tool.description("Get the current date formatted as %d/%m/%Y")
  |> Tool.build()

Result:

%{
  name: "get_date",
  description: "Get the current date formatted as %d/%m/%Y",
  title: "Get the current date (new)",
  inputSchema: %{type: "object", properties: %{}}
}

Long example:

%Tool{}
  |> Tool.name("get_date")
  |> Tool.title("Get the current date")
  |> Tool.description("Get the current date formatted as %d/%m/%Y")
  |> Tool.execution(
    %ToolExecution{}
    |> ToolExecution.task_support(:forbidden)
  )
  |> Tool.icons([
    %Icon{}
    |> Icon.src("https://img.com/icon.png")
    |> Icon.mime_type("image/png")
    |> Icon.sizes(["16x16"])
  ])
  |> Tool._meta(%{
    id: "472",
    md5: "154173f63ed5380419b649e66173e148"
  })
  |> Tool.build()

Result:

%{
  name: "get_date",
  description: "Get the current date formatted as %d/%m/%Y",
  title: "Get the current date",
  execution: %{taskSupport: :forbidden},
  icons: [
    %{
      src: "https://img.com/icon.png",
      sizes: ["16x16"],
      mimeType: "image/png"
    }
  ],
  _meta: %{id: "472", md5: "154173f63ed5380419b649e66173e148"},
  inputSchema: %{type: "object", properties: %{}}
}

The required_scopes field holds the scopes that a principal must hold to use the tool. OzMcp uses them for the check of tools/call and for the filter of tools/list. They are never sent to the client.

Specification: Tool

Fields

FieldSetterTypeRequired
namename/2stringyes
titletitle/2stringno
descriptiondescription/2stringno
inputSchemainput_schema/2mapyes
outputSchemaoutput_schema/2mapno
_meta_meta/2mapno
iconsicons/2list of OzMcp.Structs.Icon.t/0no
executionexecution/2OzMcp.Structs.ToolExecution.t/0no
annotationsannotations/2OzMcp.Structs.ToolAnnotations.t/0no
required_scopesrequired_scopes/2list of scopes, never sentno
extrasextras/2mapno

Summary

Types

t()

@type t() :: %OzMcp.Structs.Tool{
  _meta: map() | nil,
  annotations: OzMcp.Structs.ToolAnnotations.t() | nil,
  description: String.t() | nil,
  execution: OzMcp.Structs.ToolExecution.t() | nil,
  extras: map() | nil,
  icons: [OzMcp.Structs.Icon.t()] | nil,
  inputSchema: map(),
  name: String.t(),
  outputSchema: map() | nil,
  required_scopes: [String.t()],
  title: String.t() | nil
}

Functions

annotations(struct, value)

@spec annotations(t(), OzMcp.Structs.ToolAnnotations.t() | nil) :: t()

build(struct)

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

description(struct, value)

@spec description(t(), String.t() | nil) :: t()

execution(struct, value)

@spec execution(t(), OzMcp.Structs.ToolExecution.t() | nil) :: t()

extras(struct, value)

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

icons(struct, value)

@spec icons(t(), [OzMcp.Structs.Icon.t()] | nil) :: t()

input_schema(struct, value)

@spec input_schema(t(), map()) :: t()

name(struct, value)

@spec name(t(), String.t()) :: t()

output_schema(struct, value)

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

required_scopes(struct, value)

@spec required_scopes(t(), [String.t()]) :: t()

title(struct, value)

@spec title(t(), String.t() | nil) :: t()