Ready to power up your AI applications with real-time data access? The Spring Boot MCP Server lets you seamlessly connect AI models like Claude or Cursor to your application's data using the Model Context Protocol (MCP). Imagine your AI fetching game listings or searching for data with simple commands, all backed by a lightweight, extensible Spring Boot service.
In this hands-on guide, you'll learn how to set up a Spring Boot MCP Server, expose your data as AI-usable tools, and test the integration with leading AI clients. Whether you're building internal developer tools or customer-facing apps, this approach streamlines AI-data connectivity—no heavy infrastructure required.
💡 Looking for an API testing platform that generates beautiful API documentation, boosts team productivity, and replaces Postman at a better price?
Apidog delivers all that in one place.
What Is the Spring Boot MCP Server?
The Spring Boot MCP Server is a modular Spring Boot application that exposes your business data as AI-accessible tools by leveraging the Spring AI MCP framework. It acts as a bridge, letting AI models securely interact with your data—such as a list of games—via standardized MCP tool endpoints.
Key Features:
- Get all games: Returns a full list of available games.
- Search games by title: Finds a game matching a specific title.
Built on Spring Boot, this solution is easy for developers to set up, extend, and maintain. Perfect for teams looking to offer dynamic data access to AI models, or for those wanting to build and test their own MCP servers.
Step-by-Step Guide: Using the Spring Boot MCP Server
Prerequisites
Before you start, ensure you have:
- Java 24: Download from oracle.com
- Maven 3.8+: Get it from maven.apache.org
- IntelliJ IDEA (or your preferred IDE): jetbrains.com
- Claude Desktop or Cursor for AI client testing: anthropic.com & cursor.com
- Basic Spring Boot knowledge
1. Create a New Spring Boot Project
- Visit Spring Initializr
- Configure:
- Project: Maven
- Language: Java
- Spring Boot: 3.5.4 (latest stable)
- Packaging: Jar
- Java Version: 24
- Add Dependency: Spring AI MCP Server

- Click Generate to download the project.
- Unzip and open it in IntelliJ IDEA (or your IDE).
2. Project Structure Overview
Your project will contain:
Game.java— Defines the data model (game title & URL)GameService.java— Implements MCP tools using@ToolTestMcpServerApplication.java— Main app; registers toolsapplication.properties— Configures the MCP server

Sample application.properties:
spring.application.name=test-mcp-server
spring.main.web-application-type=none
spring.ai.mcp.server.name=game-demo-mcp
spring.ai.mcp.server.version=0.0.1
spring.main.banner-mode=off
logging.pattern.console=
This configures a non-web, STDIO-based MCP server—ideal for secure AI tool communication.
3. Define Your Data Model
In Game.java, create a simple record for the game data:
package com.example.testmcpserver;
public record Game(String title, String url) {}
This immutable object makes it easy for AI models to process your data.
4. Implement MCP Tools
Define your business logic in GameService.java using the @Tool annotation:
package com.example.testmcpserver;
import jakarta.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class GameService {
private static final Logger log = LoggerFactory.getLogger(GameService.class);
private List<Game> games = new ArrayList<>();
@Tool(name = "get_games", description = "Get a list of games from the collection")
public List<Game> getGames() {
return games;
}
@Tool(name = "get_game", description = "Get a single game from the collection by title")
public Game getGame(String title) {
return games.stream().filter(game -> game.title().equals(title)).findFirst().orElse(null);
}
@PostConstruct
public void init() {
games.addAll(List.of(
new Game("GTA 6", "https://www.rockstargames.com/VI"),
new Game("FC 26","https://www.ea.com/en/games/ea-sports-fc/fc-26"),
new Game("Call of Duty: Black Ops 7","https://www.callofduty.com/blackops7")
));
}
}
5. Register Tools with the MCP Framework
In TestMcpServerApplication.java, wire up your tools:
package com.example.testmcpserver;
import org.springframework.ai.support.ToolCallbacks;
import org.springframework.ai.tool.ToolCallback;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import java.util.List;
@SpringBootApplication
public class TestMcpServerApplication {
public static void main(String[] args) {
SpringApplication.run(TestMcpServerApplication.class, args);
}
@Bean
public List<ToolCallback> danTools(GameService gameService) {
return List.of(ToolCallbacks.from(gameService));
}
}
ToolCallbacks.from() scans for @Tool methods and registers them.
6. Run Your Spring Boot MCP Server
- Open your terminal in IntelliJ IDEA.
- Run:
mvn spring-boot:run - The server starts as an STDIO-based MCP server (no web UI).
Verify: You should see two registered tools: get_games and get_game.
7. Connect with Claude Desktop or Cursor
For Claude Desktop
-
Build the JAR:
mvn clean packageFind the JAR at
target/test-mcp-server-0.0.1-SNAPSHOT.jar. -
Configure
claude_desktop_config.json:- macOS:
~/Library/Application Support/Claude - Windows:
%APPDATA%\Claude
Add:
{ "mcpServers": { "game-demo-mcp": { "command": "java", "args": [ "-jar", "path/to/test-mcp-server-0.0.1-SNAPSHOT.jar" ] } } }Replace
path/to/with the actual file path. - macOS:

- Restart Claude Desktop to load the new config.
For Cursor
- Go to Settings → Cursor Settings → Tools and Integrations
- Click New MCP server and follow the prompts.

8. Test the MCP Server Integration
Try these test commands via Claude Desktop or Cursor:
- List all games:
Expected Output:Using the MCP server, get all available games.Available games: - Title: GTA 6, URL: https://www.rockstargames.com/VI - Title: FC 26, URL: https://www.ea.com/en/games/ea-sports-fc/fc-26 - Title: Call of Duty: Black Ops 7, URL: https://www.callofduty.com/blackops7

- Find a specific game:
Expected Output:Using the MCP server, get the game with title "FC 26".Game: FC 26, URL: https://www.ea.com/en/games/ea-sports-fc/fc-26
9. Extend and Customize the MCP Server
To further adapt the server to your needs:
- Add More Data: Expand the
gameslist inGameService. - Create New Tools: For example, search by keyword:
@Tool(name = "search_games", description = "Search games containing a keyword") public List<Game> searchGames(String keyword) { return games.stream() .filter(game -> game.title().toLowerCase().contains(keyword.toLowerCase())) .collect(Collectors.toList()); } - Integrate a Database: Replace the in-memory list with a persistent database.
- Enhance Search: Add category filters or fuzzy search as needed.
Troubleshooting
- Server Won't Start? Check your Java and Maven versions, and ensure
application.propertiesis set correctly. - Claude/Cursor Can't Connect? Verify your JAR path and configuration files, then restart the client.
- Tools Missing? Ensure
@Toolannotations andToolCallbacksregistration are correct. - No Output? Review the terminal logs for errors.
Why Choose the Spring Boot MCP Server for AI Integration?
The Spring Boot MCP Server is purpose-built for developers who want robust, real-time AI integration without heavy infrastructure. Its STDIO-based transport ensures secure communication, and Spring Boot’s flexibility means you can quickly adapt it to your backend or API ecosystem.
This guide demonstrated a full workflow: setup, tool exposure, and real-world testing with Claude Desktop and Cursor. By leveraging MCP, you unlock AI-driven data access in your applications—ideal for API teams, backend engineers, and innovation-focused developers.
For teams managing complex APIs or seeking tighter integration between their backend and AI models, pairing the MCP Server approach with a collaborative API platform like Apidog streamlines API design, documentation, and testing.
💡 Want beautiful API documentation, seamless team workflows, and a cost-effective Postman alternative?
Try Apidog—all your API needs in one place.



