Build an MCP server in Java with Spring Boot 4 and Spring AI — expose your app's operations as tools any AI agent can call.
Config is the same across clients — only the file and path differ.
{
"mcpServers": {
"product-store": {
"args": [
"-jar",
"/ABSOLUTE/PATH/TO/product-mcp-server/build/libs/product-mcp-server-0.0.1-SNAPSHOT.jar",
"--spring.profiles.active=stdio"
],
"command": "java"
}
}
}Are you the author?
Add this badge to your README to show your security score and help users find safe servers.
A small but complete Model Context Protocol (MCP) server built with Spring Boot 4 and Spring AI. It exposes a fictional product & order management app as MCP tools that any MCP-capable AI agent (Claude Desktop, Claude Code, Cursor, VS Code, …) can call to read and change data.
This server supports HTTP transport. Be the first to test it — help the community know if it works.
Five weighted categories — click any category to see the underlying evidence.
No known CVEs.
No package registry to scan.
Be the first to review
Have you used this server?
Share your experience — it helps other developers decide.
Sign in to write a review.
Others in ai-ml / education
Dynamic problem-solving through sequential thought chains
Workspace template + MCP server for Claude Code, Codex CLI, Cursor & Windsurf. Multi-agent knowledge engine (ag-refresh / ag-ask) that turns any codebase into a queryable AI assistant.
Persistent memory using a knowledge graph
An autonomous agent that conducts deep research on any data using any LLM providers
MCP Security Weekly
Get CVE alerts and security updates for Spring Mcp Server Tutorial and similar servers.
Start a conversation
Ask a question, share a tip, or report an issue.
Sign in to join the discussion.
A small but complete Model Context Protocol (MCP) server built with Spring Boot 4 and Spring AI. It exposes a fictional product & order management app as MCP tools that any MCP-capable AI agent (Claude Desktop, Claude Code, Cursor, VS Code, …) can call to read and change data.
It is the sample project for the Tucanoo tutorial: "Building an MCP Server in Java: Connecting Your Spring Boot App to AI Agents" → https://tucanoo.com/building-an-mcp-server-in-java-connecting-your-spring-boot-app-to-ai-agents/
No LLM, no API key, no database required. An MCP server doesn't run a model — the connecting agent brings the AI. Data is held in memory and seeded at startup.
Tools
| Tool | Kind | What it does |
|---|---|---|
search_products | read | Keyword search across the catalog |
get_product | read | Full details of one product by SKU |
check_stock | read | Units in stock for a SKU |
list_orders | read | All orders, optionally filtered by status |
get_order | read | One order by ID |
create_order | write | Create an order (checks + decrements stock) |
update_order_status | write | Move an order to NEW / PAID / SHIPPED / CANCELLED |
Plus one resource — catalog://products/{sku} — returning a product summary, to demonstrate the
MCP resource primitive alongside tools.
build.gradle. Move to 2.0.0 GA when it ships../gradlew build
This produces build/libs/product-mcp-server-0.0.1-SNAPSHOT.jar.
This project uses the single spring-ai-starter-mcp-server-webmvc starter for both transports;
a Spring profile picks which one runs.
stdio carries the protocol over stdin/stdout, so the app must not print anything else. The stdio
profile turns off the web server, the banner, and console logging (logs go to a file instead):
java -jar build/libs/product-mcp-server-0.0.1-SNAPSHOT.jar --spring.profiles.active=stdio
You normally don't run this yourself — the AI client does (see Claude Desktop below).
java -jar build/libs/product-mcp-server-0.0.1-SNAPSHOT.jar --spring.profiles.active=http
# MCP endpoint: http://localhost:8080/mcp
(Use --server.port=8081 if 8080 is taken.)
stdio:
# list tools
SPRING_PROFILES_ACTIVE=stdio npx @modelcontextprotocol/inspector --cli \
java -jar build/libs/product-mcp-server-0.0.1-SNAPSHOT.jar --method tools/list
# call a tool
SPRING_PROFILES_ACTIVE=stdio npx @modelcontextprotocol/inspector --cli \
java -jar build/libs/product-mcp-server-0.0.1-SNAPSHOT.jar \
--method tools/call --tool-name search_products --tool-arg query=headphones
HTTP (start the server with the http profile first):
npx @modelcontextprotocol/inspector --cli http://localhost:8080/mcp --transport http --method tools/list
Run npx @modelcontextprotocol/inspector with no --cli for the web UI (it prints a session-token URL
in the terminal — open that).
Edit claude_desktop_config.json:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json{
"mcpServers": {
"product-store": {
"command": "java",
"args": [
"-jar",
"/ABSOLUTE/PATH/TO/product-mcp-server/bui
... [View full README on GitHub](https://github.com/tucanoo/spring-mcp-server-tutorial#readme)