Skip to content

Commit bddfe3c

Browse files
committed
docs(elicitation): note picking a mode the client supports
Document that check_client_capability inspects the elicitation form/url sub-capabilities, so a tool can choose a mode the client actually supports before it asks. Companion to the check_capability sub-capability fix.
1 parent a349f2a commit bddfe3c

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

docs/handlers/elicitation.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ Some things must not go through the model or the client: credentials, card numbe
124124

125125
Look at the second tool. When your server learns the out-of-band flow finished (a webhook, a poll; here it's modelled as a second tool), `ctx.session.send_elicit_complete(...)` sends `notifications/elicitation/complete` with the same `elicitation_id`. That is how the client knows it can stop showing *"waiting for payment..."*. Without it, the client can only guess.
126126

127+
## Ask only in a mode the client supports
128+
129+
A client can declare one mode without the other - a terminal that renders a form but has no browser to open a URL, or a kiosk that can only open a URL. `ctx.session.check_client_capability` reads the `form` / `url` sub-capabilities, so a tool can pick a mode the client actually supports before it asks:
130+
131+
```python
132+
from mcp_types import ClientCapabilities, ElicitationCapability, FormElicitationCapability
133+
134+
wants_form = ClientCapabilities(elicitation=ElicitationCapability(form=FormElicitationCapability()))
135+
if ctx.session.check_client_capability(wants_form):
136+
result = await ctx.elicit("Which date?", schema=AlternativeDate)
137+
else:
138+
... # can't ask in form mode - return a sensible default, or send a URL instead
139+
```
140+
141+
A bare `ElicitationCapability()` (no mode set) matches any client that supports elicitation at all, so name a mode only when you need that specific one. This is the same *"what if I can't ask?"* design the client-side check below calls out - now decided per mode.
142+
127143
## The client side
128144

129145
Servers ask. Clients answer by passing an **`elicitation_callback`** to `Client(...)`:

0 commit comments

Comments
 (0)