Elicitation
Elicitation allows MCP tools to request additional information from users during their execution.
Configuration
To enable elicitation, provide anelicitation_callback
function when initializing the MCPClient:
Handler Parameters
The elicitation handler receives two parameters:Elicitation Handler Parameters
Parameter | Type | Description |
---|---|---|
context | RequestContext | Request context containing metadata about the elicitation request |
params | ElicitRequestParams | The MCP elicitation request parameters containing the message and optional schema |
ElicitRequestParams Structure
Field | Type | Description |
---|---|---|
message | str | The prompt message to display to the user |
requestedSchema | dict | None | Optional JSON schema defining the expected response structure |
Response Structure
The handler must return anElicitResult
object that specifies how the user responded:
ElicitResult Structure
Field | Type | Description |
---|---|---|
action | Literal['accept', 'decline', 'cancel'] | How the user responded to the elicitation request |
content | dict | str | None | The user’s input data (required for “accept”, omitted for “decline”/“cancel”) |
Action Types:
- accept: User provided valid input - include their data in the
content
field - decline: User chose not to provide the requested information - omit
content
- cancel: User cancelled the entire operation - omit
content