Package io.modelcontextprotocol.spec
Record Class McpSchema.CreateMessageRequest
java.lang.Object
java.lang.Record
io.modelcontextprotocol.spec.McpSchema.CreateMessageRequest
- Record Components:
messages- The conversation messages to send to the LLMmodelPreferences- The server's preferences for which model to select. The client MAY ignore these preferencessystemPrompt- An optional system prompt the server wants to use for sampling. The client MAY modify or omit this promptincludeContext- 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 requesttemperature- Optional temperature parameter for samplingmaxTokens- The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requestedstopSequences- Optional stop sequences for samplingmetadata- Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specificmeta- See specification for notes on _meta usage
- All Implemented Interfaces:
McpSchema.Request
- Enclosing class:
- McpSchema
public static record McpSchema.CreateMessageRequest(List<McpSchema.SamplingMessage> messages, McpSchema.ModelPreferences modelPreferences, String systemPrompt, McpSchema.CreateMessageRequest.ContextInclusionStrategy includeContext, Double temperature, int maxTokens, List<String> stopSequences, Map<String,Object> metadata, Map<String,Object> meta)
extends Record
implements McpSchema.Request
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enum -
Constructor Summary
ConstructorsConstructorDescriptionCreateMessageRequest(List<McpSchema.SamplingMessage> messages, McpSchema.ModelPreferences modelPreferences, String systemPrompt, McpSchema.CreateMessageRequest.ContextInclusionStrategy includeContext, Double temperature, int maxTokens, List<String> stopSequences, Map<String, Object> metadata) CreateMessageRequest(List<McpSchema.SamplingMessage> messages, McpSchema.ModelPreferences modelPreferences, String systemPrompt, McpSchema.CreateMessageRequest.ContextInclusionStrategy includeContext, Double temperature, int maxTokens, List<String> stopSequences, Map<String, Object> metadata, Map<String, Object> meta) Creates an instance of aCreateMessageRequestrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of theincludeContextrecord component.intReturns the value of themaxTokensrecord component.messages()Returns the value of themessagesrecord component.meta()Returns the value of themetarecord component.metadata()Returns the value of themetadatarecord component.Returns the value of themodelPreferencesrecord component.Returns the value of thestopSequencesrecord component.Returns the value of thesystemPromptrecord component.Returns the value of thetemperaturerecord component.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.modelcontextprotocol.spec.McpSchema.Request
progressToken
-
Constructor Details
-
CreateMessageRequest
public CreateMessageRequest(List<McpSchema.SamplingMessage> messages, McpSchema.ModelPreferences modelPreferences, String systemPrompt, McpSchema.CreateMessageRequest.ContextInclusionStrategy includeContext, Double temperature, int maxTokens, List<String> stopSequences, Map<String, Object> metadata) -
CreateMessageRequest
public CreateMessageRequest(List<McpSchema.SamplingMessage> messages, McpSchema.ModelPreferences modelPreferences, String systemPrompt, McpSchema.CreateMessageRequest.ContextInclusionStrategy includeContext, Double temperature, int maxTokens, List<String> stopSequences, Map<String, Object> metadata, Map<String, Object> meta) Creates an instance of aCreateMessageRequestrecord class.- Parameters:
messages- the value for themessagesrecord componentmodelPreferences- the value for themodelPreferencesrecord componentsystemPrompt- the value for thesystemPromptrecord componentincludeContext- the value for theincludeContextrecord componenttemperature- the value for thetemperaturerecord componentmaxTokens- the value for themaxTokensrecord componentstopSequences- the value for thestopSequencesrecord componentmetadata- the value for themetadatarecord componentmeta- the value for themetarecord component
-
-
Method Details
-
builder
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
messages
Returns the value of themessagesrecord component.- Returns:
- the value of the
messagesrecord component
-
modelPreferences
Returns the value of themodelPreferencesrecord component.- Returns:
- the value of the
modelPreferencesrecord component
-
systemPrompt
Returns the value of thesystemPromptrecord component.- Returns:
- the value of the
systemPromptrecord component
-
includeContext
Returns the value of theincludeContextrecord component.- Returns:
- the value of the
includeContextrecord component
-
temperature
Returns the value of thetemperaturerecord component.- Returns:
- the value of the
temperaturerecord component
-
maxTokens
public int maxTokens()Returns the value of themaxTokensrecord component.- Returns:
- the value of the
maxTokensrecord component
-
stopSequences
Returns the value of thestopSequencesrecord component.- Returns:
- the value of the
stopSequencesrecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-
meta
Returns the value of themetarecord component.- Specified by:
metain interfaceMcpSchema.Request- Returns:
- the value of the
metarecord component
-