feat(mcp): adding elicitation spec to 'MCPClient'
Background
As requested in #7978
For elicitation specs, refer here
Summary
Updated the spec so that createMCPClient has a elicitation handler. It now supports requests that the server might make to the client.
Manual Verification
- [x] e2e example for testing, with a UI modal for sending user's preferences
- [x] console example
- [x] unit tests
Checklist
- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A patch changeset for relevant packages has been added (for bug fixes / features - run
pnpm changesetin the project root)
Related Issues
Fixes #7978
Is there any way to share what format things like date/time/duration should be provided
=== Elicitation Request ===
Step 1: Enter basic event information
Schema: {
"type": "object",
"properties": {
"title": {
"type": "string",
"title": "Event Title",
"description": "Name of the event",
"minLength": 1
},
"description": {
"type": "string",
"title": "Description",
"description": "Event description (optional)"
}
},
"required": [
"title"
]
}
Action (accept/decline/cancel) [accept]: accept
Event Title (required): test title
Description (optional):
=== Elicitation Request ===
Step 2: Enter date and time
Schema: {
"type": "object",
"properties": {
"date": {
"type": "string",
"title": "Date",
"description": "Event date"
},
"startTime": {
"type": "string",
"title": "Start Time",
"description": "Event start time (HH:MM)"
},
"duration": {
"type": "integer",
"title": "Duration",
"description": "Duration in minutes",
"minimum": 15,
"maximum": 480
}
},
"required": [
"date",
"startTime",
"duration"
]
}
Action (accept/decline/cancel) [accept]: accept
Date (required): 2025-12-12
Start Time (required): 12:00:00
Duration (required): 0
TOOL RESULTS: [
{
"type": "tool-result",
"toolCallId": "call_02yIVAMEQWCTA5QIfKhUdF6M",
"toolName": "create_event",
"input": {},
"output": {
"content": [
{
"type": "text",
"text": "Event creation failed: MCP error -32602: Elicitation response content does not match requested schema: data.duration should be >= 15"
}
],
"isError": true
},
"dynamic": true
}
]
I tried the next-openai demo but nothing happens? I don't see any errors in the logs
GET /mcp-elicitation 200 in 496ms
○ Compiling /api/mcp-elicitation ...
✓ Compiled /api/mcp-elicitation in 1480ms (2799 modules)
POST /api/mcp-elicitation 200 in 1630ms
updated the PR to address all comments and added docs.
--
I tried the next-openai demo but nothing happens? I don't see any errors in the logs
@gr2m you will need to start the MCP server in another terminal to run the UI example. Apologies for unclear instructions before, you can refer the README.md on how to run the example
✅ Backport PR created: https://github.com/vercel/ai/pull/10555