Spring Boot MCP Starter
ๅฐ Spring Boot ๅพฎๆๅกๅฟซ้่ฝฌๆขไธบๆฏๆ Streamable HTTP ไผ ่พๅ่ฎฎ็ MCP ServerใๆฏๆWebMVCๅWebFlux
Ask AI about Spring Boot MCP Starter
Powered by Claude ยท Grounded in docs
I know everything about Spring Boot MCP Starter. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
Spring Boot MCP Starter
A lightweight Spring Boot starter for building Model Context Protocol (MCP) servers in Java. Define tools, resources, and prompts with annotations โ no boilerplate.
Why?
MCP is the open standard for connecting AI assistants to external tools and data. Most implementations are in Python or TypeScript. If you're a Java/Spring Boot engineer, there's no easy way to build an MCP server that fits into your existing stack.
This starter fixes that. Drop it into any Spring Boot app, annotate your methods, and you have a working MCP server.
Quick Start
1. Add the dependency
<dependency>
<groupId>dev.ramesh</groupId>
<artifactId>spring-boot-mcp-starter</artifactId>
<version>0.1.0</version>
</dependency>
2. Define a tool
@McpTool(name = "get_weather", description = "Get current weather for a city")
public class WeatherTool {
@ToolMethod
public String execute(@ToolParam(name = "city", description = "City name") String city) {
// Your logic here
return "Sunny, 22ยฐC in " + city;
}
}
3. Run
mvn spring-boot:run
Your Spring Boot app is now an MCP server. Connect it to Claude Desktop, GitHub Copilot, or any MCP client.
Features
@McpToolโ Turn any Spring bean into an MCP tool@McpResourceโ Expose data sources (databases, APIs, files) as MCP resources@McpPromptโ Define reusable prompt templates- Stdio & HTTP transports โ Works with local CLI tools (stdio) and remote clients (SSE/HTTP)
- Auto-discovery โ Tools, resources, and prompts are auto-registered via component scanning
- Spring Boot native โ Constructor injection,
application.ymlconfig, actuator health checks - JSON Schema generation โ Tool parameters automatically generate JSON Schema from Java types
Configuration
mcp:
server:
name: my-mcp-server
version: 1.0.0
transport: stdio # or 'sse' for HTTP
sse:
port: 8080
endpoint: /mcp
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Spring Boot Application โ
โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ @McpTool โ โ@McpResourceโ โ@McpPromptโ โ
โ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโโ โโโโโโฌโโโโโโ โ
โ โ โ โ โ
โ โโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโโโโโโผโโโโโ โ
โ โ McpServerAutoConfiguration โ โ
โ โ (auto-discovers & registers all) โ โ
โ โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Transport Layer โ โ
โ โ โโโโโโโโโโโ โโโโโโโโโโโโ โ โ
โ โ โ Stdio โ โ SSE/HTTP โ โ โ
โ โ โโโโโโโโโโโ โโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Examples
Database query tool
@McpTool(name = "query_users", description = "Search users by name")
@RequiredArgsConstructor
public class UserQueryTool {
private final UserRepository userRepository;
@ToolMethod
public List<User> execute(
@ToolParam(name = "name", description = "Name to search for") String name,
@ToolParam(name = "limit", description = "Max results", required = false) Integer limit) {
return userRepository.findByNameContaining(name, PageRequest.of(0, limit != null ? limit : 10));
}
}
REST API resource
@McpResource(
uri = "api://orders/{orderId}",
name = "order",
description = "Fetch order details by ID"
)
@RequiredArgsConstructor
public class OrderResource {
private final OrderService orderService;
@ResourceMethod
public Order fetch(@ResourceParam("orderId") String orderId) {
return orderService.getById(orderId);
}
}
Prompt template
@McpPrompt(name = "code_review", description = "Review code for common issues")
public class CodeReviewPrompt {
@PromptMethod
public String generate(
@PromptParam(name = "language") String language,
@PromptParam(name = "code") String code) {
return """
Review this %s code for bugs, security issues, and performance problems.
Be specific and actionable. Only flag things that matter.
```%s
%s
```
""".formatted(language, language, code);
}
}
Transport Options
| Transport | Use Case | Config |
|---|---|---|
| Stdio | CLI tools, local AI assistants (Copilot, Claude Desktop) | mcp.server.transport=stdio |
| SSE | Remote clients, web-based integrations | mcp.server.transport=sse |
Roadmap
- Auto-generate JSON Schema from records and POJOs
- Streaming responses for long-running tools
- OAuth2 authentication for SSE transport
- Spring Boot Actuator endpoint for MCP server health
- GraalVM native image support
- Publish to Maven Central
Contributing
Contributions welcome. Open an issue first to discuss what you'd like to change.
