|
1 | 1 | # Elicitation |
| 2 | + |
| 3 | +Modern AI applications often need to collect structured input from users at key moments in a workflow. **Elicitation** in the Model Context Protocol (MCP) standardizes this process, allowing servers to request information from users through the client, using a well-defined schema and a secure, user-friendly interaction model. |
| 4 | + |
| 5 | +Elicitation enables interactive workflows like confirming destructive actions, collecting additional details, or guiding users through multi-step forms by letting the server pause and ask the user for exactly what it needs, in a structured way. |
| 6 | + |
| 7 | +<callout-info> |
| 8 | + Elicitation requests are always initiated by the server (so you need a |
| 9 | + persistent connection), but the client controls the user experience. The |
| 10 | + protocol does not mandate a specific UI, so clients can present prompts as |
| 11 | + dialogs, forms, or any interface that fits their platform. |
| 12 | +</callout-info> |
| 13 | + |
| 14 | +## User Interaction Model |
| 15 | + |
| 16 | +When an MCP server needs more information, it sends an `elicitation/create` request to the client, specifying: |
| 17 | + |
| 18 | +- A **message** to display to the user (e.g., "What is your preferred delivery window?") |
| 19 | +- A **requestedSchema** (using a restricted JSON Schema) describing the expected input (e.g., a string `deliveryWindow` field with enum options) |
| 20 | + |
| 21 | +The client presents this to the user, who can: |
| 22 | + |
| 23 | +- **Accept** (provide the requested data) |
| 24 | +- **Decline** (explicitly refuse) |
| 25 | +- **Cancel** (dismiss without a choice) |
| 26 | + |
| 27 | +The server must handle all three outcomes appropriately. |
| 28 | + |
| 29 | +<callout-success> |
| 30 | + Elicitation is designed for trust and safety. Servers **must not** use it to |
| 31 | + request sensitive information. Clients should always make it clear which |
| 32 | + server is requesting input, and users should be able to review, modify, or |
| 33 | + decline any request. |
| 34 | +</callout-success> |
| 35 | + |
| 36 | +## Example: Pizza Order Customization |
| 37 | + |
| 38 | +Imagine an online pizza ordering system. After a user selects their pizza and toppings, the server wants to know if they'd like to add a drink to their order. Instead of assuming or cluttering the main UI, the server uses elicitation: |
| 39 | + |
| 40 | +1. The user submits their pizza order. |
| 41 | +2. The server sends an `elicitation/create` request: |
| 42 | + |
| 43 | +```json |
| 44 | +{ |
| 45 | + "jsonrpc": "2.0", |
| 46 | + "id": 1, |
| 47 | + "method": "elicitation/create", |
| 48 | + "params": { |
| 49 | + "message": "Would you like to add a drink to your order?", |
| 50 | + "requestedSchema": { |
| 51 | + "type": "object", |
| 52 | + "properties": { |
| 53 | + "drink": { |
| 54 | + "type": "string", |
| 55 | + "title": "Drink Selection", |
| 56 | + "description": "Choose a drink to add to your order", |
| 57 | + "enum": ["None", "Cola", "Lemonade", "Water"], |
| 58 | + "enumNames": ["No drink", "Cola", "Lemonade", "Water"] |
| 59 | + } |
| 60 | + }, |
| 61 | + "required": ["drink"] |
| 62 | + } |
| 63 | + } |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +The client presents this to the user, who can: |
| 68 | + |
| 69 | +- **Accept** (provide the requested data) |
| 70 | +- **Decline** (explicitly refuse) |
| 71 | +- **Cancel** (dismiss without a choice) |
| 72 | + |
| 73 | +Here's what the response from the client might look like: |
| 74 | + |
| 75 | +```json |
| 76 | +{ |
| 77 | + "jsonrpc": "2.0", |
| 78 | + "id": 1, |
| 79 | + "result": { |
| 80 | + "action": "accept", // or "decline" or "cancel" |
| 81 | + "content": { |
| 82 | + "drink": "Cola" |
| 83 | + } |
| 84 | + } |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +If the user selects a drink, it's added to the order. If they choose "None" or decline, the order proceeds without a drink. |
| 89 | + |
| 90 | +For more details, see the [MCP Elicitation Spec](https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation). |
| 91 | + |
| 92 | +## Sequence Diagram |
| 93 | + |
| 94 | +```mermaid |
| 95 | +sequenceDiagram |
| 96 | + participant User |
| 97 | + participant HostApp |
| 98 | + participant LLM |
| 99 | + participant Client |
| 100 | + participant Server |
| 101 | +
|
| 102 | + User->>HostApp: Submit pizza order prompt |
| 103 | + HostApp->>LLM: Forward prompt |
| 104 | + LLM->>HostApp: Decide to call tool (pizza_order) |
| 105 | + HostApp->>Client: Submit tool call |
| 106 | + Client->>Server: Forward tool call |
| 107 | + Server->>Client: Elicitation request (add drink?) |
| 108 | + Client->>HostApp: Forward elicitation request |
| 109 | + HostApp->>User: Present elicitation prompt |
| 110 | + User->>HostApp: Make selection (accept/decline/cancel) |
| 111 | + HostApp->>Client: Forward selection |
| 112 | + Client->>Server: Forward selection |
| 113 | +``` |
| 114 | + |
| 115 | +## Recommended Practices |
| 116 | + |
| 117 | +- Use clear, concise messages for elicitation prompts. |
| 118 | +- Design schemas with only the fields you truly need (avoid requesting sensitive info). |
| 119 | +- Always handle accept, decline, and cancel actions. |
| 120 | + |
| 121 | +## References |
| 122 | + |
| 123 | +- π [MCP Elicitation Spec](https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation) |
| 124 | +- π [Elicitation Concepts](https://modelcontextprotocol.io/docs/concepts/elicitation) |
| 125 | +- π [MCP Elicitations: Standardizing Interactive AI Workflows](https://blog.fka.dev/blog/2025-01-15-mcp-elicitations-standardizing-interactive-ai-workflows/) |
0 commit comments