CreateMessageRequestParams class final

Parameters for a sampling/createMessage request.

Revisions: 2025-11-25, 2026-07-28, ext-tasks/2026-07-28.

Inheritance

Constructors

CreateMessageRequestParams({CreateMessageRequestParamsMeta? meta, CreateMessageRequestParamsIncludeContext? includeContext, required int maxTokens, required List<SamplingMessage> messages, Map<String, Object?>? metadata, ModelPreferences? modelPreferences, List<String>? stopSequences, String? systemPrompt, TaskMetadata? task, num? temperature, ToolChoice? toolChoice, List<Tool>? tools, Map<String, Object?>? extra})
CreateMessageRequestParams.fromJson(Map<String, Object?> json)
Wraps json as received; nothing is dropped.

Properties

extra → Map<String, Object?>
Keys outside the schema (newer revisions, extensions, applications).
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
includeContext → CreateMessageRequestParamsIncludeContext?
A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.
no setter
maxTokens → int
The requested maximum number of tokens to sample (to prevent runaway completions).
no setter
messages → List<SamplingMessage>
no setter
meta → CreateMessageRequestParamsMeta?
See General fields: _meta for notes on _meta usage.
no setter
metadata → Map<String, Object?>?
Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
no setter
modelPreferences → ModelPreferences?
The server's preferences for which model to select. The client MAY ignore these preferences.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
schemaKeys → Set<String>
Property names the schema defines for this type.
no setteroverride
stopSequences → List<String>?
no setter
systemPrompt → String?
An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
no setter
task → TaskMetadata?
If specified, the caller is requesting task-augmented execution for this request. The request will return a CreateTaskResult immediately, and the actual result can be retrieved later via tasks/result.
no setter
temperature → num?
no setter
toolChoice → ToolChoice?
Controls how the model uses tools. The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared. Default is { mode: "auto" }.
no setter
tools → List<Tool>?
Tools that the model may use during generation. The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
no setter

Methods

$optional<T>(String key, T? read(Object? value, String path)) → T?
Optional property key, converted by read; null when absent or null.
inherited
$required<T>(String key, T read(Object? value, String path)) → T
Required property key, converted by read.
inherited
check() → List<String>
Reads every property this type defines and returns what could not be read (missing required properties, wrong types), nested types included. Empty = the JSON matches the schema's shape for this type.
override
copyWith({CreateMessageRequestParamsMeta? meta, CreateMessageRequestParamsIncludeContext? includeContext, int? maxTokens, List<SamplingMessage>? messages, Map<String, Object?>? metadata, ModelPreferences? modelPreferences, List<String>? stopSequences, String? systemPrompt, TaskMetadata? task, num? temperature, ToolChoice? toolChoice, List<Tool>? tools}) → CreateMessageRequestParams
A copy with the given properties replaced; everything else, unknown keys included, is kept.
has(String key) → bool
Whether key is present (a null value counts as present).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, Object?>
The JSON form of this value.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
Equal when the JSON is equal; key order does not matter.
inherited
operator [](String key) → Object?
The raw JSON value of key.
inherited

Constants

keys → const Set<String>