CreateMessageRequest

@Serializable
data class CreateMessageRequest(val messages: List<SamplingMessage>, val systemPrompt: String?, val includeContext: CreateMessageRequest.IncludeContext?, val temperature: Double?, val maxTokens: Int, val stopSequences: List<String>?, val metadata: JsonObject = EmptyJsonObject, val modelPreferences: ModelPreferences?, val _meta: JsonObject = EmptyJsonObject) : ServerRequest, WithMeta(source)

A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling to allow them to inspect the request (human in the loop) and decide whether to approve it.

Constructors

Link copied to clipboard
constructor(messages: List<SamplingMessage>, systemPrompt: String?, includeContext: CreateMessageRequest.IncludeContext?, temperature: Double?, maxTokens: Int, stopSequences: List<String>?, metadata: JsonObject = EmptyJsonObject, modelPreferences: ModelPreferences?, _meta: JsonObject = EmptyJsonObject)

Types

Link copied to clipboard

Properties

Link copied to clipboard
open override val _meta: JsonObject

The protocol reserves this result property to allow clients and servers to attach additional metadata to their responses.

Link copied to clipboard

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.

Link copied to clipboard

The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested.

Link copied to clipboard
Link copied to clipboard
val metadata: JsonObject

Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.

Link copied to clipboard
open override val method: Method
Link copied to clipboard

The server's preferences for which model to select.

Link copied to clipboard
Link copied to clipboard

An optional system prompt the server wants to use it for sampling. The client MAY modify or omit this prompt.

Link copied to clipboard

Functions

Link copied to clipboard

Converts the request to a JSON-RPC request.