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
Copy file name to clipboardExpand all lines: docs/docs/concepts/sampling.mdx
+17-8Lines changed: 17 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: "Sampling"
3
3
description: "Let your servers request completions from client LLMs"
4
4
---
5
5
6
-
Sampling is a powerful MCP feature that allows servers to request LLM completions through the client, enabling sophisticated agentic behaviors such as agent-to-agent communication while maintaining security and privacy.
6
+
Sampling is a powerful MCP feature that allows servers to request LLM completions through the client, enabling sophisticated LLM-enhanced behaviors while maintaining security and privacy.
7
7
8
8
<Info>
9
9
@@ -13,15 +13,16 @@ This feature of MCP is not yet supported in the Claude Desktop client.
13
13
14
14
## Overview
15
15
16
-
Sampling allows an MCP server to request completions from (or "sample") an LLM owned by an MCP client. This enables complex collaborative interactions within other MCP features, such as [tools](/docs/concepts/tools) and [prompts](/docs/concepts/prompts).
16
+
Sampling allows an MCP server to request completions from (or "sample") an LLM controlled by an MCP client.
17
+
This enables servers to leverage an LLM as part of other MCP interactions, such as [tools](/docs/concepts/tools) and [prompts](/docs/concepts/prompts), without needing additional infrastructure or configuration to directly integrate with model providers themselves.
17
18
18
-
Sampling enables agentic patterns such as:
19
+
Sampling flows generally follow these steps:
19
20
20
-
- Negotiating interactions with other LLM-controlled agents
21
-
- Providing interactive assistance to users
22
-
- Making decisions based on context
23
-
- Generating natural language data
24
-
- Handling multi-step tasks
21
+
1. The server sends a `sampling/createMessage` request to the client, containing a prompt and other information
22
+
2. The client reviews the request and may modify it
23
+
3. The client requests the completion from its own LLM
24
+
4. The client reviews the completion
25
+
5. The client responds to the server with the LLM-generated completion
25
26
26
27
## Capabilities
27
28
@@ -42,6 +43,9 @@ Sampling can be a standalone server-initiated interaction, but works best when u
42
43
43
44
### Server
44
45
46
+
This server exposes a single `add` tool which asks the client's LLM for the sum of the two inputs. Upon receiving a response from the client, the server extracts the result and returns the tool call result back to the client.
47
+
In effect, the server has made its own request from the client within that client's existing tool call request.
0 commit comments