FastestMCP.Prompts.Message (fastest_mcp v0.1.2)

Copy Markdown View Source

Prompt message helper with content normalization.

This helper exists for the cases where a prompt wants explicit control over roles and content blocks without forcing every handler to build raw MCP maps by hand.

Accepted content forms:

  • strings - emitted as text content
  • MCP-style content maps - passed through
  • maps, lists, tuples, structs, and other values - JSON encoded as text

Examples

FastestMCP.Prompts.Message.new("Summarize the diff")
FastestMCP.Prompts.Message.new("Done.", role: :assistant)
FastestMCP.Prompts.Message.new(%{type: "resource", resource: %{uri: "file:///tmp/out.txt"}})

Summary

Functions

Normalizes a message-like value into %FastestMCP.Prompts.Message{}.

Builds a normalized prompt message.

Converts the helper struct into the normalized prompt-message map used by the runtime.

Types

role()

@type role() :: :user | :assistant | String.t()

t()

@type t() :: %FastestMCP.Prompts.Message{
  content: any(),
  meta: map() | nil,
  role: String.t()
}

Functions

from(message)

Normalizes a message-like value into %FastestMCP.Prompts.Message{}.

new(content, opts \\ [])

Builds a normalized prompt message.

to_map(message)

Converts the helper struct into the normalized prompt-message map used by the runtime.