You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Model Context Protocol (MCP) provides a standardized way for servers to request generations from language models via clients. This unique reverse flow allows clients to maintain control over model access, selection, and permissions while enabling servers to leverage AI capabilities. Servers can request text or image-based interactions and optionally include context from MCP servers in their prompts.
11
+
The Model Context Protocol (MCP) provides a standardized way for servers to request LLM sampling ("completions" or "generations") from language models via clients. This flow allows clients to maintain control over model access, selection, and permissions while enabling servers to leverage AI capabilities—with no server API keys necessary. Servers can request text or image-based interactions and optionally include context from MCP servers in their prompts.
12
12
13
13
## User Interaction Model
14
14
15
-
Sampling in MCP is designed around a human-in-the-loop approval pattern. A recommended implementation exposes sampling requests through an approval UI that allows users to:
15
+
Sampling in MCP allows servers to implement agentic behaviors, by enabling LLM calls to occur _nested_ inside other MCP server features.
16
16
17
-
1. Review incoming sampling requests
18
-
2. Inspect model selections and parameters
19
-
3. View and edit prompts before sending
20
-
4. Review generated responses before delivery
17
+
Implementations are free to expose sampling through any interface pattern that suits their needs—the protocol itself does not mandate any specific user interaction model.
21
18
22
-
However, implementations are free to expose sampling through any interface pattern that suits their needs - the protocol itself does not mandate any specific user interaction model.
19
+
{{< callout type="warning" >}}
20
+
For trust & safety and security, there **SHOULD** always be a human in the loop with the ability to deny sampling requests.
21
+
22
+
Applications **SHOULD**:
23
+
* Provide UI that makes it easy and intuitive to review sampling requests
24
+
* Allow users to view and edit prompts before sending
25
+
* Present generated responses for review before delivery
26
+
{{< /callout >}}
23
27
24
28
## Capabilities
25
29
26
-
Clients that support sampling MUST include a`sampling` capability in their `ClientCapabilities` during initialization:
30
+
Clients that support sampling **MUST** declare the`sampling` capability during [initialization]({{< ref "/specification/basic/lifecycle#initialization" >}}):
27
31
28
32
```json
29
33
{
@@ -33,8 +37,6 @@ Clients that support sampling MUST include a `sampling` capability in their `Cli
33
37
}
34
38
```
35
39
36
-
The empty object indicates basic sampling support with no additional features.
37
-
38
40
## Protocol Messages
39
41
40
42
### Creating Messages
@@ -67,8 +69,7 @@ To request a language model generation, servers send a `sampling/createMessage`
67
69
"speedPriority": 0.5
68
70
},
69
71
"systemPrompt": "You are a helpful assistant.",
70
-
"maxTokens": 100,
71
-
"temperature": 0.7
72
+
"maxTokens": 100
72
73
}
73
74
}
74
75
```
@@ -151,18 +152,18 @@ To solve this, MCP implements a preference system that combines abstract capabil
151
152
152
153
Servers express their needs through three normalized priority values (0-1):
153
154
154
-
-`costPriority`: How important is minimizing costs? Higher values prefer cheaper models
155
-
-`speedPriority`: How important is low latency? Higher values prefer faster models
156
-
-`intelligencePriority`: How important are advanced capabilities? Higher values prefer more capable models
155
+
-`costPriority`: How important is minimizing costs? Higher values prefer cheaper models.
156
+
-`speedPriority`: How important is low latency? Higher values prefer faster models.
157
+
-`intelligencePriority`: How important are advanced capabilities? Higher values prefer more capable models.
157
158
158
159
#### Model Hints
159
160
160
161
While priorities help select models based on characteristics, `hints` allow servers to suggest specific models or model families:
161
162
162
163
- Hints are treated as substrings that can match model names flexibly
163
164
- Multiple hints are evaluated in order of preference
164
-
- Clients MAY map hints to equivalent models from different providers
165
-
- Hints are advisory - clients make final model selection
165
+
- Clients **MAY** map hints to equivalent models from different providers
166
+
- Hints are advisory—clients make final model selection
0 commit comments