This example shows how to handle MCP elicitation/create requests from a VoltAgent MCP server while running a VoltAgent generateText call.
- Node.js 18+
- OpenAI API key
pnpm installCopy the example environment file and add your API key:
cp .env.example .envEdit .env:
OPENAI_API_KEY=your_openai_api_key_here
pnpm devFrom the repo root you can also run:
pnpm --filter voltagent-example-with-mcp-elicitation devRequires Go 1.23+ (the Go MCP SDK requires Go 1.23).
Start the Go server:
cd examples/with-mcp-elicitation/go-server
go run .Then run the VoltAgent example pointing at it:
MCP_SERVER_URL=http://localhost:3142/mcp pnpm devThe Go server exposes the customer_delete tool and intentionally sends an empty
elicitation message with a schema description so you can verify the client-side
fallback.
- Starts a VoltAgent MCP server on
http://localhost:3142/mcp/mcp-elicitation-example/mcp. - Registers a
customer_deletetool that requests user confirmation viaelicitation/create. - Runs a VoltAgent
generateTextcall with anelicitationhandler that accepts the request and returns{ confirm: true }.
The console output will show the full elicitation request payload and the final agent response.