OzMcp.Structs.CreateMessageRequestParams (OzMcp v0.9.0)

Copy Markdown View Source

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_result block has only tool_result blocks, has the role user and comes right after a message with the tool_use blocks it answers;
  • a message that has tool_use blocks has the role assistant and is followed by a message with a tool_result block for each of them (the same toolUseId).

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

FieldSetterTypeRequired
messagesmessages/2list of OzMcp.Structs.SamplingMessage.t/0 or mapyes
modelPreferencesmodel_preferences/2OzMcp.Structs.ModelPreferences.t() | map() | nilno
systemPromptsystem_prompt/2stringno
includeContextinclude_context/2String.t() | atom() | nilno
temperaturetemperature/2numberno
maxTokensmax_tokens/2pos_integer() | nilno
stopSequencesstop_sequences/2listno
metadatametadata/2mapno
toolstools/2[OzMcp.Structs.Tool.t() | map()] | nilno
toolChoicetool_choice/2OzMcp.Structs.ToolChoice.t() | map() | atom() | nilno
_meta_meta/2mapno
tasktask/2OzMcp.Structs.TaskMetadata.t/0no

Summary

Types

t()

@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

build(struct)

@spec build(t()) :: map()

include_context(struct, value)

@spec include_context(t(), String.t() | atom() | nil) :: t()

max_tokens(struct, value)

@spec max_tokens(t(), pos_integer() | nil) :: t()

messages(struct, value)

@spec messages(t(), [OzMcp.Structs.SamplingMessage.t() | map()]) :: t()

metadata(struct, value)

@spec metadata(t(), map() | nil) :: t()

model_preferences(struct, value)

@spec model_preferences(t(), OzMcp.Structs.ModelPreferences.t() | map() | nil) :: t()

stop_sequences(struct, value)

@spec stop_sequences(t(), list() | nil) :: t()

system_prompt(struct, value)

@spec system_prompt(t(), String.t() | nil) :: t()

task(struct, value)

@spec task(t(), OzMcp.Structs.TaskMetadata.t() | nil) :: t()

temperature(struct, value)

@spec temperature(t(), number() | nil) :: t()

tool_choice(struct, value)

@spec tool_choice(t(), OzMcp.Structs.ToolChoice.t() | map() | atom() | nil) :: t()

tools(struct, value)

@spec tools(t(), [OzMcp.Structs.Tool.t() | map()] | nil) :: t()