Class SamplingMessage | MCP C# SDK

Namespace
ModelContextProtocol.Protocol
Assembly
ModelContextProtocol.Core.dll

Represents a message issued to or received from an LLM API within the Model Context Protocol.

public sealed class SamplingMessage
Inheritance

SamplingMessage

Inherited Members

Properties

Content

Gets or sets the content of the message.

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

Property Value

IList<ContentBlock>

Meta

Gets or sets metadata reserved by MCP for protocol-level metadata.

[JsonPropertyName("_meta")]
public JsonObject? Meta { get; set; }

Property Value

JsonObject

Role

Gets or sets the role of the message sender.

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

Property Value

Role