spring-ai-mcp-server-patterns
Model Context Protocol (MCP) server implementation patterns with Spring AI. Use when building MCP servers to extend AI capabilities with custom tools, resources, and prompt templates using Spring's official AI framework.
npx skills add majiayu000/claude-skill-registry --skill spring-ai-mcp-server-patterns --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
This skill provides patterns and code examples to implement Model Context Protocol (MCP) servers using Spring AI. It outlines how to declare callable functions as tools, define prompts, configure transport channels, and wire up MCP server auto-configuration in Spring Boot. It includes basic example components for tools, function callbacks, and prompt templates, plus configuration blocks for Maven/Gradle dependencies and application properties. It also covers security hooks, health indicators, and custom server configuration hooks for advanced behavior.
How it works
- Uses @Tool to declare methods as callable functions for AI models and @ToolParam/@PromptTemplate to document and structure inputs.
- Demonstrates a Tool Creation pattern where components expose safe read queries and metadata like table schemas, including input validation (e.g., ensuring only SELECT queries).
- Shows an Advanced Tool Pattern with a WebClient-based HTTP tool, including URL validation and optional headers parsing from JSON.
- Provides Prompt Template Pattern examples with @PromptTemplate and @PromptParam to create reusable prompts (e.g., Java code review prompts and test generation prompts).
- Introduces a FunctionCallback setup to register getCurrentWeather and calculator-like functions, enabling the MCP server to expose these as tools.
- Details Spring Boot auto-configuration for MCP server, wiring in function callbacks and prompt templates via Spring beans, and optional health indicators.
- Includes MCP server properties and application properties guidance, with transport types (STDIO, HTTP, SSE) and port/path options.
- Includes a Custom Server Configuration example demonstrating interceptors, tool execution timing, and basic security hooks.
- Outlines security patterns using Spring Security foundations to validate authentication and tool permissions before execution.
When to use it
Use this skill when building:
- AI applications requiring external tool integration with Spring AI
- Enterprise MCP servers with Spring ecosystem integration
- Function calling servers with Spring AI's declarative patterns
- Prompt template servers for standardized AI interactions
- Spring Boot applications with native MCP integration
- Production-ready MCP servers with Spring Security and monitoring
- Microservices that expose AI capabilities via MCP protocol
- Hybrid systems using both Spring AI and traditional Spring components
What it can touch
- Tools declared with @Tool in Spring components (e.g., DatabaseTools.executeQuery, ApiTools.callApi).
- Prompt templates declared with @PromptTemplate (e.g., CodeReviewPrompts).
- FunctionCallback and PromptTemplate beans registered in McpServer setup.
- Spring Security context for authentication and authorization during tool execution.
- MCP server configuration via McpServerProperties, application.yml, and customizers.
Caveats
- Depicts integration patterns and code examples; actual behavior depends on concrete project setup and environment.
- Certain sections require real implementations for data access, HTTP requests, and security logic beyond examples.
- License is MIT per skill metadata; ensure compliance in production.
# Spring AI MCP Server Implementation Patterns Implement Model Context Protocol (MCP) servers with Spring AI to extend AI capabilities with standardized tools, resources, and prompt templates using Spring's native AI abstractions. ## When to Use Use this skill when building: - AI applications requiring external tool integration with Spring AI - Enterprise MCP servers with Spring ecosystem integration - Function calling servers with Spring AI's declarative patterns - Prompt template servers for standardized AI interactions - Spring Boot applications with native MCP integration - Production-ready MCP servers with Spring Security and monitoring - Microservices that expose AI capabilities via MCP protocol - Hybrid systems using both Spring AI and traditional Spring components ## Quick Start ### Basic MCP Server with Spring AI Create a simple MCP server with function calling: ```java @SpringBootApplication @EnableMcpServer public class WeatherMcpApplication { public static void main(String[] args) { SpringApplication.run(WeatherMcpApplication.class, args); } } @Component public class WeatherTools { @Tool(description = "Get current weather for a city") public WeatherData getWeather(@Tool
- When to Use
- Quick Start
- Basic MCP Server with Spring AI
- Function Calling Setup
- Build Configuration
- Core Concepts
- MCP Architecture with Spring AI
- Key Spring AI Components
- Implementation Patterns
- Tool Creation Pattern
- Advanced Tool Pattern with Validation
- Prompt Template Pattern
- Function Callback Pattern
- Spring Boot Integration
What does the spring-ai-mcp-server-patterns skill do?
Model Context Protocol (MCP) server implementation patterns with Spring AI. Use when building MCP servers to extend AI capabilities with custom tools, resources, and prompt templates using Spring's official AI framework.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill spring-ai-mcp-server-patterns --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
