Agents can respond to MCP elicitation requests
Key Points
- Agents support MCP elicitation (form and url)
- Register handlers with mcp.configureElicitationHandlers in onStart
- Advertised modes persist through Durable Object hibernation
Summary
Agents connected to MCP servers via addMcpServer can now handle MCP elicitation ↗ requests. Two modes are supported:
- form: collect structured, non-sensitive data from the user
- url: request consent before opening an out-of-band flow (e.g., third‑party auth or payment)
Key Points
- Register handlers in onStart with
this.mcp.configureElicitationHandlers({ form: (req, serverId) => ..., url: (req, serverId) => ... }). Handlers should return a Promise resolving anElicitResult. - Only modes with configured handlers are advertised to the MCP server; an Agent with no handlers advertises no elicitation capability and the server may use a fallback.
- Advertised modes are persisted with each MCP server registration so they survive Durable Object hibernation; callback functions are kept in memory and reattach when
onStart()runs. - Examples: refer to the
mcp-clientandmcp-elicitationexamples for server/client flow and a browser forwarding pattern. - Upgrade: install the latest SDK (e.g.
npm i agents@latest,yarn add agents@latest,pnpm add agents@latest, orbun add agents@latest).
Implementation tip: show the elicitation request in your UI, resolve with accept, decline, or cancel, and for url mode open the URL only after explicit user consent.