Fix stale MRTR/elicitation framing in client and upgrade docs (#4551)

This commit is contained in:
Jeremiah Lowin 2026-07-19 18:10:15 -04:00 committed by GitHub
commit eee5e91334
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 8 deletions

View file

@ -543,7 +543,9 @@ If you need to support both eras, branch on `ctx.protocol_version`: return an `I
### Sampling and roots
Elicitation is the most common request to carry this way, but the same mechanism carries **sampling** and **roots** requests too — the `input_requests` map can hold any of the three, and each answer comes back in `ctx.input_responses` under its key (an `ElicitResult`, `CreateMessageResult`, or `ListRootsResult`). See [Sampling](/servers/sampling) and [Client Roots](/clients/roots) for what those requests contain. `fastmcp.Client` answers all three from the handlers you already configured, so a guard tool that mixes them needs no extra client wiring.
Elicitation is the most common request to carry this way, and **roots** requests work identically — the `input_requests` map holds them the same way, and each answer comes back in `ctx.input_responses` under its key (an `ElicitResult` or `ListRootsResult`). See [Client Roots](/clients/roots) for what a roots request contains. `fastmcp.Client` answers both from the handlers you already configured, so a guard tool that mixes them needs no extra client wiring.
The map can structurally hold a **sampling** request too (its answer would be a `CreateMessageResult`), but SEP-2577 deprecated server-initiated sampling on the modern protocol, so reach for a direct server-side LLM call instead of routing generation through a guard round. See [Sampling](/servers/sampling).
### Middleware

View file

@ -24,7 +24,7 @@ answer.
</Warning>
<Note>
This page covers `ctx.sample()`, which requests generation over the handshake-era back-channel. On the modern protocol (2026-07-28) a tool can instead request a sampling round from the client as part of a multi-round guard call — the same mechanism that carries elicitation. See [Elicitation on the modern protocol](/servers/elicitation#elicitation-on-the-modern-protocol) for how a guard tool returns `input_requests` and reads the answers back off `ctx.input_responses`.
This page covers `ctx.sample()`, which requests generation over the handshake-era back-channel. The modern protocol's guard mechanism can structurally carry a sampling request in its `input_requests` map, but SEP-2577 deprecated server-initiated sampling as a pattern rather than only the `ctx.sample()` spelling of it, so that is not a supported migration path. Use the guard mechanism for [elicitation](/servers/elicitation#elicitation-on-the-modern-protocol) and roots, and call an LLM directly from your server for generation.
</Note>
LLM sampling allows your MCP tools to request text generation from an LLM during execution. This enables tools to leverage AI capabilities for analysis, generation, reasoning, and more—without the client needing to orchestrate multiple calls.