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

View Source

Structs for representing tool result content items.

This module provides typed structs for different types of content that can be returned from tool functions, following the MCP protocol specification.

Content Types

  • Text - Text content
  • Image - Image content with base64-encoded data
  • Resource - Embedded resource content

Examples

iex> alias McpServer.Tool.Content
iex> text = Content.Text.new(text: "Hello, World!")
iex> text.text
"Hello, World!"

iex> image_data = <<137, 80, 78, 71, 13, 10, 26, 10>>
iex> image = Content.Image.new(data: image_data, mime_type: "image/png")
iex> image.mime_type
"image/png"

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