Allows MCP servers to request additional information from users.
Elicitation is a powerful feature that allows MCP tools to pause execution and request additional information or confirmation from the user before proceeding. This enables more interactive and controlled tool behavior.
When a tool calls ctx.elicit(), it pauses execution and sends a request to the user. The user can then:
Accept the request by providing the requested information
Decline the request, causing the tool to handle the declined state
Cancel the request, stopping the tool execution
Copy
Ask AI
# In an MCP server toolresult = await ctx.elicit( message="Confirm booking for 2 people on June 21st at 5pm?", schema=ConfirmBooking)match result: case AcceptedElicitation(data=data): # User accepted and provided data if data.confirm: return "Booking confirmed!" case DeclinedElicitation(): # User declined the request return "Booking declined" case CancelledElicitation(): # User cancelled the operation return "Booking cancelled"
When elicitation is triggered, users see an interactive prompt like this:
Copy
Ask AI
ELICITATION RESPONSE NEEDED FROM: demo_serverElicitation RequestConfirm booking for 2 on 2023-06-21T17:00:00?Type / to see available commands──────────────────────────────────────────────Enter confirm - Confirm booking?Type / to see available commandsEnter: true/false, yes/no, y/n, or 1/0>