CreateMessageRequest class
Create message request for sampling.
Spec 2025-11-25+ adds sampling tool calling: tools advertises tool
definitions the sampled model may call, and toolChoice steers whether
/ which tool it must use. Both are gated by
McpProtocol.supportsSamplingTools(negotiatedVersion); older peers omit
them and the fields serialize away (additive).
- Annotations
-
- @immutable
Constructors
-
CreateMessageRequest({required List<
Message> messages, ModelPreferences? modelPreferences, String? systemPrompt, String? includeContext, int? maxTokens, double? temperature, List<String> ? stopSequences, Map<String, dynamic> ? metadata, List<Tool> ? tools, Object? toolChoice}) -
const
-
CreateMessageRequest.fromJson(Map<
String, dynamic> json) -
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- includeContext → String?
-
final
- maxTokens → int?
-
final
-
messages
→ List<
Message> -
final
-
metadata
→ Map<
String, dynamic> ? -
final
- modelPreferences → ModelPreferences?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stopSequences
→ List<
String> ? -
final
- systemPrompt → String?
-
final
- temperature → double?
-
final
- toolChoice → Object?
-
Spec 2025-11-25+: tool-selection directive. Carried losslessly — the
wire value is either a mode string (
"auto"/"none"/"required") or an object naming a specific tool (e.g.{"type":"tool","name":"…"}). Modeled as Object rather than a rigid enum so any peer-defined shape round-trips without loss; use SamplingToolChoice helpers to build it.final -
tools
→ List<
Tool> ? -
Spec 2025-11-25+: tool definitions offered to the sampled model. Reuses
the Tool schema (
name/description/inputSchema), matching how tools are modeled everywhere else in the protocol.final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited