Provides Spring Boot MCP server patterns that create Model Context Protocol servers with Spring AI by defining tool handlers, exposing resources, configuring prompt templates, and setting up transports for AI function calling and tool calling. Use when building MCP servers to extend AI capabilities with Spring's official AI framework, implementing AI tools, custom function calling, or MCP client integration.
This skill provides production-ready patterns for building Model Context Protocol (MCP) servers with Spring Boot and Spring AI. It solves the problem of exposing Java application capabilities as AI-callable tools, resources, and prompt templates by documenting the canonical annotations, transport configuration, and architectural patterns for AI function/tool calling using Spring's official AI framework.
The skill covers core annotations (@EnableMcpServer, @Tool, @ToolParam, @PromptTemplate, @PromptParam), the three transport types (stdio for local/Claude Desktop, http, and sse for streaming), and Maven/Gradle dependency setup. Step-by-step instructions show project setup with API keys pulled from environment variables, defining @Tool methods inside @Component beans, and building reusable prompt templates. A rich set of reference files goes further into advanced patterns — dynamic runtime tool registration, multi-model selection across OpenAI and Anthropic, caching with Spring's cache abstraction, and security. Notably, the security-oriented examples demonstrate a SecureToolExecutor that authenticates and authorizes callers via Spring Security before running a tool, Bean Validation on tool inputs, and defensive argument checks, alongside examples.md, migration-guide.md, api-reference.md, and testing-guide.md.
It targets Java and Spring developers building MCP servers to extend AI assistants with custom tools, implementing function calling, or integrating MCP clients. The advanced dynamic-registration examples include dispatching to Groovy scripts, Spring beans, or HTTP endpoints, which are legitimate extensibility patterns but warrant care when the registration inputs are externally controlled; the reference pairs them with authentication, authorization, and input-validation guidance.
MCP (Model Context Protocol) servers using Spring Boot and Spring AI — defining tool handlers with @Tool, exposing resources, configuring @PromptTemplate prompt templates, and setting up stdio/HTTP/SSE transports for AI function and tool calling.
Annotations like @EnableMcpServer to enable the server, @Tool/@ToolParam to declare AI-callable methods and document parameters, and @PromptTemplate/@PromptParam for reusable prompts, all inside Spring @Component beans.
The examples reference model API keys from environment variables (e.g. spring.ai.openai.api-key=${OPENAI_API_KEY}, or System.getenv for OpenAI/Anthropic keys), keeping secrets out of source.
Yes. Advanced patterns include a SecureToolExecutor that checks Spring Security authentication and per-tool permissions before execution, Bean Validation (@Valid) on tool inputs, argument validation, and audit logging.
stdio for local processes and Claude Desktop, http for remote HTTP clients, and sse for real-time streaming clients, configured via port and path.
Quick Setup:
.claude/skills/Repository
giuseppe-trisciuoglio/developer-kit