How It Works
When a tool needs user input, it can use theContext to send an elicitation request to the client. The client displays the request to the user and returns their response to the tool. The user can accept (provide data), decline (skip), or cancel the operation.
Basic Usage
Use theelicit() method on the context object to request user input:
Structured Input
Define schemas using dataclasses or Pydantic models for structured data collection:Response Actions
Elicitation responses use a three-action model:- accept: User provided valid input - the
datafield contains their response - decline: User chose not to provide the information
- cancel: User cancelled the entire operation
Use Case Example
A task management server that collects task details from users:Important Notes
- The client must provide an
elicitation_callbackto handle elicitation requests - If no callback is configured, elicitation requests will fail
- Use dataclasses or Pydantic models for type-safe structured input
- Handle all three response actions (
accept,decline,cancel) appropriately
Next Steps
- See Context API for more context methods
- Learn about Sampling for requesting LLM completions