Table of Contents

Class SamplingMessage

Namespace
ModelContextProtocol.Protocol
Assembly
ModelContextProtocol.dll

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

public class SamplingMessage
Inheritance
SamplingMessage
Inherited Members

Remarks

A SamplingMessage encapsulates content sent to or received from AI models in the Model Context Protocol. Each message has a specific role (User or Assistant) and contains content which can be text or images.

SamplingMessage objects are typically used in collections within CreateMessageRequestParams to represent prompts or queries for LLM sampling. They form the core data structure for text generation requests within the Model Context Protocol.

While similar to PromptMessage, the SamplingMessage is focused on direct LLM sampling operations rather than the enhanced resource embedding capabilities provided by PromptMessage.

See the schema for details.

Properties

Content

Gets or sets the content of the message.

[JsonPropertyName("content")]
public required Content Content { get; init; }

Property Value

Content

Role

Gets or sets the role of the message sender, indicating whether it's from a "user" or an "assistant".

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

Property Value

Role