Table of Contents

Class CreateMessageResult

Namespace
ModelContextProtocol.Protocol
Assembly
ModelContextProtocol.Core.dll

Represents a client's response to a SamplingCreateMessage from the server.

public sealed class CreateMessageResult : Result
Inheritance
CreateMessageResult
Inherited Members

Remarks

See the schema for details.

Properties

Content

Gets or sets the content of the assistant's response.

[JsonPropertyName("content")]
[JsonConverter(typeof(SingleItemOrListConverter<ContentBlock>))]
public required IList<ContentBlock> Content { get; set; }

Property Value

IList<ContentBlock>

Remarks

In the corresponding JSON, this might be a single content block or an array of content blocks.

Model

Gets or sets the name of the model that generated the message.

[JsonPropertyName("model")]
public required string Model { get; set; }

Property Value

string

Remarks

This value should contain the specific model identifier such as "claude-3-5-sonnet-20241022" or "o3-mini".

This property allows the server to know which model was used to generate the response, enabling appropriate handling based on the model's capabilities and characteristics.

Role

Gets or sets the role of the user who generated the message.

[JsonPropertyName("role")]
public Role Role { get; set; }

Property Value

Role

The role of the user who generated the message. The default is Assistant.

StopReason

Gets or sets the reason why message generation (sampling) stopped, if known.

[JsonPropertyName("stopReason")]
public string? StopReason { get; set; }

Property Value

string

Remarks

Standard values include:

  • endTurnThe model naturally completed its response.
  • maxTokensThe response was truncated due to reaching token limits.
  • stopSequenceA specific stop sequence was encountered during generation.
  • toolUseThe model wants to use one or more tools.
This field is an open string to allow for provider-specific stop reasons.