Helper module used to build the params of a sampling/createMessage
request.
(MCP protocol: 2025-11-25)
messages is a list of OzMcp.Structs.SamplingMessage structs or maps.
tools is a list of OzMcp.Structs.Tool structs or maps. maxTokens is
required.
Tool use follows the rules of the specification, checked by build/1:
- a message that has a
tool_resultblock has onlytool_resultblocks, has the roleuserand comes right after a message with thetool_useblocks it answers; - a message that has
tool_useblocks has the roleassistantand is followed by a message with atool_resultblock for each of them (the sametoolUseId).
Short example:
%CreateMessageRequestParams{}
|> CreateMessageRequestParams.messages([SamplingMessage.user("Hello")])
|> CreateMessageRequestParams.max_tokens(100)
|> CreateMessageRequestParams.build()Result:
%{
messages: [%{role: "user", content: %{type: "text", text: "Hello"}}],
maxTokens: 100
}Specification: CreateMessageRequestParams
Fields
| Field | Setter | Type | Required |
|---|---|---|---|
messages | messages/2 | list of OzMcp.Structs.SamplingMessage.t/0 or map | yes |
modelPreferences | model_preferences/2 | OzMcp.Structs.ModelPreferences.t() | map() | nil | no |
systemPrompt | system_prompt/2 | string | no |
includeContext | include_context/2 | String.t() | atom() | nil | no |
temperature | temperature/2 | number | no |
maxTokens | max_tokens/2 | pos_integer() | nil | no |
stopSequences | stop_sequences/2 | list | no |
metadata | metadata/2 | map | no |
tools | tools/2 | [OzMcp.Structs.Tool.t() | map()] | nil | no |
toolChoice | tool_choice/2 | OzMcp.Structs.ToolChoice.t() | map() | atom() | nil | no |
_meta | _meta/2 | map | no |
task | task/2 | OzMcp.Structs.TaskMetadata.t/0 | no |
Summary
Types
@type t() :: %OzMcp.Structs.CreateMessageRequestParams{ _meta: map() | nil, includeContext: String.t() | atom() | nil, maxTokens: pos_integer() | nil, messages: [OzMcp.Structs.SamplingMessage.t() | map()], metadata: map() | nil, modelPreferences: OzMcp.Structs.ModelPreferences.t() | map() | nil, stopSequences: list() | nil, systemPrompt: String.t() | nil, task: OzMcp.Structs.TaskMetadata.t() | nil, temperature: number() | nil, toolChoice: OzMcp.Structs.ToolChoice.t() | map() | atom() | nil, tools: [OzMcp.Structs.Tool.t() | map()] | nil }
Functions
@spec max_tokens(t(), pos_integer() | nil) :: t()
@spec messages(t(), [OzMcp.Structs.SamplingMessage.t() | map()]) :: t()
@spec model_preferences(t(), OzMcp.Structs.ModelPreferences.t() | map() | nil) :: t()
@spec task(t(), OzMcp.Structs.TaskMetadata.t() | nil) :: t()
@spec tool_choice(t(), OzMcp.Structs.ToolChoice.t() | map() | atom() | nil) :: t()
@spec tools(t(), [OzMcp.Structs.Tool.t() | map()] | nil) :: t()