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/sampling_context_guide.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Below are answers to common questions about using these components.
10
10
11
11
### 1. How can I access the LLM(s) available to the client directly, rather than making an explicit call?
12
12
13
-
**You cannot access the client's LLM directly.**
13
+
**You cannot access the client's LLM directly.**
14
14
15
15
The Model Context Protocol is designed so that the client securely controls access to its LLMs. Servers cannot bypass the protocol to access the LLM directly. You must make an explicit sampling request by calling `create_message` on the active session, allowing the client to execute the inference on your behalf.
16
16
@@ -49,6 +49,7 @@ The client will prioritize `hints` (matching as a substring). If multiple models
49
49
The `RequestContext` (typically `ServerRequestContext` or `Context` in the Python SDK) is a **server-side** object. It is *not* used to directly send context to the LLM.
50
50
51
51
Instead, the `RequestContext` gives your server handler access to the active connection's session. To pass context to the LLM, you should:
52
+
52
53
1. Retrieve the session from the context (`ctx.session`).
53
54
2. Include the context in your sampling prompt by adding it to the `messages` list in the `create_message` call.
54
55
3. Use the `include_context` argument to instruct the client to append its own context.
@@ -58,6 +59,7 @@ Instead, the `RequestContext` gives your server handler access to the active con
58
59
The `include_context` parameter dictates the **scope** of MCP-server context that the client should automatically attach to the sampling prompt, but it **cannot be used for granular filtering**.
59
60
60
61
You can pass one of three values:
62
+
61
63
-`"none"` (Default): No implicit context is added. The LLM only sees the messages you explicitly provided.
62
64
-`"thisServer"`: The client automatically includes recent interactions and context specifically related to your server (e.g., recent tool results or resources from this server).
63
65
-`"allServers"`: The client includes context from all servers connected to it.
0 commit comments