Helper module used to build SamplingMessage structure: a message of the
conversation the server asks the client to complete.
(MCP protocol: 2025-11-25)
content is one block or a list of blocks. A block is a TextContent,
ImageContent, AudioContent, ToolUseContent or ToolResultContent
struct, or a map that is already a block.
Short example:
%SamplingMessage{}
|> SamplingMessage.role(:user)
|> SamplingMessage.content(%TextContent{} |> TextContent.text("Hello"))
|> SamplingMessage.build()Result:
%{role: "user", content: %{type: "text", text: "Hello"}}user/1 and assistant/1 build a message from a text:
SamplingMessage.user("Hello") |> SamplingMessage.build()Specification: SamplingMessage
Fields
| Field | Setter | Type | Required |
|---|---|---|---|
role | role/2 | role() | String.t() | no |
content | content/2 | block() | list(block()) | nil | no |
_meta | _meta/2 | map | no |
Summary
Types
@type block() :: %OzMcp.Structs.TextContent{_meta: term(), annotations: term(), text: term()} | %OzMcp.Structs.ImageContent{ _meta: term(), annotations: term(), data: term(), mimeType: term() } | %OzMcp.Structs.AudioContent{ _meta: term(), annotations: term(), data: term(), mimeType: term() } | %OzMcp.Structs.ToolUseContent{ _meta: term(), id: term(), input: term(), name: term() } | %OzMcp.Structs.ToolResultContent{ _meta: term(), content: term(), isError: term(), structuredContent: term(), toolUseId: term() } | map()
@type role() :: :user | :assistant