|
| 1 | +--- |
| 2 | +title: "Elicitation" |
| 3 | +description: "Let your servers request additional information from users" |
| 4 | +--- |
| 5 | + |
| 6 | +Elicitation is a powerful MCP feature that allows servers to request additional information directly from users through the client, enabling interactive workflows while maintaining security and privacy controls. |
| 7 | + |
| 8 | +<Info> |
| 9 | + This feature of MCP is not yet supported in the Claude Desktop client. |
| 10 | +</Info> |
| 11 | + |
| 12 | +## How elicitation works |
| 13 | + |
| 14 | +The elicitation flow follows these steps: |
| 15 | + |
| 16 | +1. Server sends an `elicitation/create` request to the client |
| 17 | +2. Client presents the request to the user |
| 18 | +3. User provides the requested information |
| 19 | +4. Client reviews and can modify the response |
| 20 | +5. Client returns the result to the server |
| 21 | + |
| 22 | +This human-in-the-loop design ensures users maintain control over what information they share with servers. |
| 23 | + |
| 24 | +## Message format |
| 25 | + |
| 26 | +Elicitation requests use a standardized message format: |
| 27 | + |
| 28 | +```typescript |
| 29 | +{ |
| 30 | + message: string |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +The response format is: |
| 35 | + |
| 36 | +```typescript |
| 37 | +{ |
| 38 | + content: [ |
| 39 | + { |
| 40 | + type: "text" | "image" | "audio", |
| 41 | + |
| 42 | + // For text: |
| 43 | + text?: string, |
| 44 | + |
| 45 | + // For images: |
| 46 | + data?: string, // base64 encoded |
| 47 | + mimeType?: string, |
| 48 | + |
| 49 | + // For audio: |
| 50 | + data?: string, // base64 encoded |
| 51 | + mimeType?: string |
| 52 | + }, |
| 53 | + // Additional content items... |
| 54 | + ], |
| 55 | + cancelled?: boolean |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +## Request parameters |
| 60 | + |
| 61 | +### Message |
| 62 | + |
| 63 | +The `message` field contains the text prompt to present to the user, explaining what information is being requested and why. |
| 64 | + |
| 65 | +## Response format |
| 66 | + |
| 67 | +The client returns an elicitation result with: |
| 68 | + |
| 69 | +- `content`: An array of the user's responses, which can include: |
| 70 | + - Text content with a `text` field |
| 71 | + - Image content with `data` (base64) and `mimeType` fields |
| 72 | + - Audio content with `data` (base64) and `mimeType` fields |
| 73 | +- `cancelled`: Optional boolean indicating if the user cancelled the request |
| 74 | + |
| 75 | +The content array allows clients to return multiple response items of different types, such as text with an accompanying image. |
| 76 | + |
| 77 | +## Example requests |
| 78 | + |
| 79 | +### Basic elicitation |
| 80 | + |
| 81 | +```json |
| 82 | +{ |
| 83 | + "method": "elicitation/create", |
| 84 | + "params": { |
| 85 | + "message": "What is your favorite programming language?" |
| 86 | + } |
| 87 | +} |
| 88 | +``` |
| 89 | + |
| 90 | +### Example response with multiple content items |
| 91 | + |
| 92 | +```json |
| 93 | +{ |
| 94 | + "result": { |
| 95 | + "content": [ |
| 96 | + { |
| 97 | + "type": "text", |
| 98 | + "text": "Python" |
| 99 | + }, |
| 100 | + { |
| 101 | + "type": "image", |
| 102 | + "data": "base64-encoded-image-data", |
| 103 | + "mimeType": "image/png" |
| 104 | + } |
| 105 | + ] |
| 106 | + } |
| 107 | +} |
| 108 | +``` |
| 109 | + |
| 110 | +## Best practices |
| 111 | + |
| 112 | +When implementing elicitation: |
| 113 | + |
| 114 | +1. Provide clear, concise messages explaining what information is needed and why |
| 115 | +2. Only request information that is necessary for the task |
| 116 | +3. Handle all response types appropriately (text, image, audio) |
| 117 | +4. Respect user privacy and data minimization principles |
| 118 | +5. Consider returning multiple content items when appropriate |
| 119 | +7. Validate responses before using them |
| 120 | +8. Handle cancellations gracefully |
| 121 | +9. Consider progressive disclosure for complex information requests |
| 122 | +10. Document expected elicitation behavior |
| 123 | + |
| 124 | +## Human in the loop controls |
| 125 | + |
| 126 | +Elicitation is designed with user agency in mind: |
| 127 | + |
| 128 | +### For requests |
| 129 | + |
| 130 | +- Clients should clearly show which server is requesting information |
| 131 | +- Users should be able to modify or reject requests |
| 132 | +- Clients can filter or block inappropriate requests |
| 133 | +- Users should understand why the information is being requested |
| 134 | + |
| 135 | +### For responses |
| 136 | + |
| 137 | +- Users should be able to review their responses before sending |
| 138 | +- Clients should provide clear UI for structured data input |
| 139 | +- Users should be able to cancel requests at any time |
| 140 | +- Clients can sanitize or modify responses to protect privacy |
| 141 | + |
| 142 | +## Security considerations |
| 143 | + |
| 144 | +When implementing elicitation: |
| 145 | + |
| 146 | +- Validate all message content |
| 147 | +- Sanitize sensitive information |
| 148 | +- Implement appropriate rate limits |
| 149 | +- Monitor elicitation usage |
| 150 | +- Encrypt data in transit |
| 151 | +- Handle user data privacy |
| 152 | +- Audit elicitation requests |
| 153 | +- Implement timeouts |
| 154 | +- Provide clear privacy policies |
| 155 | +- Allow users to opt out |
| 156 | + |
| 157 | +## Common patterns |
| 158 | + |
| 159 | +### Interactive workflows |
| 160 | + |
| 161 | +Elicitation enables interactive patterns like: |
| 162 | + |
| 163 | +- Progressive form filling |
| 164 | +- Multi-step data collection |
| 165 | +- Contextual information gathering |
| 166 | +- Clarification of ambiguous requests |
| 167 | +- Confirmation of critical actions |
| 168 | + |
| 169 | +### Multiple content items |
| 170 | + |
| 171 | +Best practices for handling multiple content items: |
| 172 | + |
| 173 | +- Consider when multiple items enhance the response |
| 174 | +- Organize content items in a logical order |
| 175 | +- Handle cases where clients may only support a subset of content types |
| 176 | +- Validate each content item individually |
| 177 | + |
| 178 | +### Error handling |
| 179 | + |
| 180 | +Robust error handling should: |
| 181 | + |
| 182 | +- Catch validation failures |
| 183 | +- Handle timeout errors |
| 184 | +- Manage rate limits |
| 185 | +- Provide helpful error messages |
| 186 | +- Support retries when appropriate |
| 187 | +- Log errors appropriately |
| 188 | + |
| 189 | +## Limitations |
| 190 | + |
| 191 | +Be aware of these limitations: |
| 192 | + |
| 193 | +- Elicitation depends on client capabilities |
| 194 | +- Not all clients support multiple content items |
| 195 | +- Users control what information they provide |
| 196 | +- Response formats may be limited |
| 197 | +- Rate limits may apply |
| 198 | +- User experience varies by client |
| 199 | +- Response times depend on user interaction |
| 200 | +- Not all content types may be supported by all clients |
0 commit comments