McpServer.Tool.Annotations (HTTP MCP Server v0.6.0)

View Source

Represents behavioral hints and metadata for tools.

Annotations provide additional information about tool behavior that helps clients make informed decisions about when and how to use the tool.

Fields

  • title - Display title for the tool
  • read_only_hint - True if the tool doesn't modify state
  • destructive_hint - True if the tool may have side effects
  • idempotent_hint - True if repeated calls produce the same result
  • open_world_hint - True if the tool works with unbounded/external data

Examples

iex> annotations = McpServer.Tool.Annotations.new(
...>   title: "Calculator",
...>   read_only_hint: true,
...>   idempotent_hint: true
...> )
%McpServer.Tool.Annotations{
  title: "Calculator",
  read_only_hint: true,
  idempotent_hint: true
}

Summary

Functions

Creates a new Tool.Annotations struct.

Types

t()

@type t() :: %McpServer.Tool.Annotations{
  destructive_hint: boolean(),
  idempotent_hint: boolean(),
  open_world_hint: boolean(),
  read_only_hint: boolean(),
  title: String.t() | nil
}

Functions

new(opts \\ [])

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

Creates a new Tool.Annotations struct.

Parameters

  • opts - Keyword list of annotation options:
    • :title - Display title
    • :read_only_hint - Whether the tool is read-only (default: false)
    • :destructive_hint - Whether the tool may have side effects (default: true)
    • :idempotent_hint - Whether the tool is idempotent (default: false)
    • :open_world_hint - Whether the tool works with unbounded data (default: true)

Examples

iex> McpServer.Tool.Annotations.new(title: "Echo Tool")
%McpServer.Tool.Annotations{title: "Echo Tool"}

iex> McpServer.Tool.Annotations.new(
...>   read_only_hint: true,
...>   destructive_hint: false,
...>   idempotent_hint: true,
...>   open_world_hint: false
...> )
%McpServer.Tool.Annotations{
  read_only_hint: true,
  destructive_hint: false,
  idempotent_hint: true,
  open_world_hint: false
}