MCP Elicitations in Spring AI: Request Missing Information from Users

Dan Vega

Dan Vega

3,833 views

What happens when your MCP tool gets called but the user didn't provide all the required information? Before elicitations, it would simply fail. Now there's a better way.

In this tutorial, you'll learn how to implement MCP Elicitations in Spring AI, a standardized approach for servers to request additional information from users during an interaction. We'll build a complete coffee shop ordering system where the MCP server dynamically asks for missing details like coffee size, type, and milk preference.

🎯 What You'll Learn:
• Understanding elicitations in the MCP specification (form mode vs URL mode)
• Building an MCP server with elicitation support using Spring Boot
• Creating tool parameters with the @MCPTool and @MCPToolParams annotations
• Testing elicitations in the MCP Inspector
• Building a Spring AI client with the @MCPElicitation annotation
• Handling elicitation requests and responses in a real application

📚 Resources:
GitHub Repository: https://github.com/danvega/spring-ai-...
MCP Elicitations Docs: https://modelcontextprotocol.io/docs/...
Spring AI Reference: https://docs.spring.io/spring-ai/refe...
Spring Initializr: https://start.spring.io

👋🏻Connect with me:
Website: https://www.danvega.dev
Twitter: Twitter: therealdanvega
Github: https://github.com/danvega
LinkedIn: LinkedIn: danvega
Newsletter: https://www.danvega.dev/newsletter

SUBSCRIBE TO MY CHANNEL: http://bit.ly/2re4GH0 ❤️