pub struct CreateMessageRequest {
pub params: CreateMessageRequestParams,
/* private fields */
}
Expand description
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.
JSON schema
{
"description": "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.",
"type": "object",
"required": [
"method",
"params"
],
"properties": {
"method": {
"type": "string",
"const": "sampling/createMessage"
},
"params": {
"type": "object",
"required": [
"maxTokens",
"messages"
],
"properties": {
"includeContext": {
"description": "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.",
"type": "string",
"enum": [
"allServers",
"none",
"thisServer"
]
},
"maxTokens": {
"description": "The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested.",
"type": "integer"
},
"messages": {
"type": "array",
"items": {
"$ref": "#/definitions/SamplingMessage"
}
},
"metadata": {
"description": "Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.",
"type": "object",
"additionalProperties": true
},
"modelPreferences": {
"description": "The server's preferences for which model to select. The client MAY ignore these preferences.",
"$ref": "#/definitions/ModelPreferences"
},
"stopSequences": {
"type": "array",
"items": {
"type": "string"
}
},
"systemPrompt": {
"description": "An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.",
"type": "string"
},
"temperature": {
"type": "number"
}
}
}
}
}
Fields§
§params: CreateMessageRequestParams
Implementations§
Source§impl CreateMessageRequest
impl CreateMessageRequest
pub fn new(params: CreateMessageRequestParams) -> Self
pub fn method(&self) -> &String
pub fn method_name() -> String
Trait Implementations§
Source§impl Clone for CreateMessageRequest
impl Clone for CreateMessageRequest
Source§fn clone(&self) -> CreateMessageRequest
fn clone(&self) -> CreateMessageRequest
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CreateMessageRequest
impl Debug for CreateMessageRequest
Source§impl<'de> Deserialize<'de> for CreateMessageRequest
impl<'de> Deserialize<'de> for CreateMessageRequest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<CreateMessageRequest> for MessageFromServer
impl From<CreateMessageRequest> for MessageFromServer
Source§fn from(value: CreateMessageRequest) -> Self
fn from(value: CreateMessageRequest) -> Self
Converts to this type from the input type.
Source§impl From<CreateMessageRequest> for RequestFromServer
impl From<CreateMessageRequest> for RequestFromServer
Source§fn from(value: CreateMessageRequest) -> Self
fn from(value: CreateMessageRequest) -> Self
Converts to this type from the input type.
Source§impl From<CreateMessageRequest> for ServerRequest
impl From<CreateMessageRequest> for ServerRequest
Source§fn from(value: CreateMessageRequest) -> Self
fn from(value: CreateMessageRequest) -> Self
Converts to this type from the input type.
Source§impl FromMessage<CreateMessageRequest> for ServerMessage
impl FromMessage<CreateMessageRequest> for ServerMessage
fn from_message( message: CreateMessageRequest, request_id: Option<RequestId>, ) -> Result<Self, RpcError>
Source§impl Serialize for CreateMessageRequest
impl Serialize for CreateMessageRequest
Source§impl ToMessage<ServerMessage> for CreateMessageRequest
impl ToMessage<ServerMessage> for CreateMessageRequest
fn to_message( self, request_id: Option<RequestId>, ) -> Result<ServerMessage, RpcError>
Auto Trait Implementations§
impl Freeze for CreateMessageRequest
impl RefUnwindSafe for CreateMessageRequest
impl Send for CreateMessageRequest
impl Sync for CreateMessageRequest
impl Unpin for CreateMessageRequest
impl UnwindSafe for CreateMessageRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more