About Spring MCP Server
Spring MCP Server is a basic Spring Boot example for Java developers building MCP servers. It shows how to expose service-provided information as tools and configure the server for Claude Desktop.
Key features
- 01Spring Boot MCP server setup
- 02Expose service data through tools
- 03Tool callback configuration
- 04Maven build instructions
Use cases
- 01Prototype a Java MCP server
- 02Expose application information to Claude Desktop
MCP support
It implements an MCP server that exposes service information through tools to MCP clients. The README demonstrates connecting it to Claude Desktop.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMESpring MCP Server
The Model Context Protocol is an open standard that enables developers to build secure, two-way connections between their data sources and AI-powered tools. The architecture is straightforward: developers can either expose their data through MCP servers or build AI applications (MCP clients) that connect to these servers.
Prerequisites
- Java 21
- Maven 3.9.9
- Spring Boot 3.4.4
- Spring AI 0.4.0
- Spring Model Context Protocol Server
- Claude Desktop Application
Getting Started
In this example, we will create a simple Spring Boot application that serves as an MCP server.
1. Create a Spring Boot Application
Create a new Spring Boot application using the Spring Initializr or your preferred method. You can use the following dependencies:
- Spring Model Context Protocol Server
Creating record
Create a record class that will represent the information you want to expose through the MCP server.
package org.sehn.spring_mcp;
public record Info(String title, String url) {
}
Creating services
Create a service class that will provide the information you want to expose through the MCP server.
package org.sehn.spring_mcp;
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 InfoService {
private static final Logger logger = LoggerFactory.getLogger(InfoService.class);
private List<Info> information = new ArrayList<>();
@Tool(name = "dr_get_information", description = "Get a list of information about Deepanshu Rawat")
public List<Info> getInformation() {
return information;
}
@Tool(name = "dr_get_info", description = "Get a specific information about Deepanshu Rawat")
public Info getInfo(String title) {
return information.stream().filter(info -> info.title().equals(title)).findFirst().orElse(null);
}
@PostConstruct
public void init() {
information.addAll(List.of(
new Info("Portfolio", "https://bento.me/deepanshu-rawat6"),
new Info("GitHub", "https://github.com/deepanshu-rawat6"),
new Info("LinkedIn", "https://www.linkedin.com/in/deepanshu-rawat6/"),
new Info("Twitter", "https://twitter.com/deepanshuurawat")
));
}
}
Creating a Tool Callback
In the SpringMCPApplication or your main application class, create a tool callback that will handle the requests from the MCP server.
@Bean
public List<ToolCallback> deepanshuTools(InfoService infoService) {
return List.of(ToolCallbacks.from(infoService));
}
Adding Configuration
Create a configuration class that will configure the MCP server.
spring.application.name=spring_mcp
spring.main.web-application-type=none
spring.ai.mcp.server.name=spring_mcp
spring.ai.mcp.server.version=0.0.1
spring.main.banner-mode=off
logging.pattern.console=
2. Build the Application
Simply run the following command to build the application:
mvn clean package -DskipTests
3. Further configuration
Now, in order to use the MCP server, you need to add the following configuration in your claude_desktop_config.json:
{
"mcpServers": {
"<name_of_the_mcp_server>": {
"command": "java",
"args": [
"-jar",
"<Path_of_the_jar_file_created_after_building>"
]
}
}
}
Replace <name_of_the_mcp_server> with the name of your MCP server and <Path_of_the_jar_file_created_after_building> with the path to the jar file created after building the application.
For example, name of my MCP server is spring_mcp.
4. Testing the MCP Server
Now, start Claude Desktop and a few new things will appear underneath the prompt area:
Installed MCP Servers

Available MCP tools

Now, upon hitting a prompt, say for example: Get me the information about Deepanshu Rawat, you will get a alert about third-party tools being used, simply accept the alert for the current chat.
And then you will get a response, like this:

Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.