Agent skill

Spring AI MCP Server Patterns

by giuseppe-trisciuoglio in giuseppe-trisciuoglio/developer-kit

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…

MITAuto-check: notesAgent Workflows

Install Spring AI MCP Server Patterns

skills CLI
$ npx skills add giuseppe-trisciuoglio/developer-kit --skill spring-ai-mcp-server-patterns -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install giuseppe-trisciuoglio/developer-kit spring-ai-mcp-server-patterns --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/giuseppe-trisciuoglio/developer-kit.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/developer-kit-java/skills/spring-ai-mcp-server-patterns .claude/skills/spring-ai-mcp-server-patterns && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
spring-ai-mcp-server-patterns
GitHub stars
357
Token cost
~2.7k tokens
SKILL.md length
589 words
Files
8 (incl. references)
Skills in repo
115
Repo updated
First seen
Licence
MIT

At a glance

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…

  • Works in 6 steps: Project Setup → Define Tools → Create Prompt Templates → …
  • Building MCP servers to extend AI capabilities with Springs official AI framework
  • SKILL.md covers Overview, When to Use, Quick Reference and Instructions, plus 4 more sections
  • Runs Java scripts from its folder; needs OPENAI_API_KEY

What it does

Spring AI MCP Server Patterns is an agent skill from giuseppe-trisciuoglio/developer-kit. 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.

Its SKILL.md is about 2.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 9 other files, including reference files (for example `references/advanced-patterns.md`, `references/api-reference.md` and `references/examples.md`).

It sits in Agent Workflows, covering MCP servers, Structured output and tool calling and Prompt engineering. It works with Model Context Protocol and Spring Boot. The repository describes itself as: Modular plugin marketplace for Claude Code and agentic CLIs, with validated, spec-driven skills, agents, commands, and workflows for Java, TypeScript, Python, PHP, AWS, and AI. The licence is MIT.

When your agent uses it

  • Building MCP servers to extend AI capabilities with Springs official AI framework
  • Implementing AI tools
  • Custom function calling
  • MCP client integration

Example prompts

  • “Use the spring-ai-mcp-server-patterns skill to provide Spring Boot MCP server patterns that create Model Context Protocol servers with Spring AI by…”
  • “/spring-ai-mcp-server-patterns”

Requirements

  • A credential in OPENAI_API_KEY
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Bash, Glob, Grep

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. Project Setup
  2. Define Tools
  3. Create Prompt Templates
  4. Configure Transport
  5. Add Security
  6. Testing

What it can do on your machine

Read from SKILL.md and the folder at commit fe73fb3. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Bash
    • Glob
    • Grep

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (Java), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • OPENAI_API_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Spring AI MCP Server Patterns loads about 2.7k tokens when it runs, and up to ~38k if it reads all its reference files. Until then it costs about 110 tokens; SKILL.md has 589 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~110
When it runs · the whole SKILL.md, loaded when a task matches
~2.7k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~38k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Read, Write, Edit, Bash, Glob, Grep

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from giuseppe-trisciuoglio/developer-kit at commit fe73fb3, republished under its MIT licence (© giuseppe-trisciuoglio). 589 words, ~2,670 tokens.

Download SKILL.mdSave it as .claude/skills/spring-ai-mcp-server-patterns/SKILL.md (or your agent's skills folder). This skill also uses 7 other files; get the full folder from GitHub.
name
spring-ai-mcp-server-patterns
description
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.
allowed-tools
Read, Write, Edit, Bash, Glob, Grep

Spring AI MCP Server Implementation Patterns

Implements MCP servers with Spring AI for AI function calling, tool handlers, and MCP transport configuration.

Overview

Production-ready MCP server patterns: @Tool functions, @PromptTemplate resources, and stdio/HTTP/SSE transports with Spring AI security.

When to Use

MCP servers, Spring AI function calling, AI tools, tool calling, custom tool handlers, Spring Boot MCP, resource endpoints, or MCP transport configuration.

Quick Reference

Core Annotations
AnnotationTargetPurpose
@EnableMcpServerClassEnable MCP server auto-configuration
@Tool(description)MethodDeclare AI-callable tool
@ToolParam(value)ParameterDocument tool parameter for AI
@PromptTemplate(name)MethodDeclare reusable prompt template
@PromptParam(value)ParameterDocument prompt parameter
Transport Types
TransportUse CaseConfig
stdioLocal process / Claude DesktopDefault
httpRemote HTTP clientsport, path
sseReal-time streaming clientsport, path
Key Dependencies
xml
<!-- Maven -->
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-mcp-server</artifactId>
    <version>1.0.0</version>
</dependency>
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-starter-model-openai</artifactId>
    <version>1.0.0</version>
</dependency>
gradle
// Gradle
implementation 'org.springframework.ai:spring-ai-mcp-server:1.0.0'
implementation 'org.springframework.ai:spring-ai-starter-model-openai:1.0.0'

Instructions

1. Project Setup

Add Spring AI MCP dependencies (see Quick Reference above), configure the AI model in application.properties, and enable MCP with @EnableMcpServer:

java
@SpringBootApplication
@EnableMcpServer
public class MyMcpApplication {
    public static void main(String[] args) {
        SpringApplication.run(MyMcpApplication.class, args);
    }
}
properties
spring.ai.openai.api-key=${OPENAI_API_KEY}
spring.ai.mcp.enabled=true
spring.ai.mcp.transport.type=stdio
2. Define Tools

Annotate methods with @Tool inside @Component beans. Use @ToolParam to document parameters:

java
@Component
public class WeatherTools {

    @Tool(description = "Get current weather for a city")
    public WeatherData getWeather(@ToolParam("City name") String city) {
        return weatherService.getCurrentWeather(city);
    }

    @Tool(description = "Get 5-day forecast for a city")
    public ForecastData getForecast(
            @ToolParam("City name") String city,
            @ToolParam(value = "Unit: celsius or fahrenheit", required = false) String unit) {
        return weatherService.getForecast(city, unit != null ? unit : "celsius");
    }
}

See references/implementation-patterns.md for database tools, API integration tools, and the FunctionCallback low-level pattern.

3. Create Prompt Templates
java
@Component
public class CodeReviewPrompts {

    @PromptTemplate(
        name = "java-code-review",
        description = "Review Java code for best practices and issues"
    )
    public Prompt createCodeReviewPrompt(
            @PromptParam("code") String code,
            @PromptParam(value = "focusAreas", required = false) List<String> focusAreas) {

        String focus = focusAreas != null ? String.join(", ", focusAreas) : "general best practices";
        return Prompt.builder()
                .system("You are an expert Java code reviewer with 20 years of experience.")
                .user("Review the following Java code for " + focus + ":\n```java\n" + code + "\n```")
                .build();
    }
}

See references/implementation-patterns.md for additional prompt template patterns.

4. Configure Transport
yaml
spring:
  ai:
    mcp:
      enabled: true
      transport:
        type: stdio       # stdio | http | sse
        http:
          port: 8080
          path: /mcp
      server:
        name: my-mcp-server
        version: 1.0.0
5. Add Security
java
@Configuration
public class McpSecurityConfig {

    @Bean
    public ToolFilter toolFilter(SecurityService securityService) {
        return (tool, context) -> {
            User user = securityService.getCurrentUser();
            if (tool.name().startsWith("admin_")) {
                return user.hasRole("ADMIN");
            }
            return securityService.isToolAllowed(user, tool.name());
        };
    }
}

Use @PreAuthorize("hasRole('ADMIN')") on tool methods for method-level security. See references/implementation-patterns.md for full security patterns.

6. Testing
java
@SpringBootTest
class WeatherToolsTest {

    @Autowired
    private WeatherTools weatherTools;

    @MockBean
    private WeatherService weatherService;

    @Test
    void testGetWeather_Success() {
        when(weatherService.getCurrentWeather("London"))
            .thenReturn(new WeatherData("London", "Cloudy", 15.0));

        WeatherData result = weatherTools.getWeather("London");

        assertThat(result.city()).isEqualTo("London");
        verify(weatherService).getCurrentWeather("London");
    }
}

See references/testing-guide.md for integration tests, Testcontainers, security tests, and slice tests.

Best Practices

Tool Design
  • Keep tools focused — one operation per tool
  • Use clear, action-oriented names (getWeather, executeQuery)
  • Always annotate parameters with @ToolParam and descriptive text
  • Return structured records/DTOs, not raw strings or maps
  • Design tools to be idempotent when possible
Security
  • Validate and sanitize all inputs — AI-generated parameters are untrusted
  • Use parameterized queries for SQL; validate and normalize paths for file tools
  • Apply @PreAuthorize for role-based access on sensitive tools
  • Audit log all data-modifying tool executions
  • Never expose credentials or sensitive data in tool descriptions or error messages
Performance
  • Use @Cacheable for expensive operations with appropriate TTL
  • Set timeouts for all external calls
  • Use @Async for long-running operations
  • Monitor with Micrometer metrics
Error Handling
  • Return structured error responses with user-friendly messages
  • Log context (user, tool name, parameters) for debugging
  • Implement retry logic for transient failures
  • Implement @ControllerAdvice for consistent error responses
Show full SKILL.md (227 more words)Show less

Examples

Example 1: Minimal Weather MCP Server
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(@ToolParam("City name") String city) {
        return new WeatherData(city, "Sunny", 22.5);
    }
}

record WeatherData(String city, String condition, double temperatureCelsius) {}
Example 2: Secure Database Tool
java
@Component
@PreAuthorize("hasRole('USER')")
public class DatabaseTools {

    private final JdbcTemplate jdbcTemplate;

    @Tool(description = "Execute a read-only SQL query and return results")
    public QueryResult executeQuery(
            @ToolParam("SQL SELECT query") String sql,
            @ToolParam(value = "Parameters as JSON map", required = false) String paramsJson) {

        if (!sql.trim().toUpperCase().startsWith("SELECT")) {
            throw new IllegalArgumentException("Only SELECT queries are allowed");
        }
        List<Map<String, Object>> rows = jdbcTemplate.queryForList(sql);
        return new QueryResult(rows, rows.size());
    }
}

See references/examples.md for complete examples including file system tools, REST API integration, and prompt template servers.

Constraints and Warnings

Security
  • Never expose sensitive data in tool descriptions, parameters, or error messages
  • Input validation is mandatory — always validate before executing
  • External content is untrusted — tools fetching URLs may receive prompt injection payloads; validate all fetched content
  • SQL injection: use parameterized queries exclusively
  • Path traversal: normalize and validate all file paths against a base path
Operational
  • Responses should be concise — large responses can exceed AI context window limits
  • All tools must implement timeouts; default should be configurable
  • Rate limit expensive operations
  • Tools may be called concurrently — ensure thread safety
Spring AI Specific
  • Spring AI is actively developed — pin specific versions in production
  • Error messages thrown by tools are exposed to AI models; sanitize them
  • Choose transport type carefully: stdio for local processes, http/sse for remote clients

References

Consult these files for detailed patterns and examples:

© giuseppe-trisciuoglio, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 7 other files (references) in plugins/developer-kit-java/skills/spring-ai-mcp-server-patterns of giuseppe-trisciuoglio/developer-kit.

  • SKILL.md
  • references/advanced-patterns.md
  • references/api-reference.md
  • references/examples.md
  • references/implementation-patterns.md
  • references/migration-guide.md
  • references/templates/tool-template.java
  • references/testing-guide.md

Open the folder on GitHubat commit fe73fb3

Compare with similar skills

Spring AI MCP Server Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Spring AI MCP Server Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Spring AI MCP Server Patterns this skillgiuseppe-trisciuoglio/developer-kit357—~2.7kAutomated safety check: NotesMIT
MCP Server Builderborghei/Claude-Skills891—~1.9kAutomated safety check: PassMIT
Workflow Schema Tuningbreaking-brake/cc-wf-studio5.4k—~1.3kAutomated safety check: PassCustom licence
Documentation Serverandrea9293/mcp-documentation-server343—~2.3kAutomated safety check: PassMIT
MCP Auditgetsentry/toolkit920—~1.5kAutomated safety check: PassCustom licence
Add Promptcyanheads/pubmed-mcp-server158—~1.6kAutomated safety check: PassApache-2.0

Similar skills

  • MCP Server Builder

    borghei/Claude-Skills

    Build MCP (Model Context Protocol) servers with tool definitions, resource providers, prompt templates, and transports.

    891 GitHub stars~1.9k tokensUpdated 4 days ago
    Agent WorkflowsAuto-check passed
  • Workflow Schema Tuning

    breaking-brake/cc-wf-studio

    Guides edits to cc-wf-studio's workflow schema so AI agents generate better workflows, treating schema text as prompt engineering rather than validation.

    5.4k GitHub stars~1.3k tokensUpdated 4 days ago
    Agent WorkflowsAuto-check passed
  • Documentation Server

    andrea9293/mcp-documentation-server

    A skill your agent uses when you need to store, retrieve, search, or manage documents in a local knowledge base with semantic search and hybrid (vector + full-text) retrieval.

    343 GitHub stars~2.3k tokensUpdated 1 mo ago
    Agent WorkflowsAuto-check passed
  • MCP Audit

    getsentry/toolkit

    Official

    Audit MCP servers for protocol compliance, metadata drift, and compatibility regressions.

    920 GitHub stars~1.5k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • Add Prompt

    cyanheads/pubmed-mcp-server

    Scaffold a new MCP prompt template. An agent skill from cyanheads/pubmed-mcp-server.

    158 GitHub stars~1.6k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • Cco Overhead

    egorfedorov/claude-context-optimizer

    Audit the fixed context overhead every session starts with — system prompt, MCP tools, agents, CLAUDE.md, memory — measured from real transcript usage

    114 GitHub stars~606 tokensUpdated 11 days ago
    Agent WorkflowsAuto-check passed

More from giuseppe-trisciuoglio/developer-kit

All 115 skills in this repo
  • Nestjs Drizzle Crud Generator

    giuseppe-trisciuoglio/developer-kit

    Generates complete CRUD modules for NestJS applications with Drizzle ORM.

    357 GitHub stars~1.3k tokensUpdated 1 mo ago
    Auto-check: notes
  • Spring Boot Actuator

    giuseppe-trisciuoglio/developer-kit

    Provides patterns to configure Spring Boot Actuator for production-grade monitoring, health probes, secured management endpoints, and Micrometer metrics across JVM services.

    357 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check: notes
  • Spring Boot Crud Patterns

    giuseppe-trisciuoglio/developer-kit

    Provides and generates complete CRUD workflows for Spring Boot 3 services.

    357 GitHub stars~2.5k tokensUpdated 1 mo ago
    Auto-check: notes
  • Spring Boot Security JWT

    giuseppe-trisciuoglio/developer-kit

    Provides JWT authentication and authorization patterns for Spring Boot 3.5.x covering token generation with JJWT, Bearer/cookie authentication, database/OAuth2 integration, and RBAC/permission-based…

    357 GitHub stars~3.9k tokensUpdated 1 mo ago
    Auto-check: notes
  • AWS CLI Beast

    giuseppe-trisciuoglio/developer-kit

    Provides advanced AWS CLI patterns for managing EC2, Lambda, S3, DynamoDB, RDS, VPC, IAM, and CloudWatch.

    357 GitHub stars~1.7k tokensUpdated 1 mo ago
    Auto-check: notes
  • PR Review Comments

    giuseppe-trisciuoglio/developer-kit

    Posts review findings from a JSON file as inline comments on a GitHub Pull Request, attaching each comment to its file and line.

    357 GitHub stars~1k tokensUpdated 1 mo ago
    Auto-check: notes

Questions about Spring AI MCP Server Patterns

What does Spring AI MCP Server Patterns do?

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…. Spring AI MCP Server Patterns is an agent skill from giuseppe-trisciuoglio/developer-kit. 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.

When should I use Spring AI MCP Server Patterns?

Spring AI MCP Server Patterns fits situations like: building MCP servers to extend AI capabilities with Springs official AI framework; implementing AI tools; custom function calling; MCP client integration.

How do I install Spring AI MCP Server Patterns in Claude Code?

Run `npx skills add giuseppe-trisciuoglio/developer-kit --skill spring-ai-mcp-server-patterns -a claude-code`. Or copy the skill folder (plugins/developer-kit-java/skills/spring-ai-mcp-server-patterns in giuseppe-trisciuoglio/developer-kit) into .claude/skills/spring-ai-mcp-server-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Spring AI MCP Server Patterns in Codex?

Run `npx skills add giuseppe-trisciuoglio/developer-kit --skill spring-ai-mcp-server-patterns -a codex`. Or copy the skill folder (plugins/developer-kit-java/skills/spring-ai-mcp-server-patterns in giuseppe-trisciuoglio/developer-kit) into .agents/skills/spring-ai-mcp-server-patterns in your project. Codex loads it when a task matches its description.

Can I use Spring AI MCP Server Patterns in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add giuseppe-trisciuoglio/developer-kit --skill spring-ai-mcp-server-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/spring-ai-mcp-server-patterns, .gemini/skills/spring-ai-mcp-server-patterns, .github/skills/spring-ai-mcp-server-patterns and .opencode/skills/spring-ai-mcp-server-patterns in your project.

What does Spring AI MCP Server Patterns need to run?

Going by SKILL.md and its folder, Spring AI MCP Server Patterns needs Java for the scripts in its folder and credentials named OPENAI_API_KEY. Our summary lists: A credential in OPENAI_API_KEY. Its frontmatter pre-approves these tools: Read, Write, Edit, Bash, Glob, Grep.

Does Spring AI MCP Server Patterns access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Spring AI MCP Server Patterns safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Spring AI MCP Server Patterns use?

Spring AI MCP Server Patterns is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Spring AI MCP Server Patterns use?

About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 36k tokens, read only when the agent opens those files.

What are the alternatives to Spring AI MCP Server Patterns?

Skills that share tags, products or a category with Spring AI MCP Server Patterns: MCP Server Builder (borghei/Claude-Skills, 891 stars), Workflow Schema Tuning (breaking-brake/cc-wf-studio, 5.4k stars), Documentation Server (andrea9293/mcp-documentation-server, 343 stars) and MCP Audit (getsentry/toolkit, 920 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Spring AI MCP Server Patterns?

giuseppe-trisciuoglio (a GitHub user) maintains it in giuseppe-trisciuoglio/developer-kit, which has 357 GitHub stars. The repository holds 115 skills in this directory. The repository was last updated on September 10, 2026.

Source: giuseppe-trisciuoglio/developer-kit on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.