Skip to content

Commit dbf5279

Browse files
committed
Revise sampling spec to define all valid request/response fields
1 parent 6e92d63 commit dbf5279

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

docs/legacy/concepts/sampling.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ The client controls what context is actually included.
107107

108108
Fine-tune the LLM sampling with:
109109

110-
- `temperature`: Controls randomness (0.0 to 1.0)
110+
- `temperature`: Controls randomness in model responses. Higher values produce higher randomness, and lower values produce more stable output.
111111
- `maxTokens`: Maximum tokens to generate
112112
- `stopSequences`: Array of sequences that stop generation
113113
- `metadata`: Additional provider-specific parameters

docs/specification/draft/client/sampling.mdx

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,13 @@ To request a language model generation, servers send a `sampling/createMessage`
7777
"name": "claude-3-sonnet"
7878
}
7979
],
80+
"costPriority": 0.3,
8081
"intelligencePriority": 0.8,
8182
"speedPriority": 0.5
8283
},
84+
"temperature": 0.1,
8385
"systemPrompt": "You are a helpful assistant.",
86+
"includeContext": "thisServer",
8487
"maxTokens": 100
8588
}
8689
}
@@ -136,7 +139,8 @@ sequenceDiagram
136139

137140
### Messages
138141

139-
Sampling messages can contain:
142+
Sampling messages **MUST** contain a `role` field of `"user"` or `"assistant"`; and
143+
a `content` field representing the message data. `content` can contain:
140144

141145
#### Text Content
142146

@@ -214,6 +218,50 @@ The client processes these preferences to select an appropriate model from its a
214218
options. For instance, if the client doesn't have access to Claude models but has Gemini,
215219
it might map the sonnet hint to `gemini-1.5-pro` based on similar capabilities.
216220

221+
### System Prompt
222+
223+
The optional `systemPrompt` field allows servers to request a specific system prompt.
224+
The client **MAY** modify or ignore this field without communicating this to the server.
225+
226+
### Context Inclusion
227+
228+
The `includeContext` parameter specifies what context information the client is expected
229+
to include in its response:
230+
231+
- `"none"`: No additional context.
232+
- `"thisServer"`: Include context from the requesting server.
233+
- `"allServers"`: Include context from all connected MCP servers.
234+
235+
The client **MAY** modify or ignore this field without communicating this to the server.
236+
For example, a client could determine that respecting this field in a particular request
237+
would require sharing sensitive information with a server, and constrain its response
238+
accordingly.
239+
240+
### Sampling Parameters
241+
242+
LLM sampling can be fine-tuned with the following parameters:
243+
244+
- `temperature`: Controls randomness in model responses. Higher values produce higher randomness, and lower values produce more stable output.
245+
- `maxTokens`: Maximum tokens to generate; required.
246+
- `stopSequences`: Array of sequences that stop generation.
247+
- `metadata`: Additional provider-specific parameters.
248+
249+
The client **MAY** modify or ignore these fields (except for `maxTokens`) without
250+
communicating this to the server. For example, a client could use a model that does not
251+
support one or more of these parameters, and would therefore be unable to leverage them.
252+
253+
### Result Fields
254+
255+
Sampling results are [message](#messages) objects, and will contain the following fields:
256+
257+
- `role`: The message role; see [Messages](#messages).
258+
- `content`: The message content; see [Messages](#messages).
259+
- `model`: The name of the model that generated the message.
260+
- `stopReason`: The reason why sampling stopped, if known. The specification defines the following (non-exhaustive) stop reasons, although implementations **MAY** provide their own arbitrary values:
261+
- `"endTurn"`: The participant is yielding the conversation to the other party.
262+
- `"stopSequence"`: Message generation encountered one of the requested `stopSequences`.
263+
- `"maxTokens"`: The token limit was reached.
264+
217265
## Error Handling
218266

219267
Clients **SHOULD** return errors for common failure cases:

0 commit comments

Comments
 (0)