A Model Context Protocol (MCP) demo server built with Spring Boot 4 and Spring AI.
It exposes calculator and date/time tools over the MCP SSE (Server-Sent Events) transport so any MCP-compatible client — including GitHub Copilot in IntelliJ IDEA — can connect to it over HTTP.
- Features
- Prerequisites
- Building the project
- Running the server
- Adding to GitHub Copilot in IntelliJ IDEA
- Actuator endpoints
- Available tools
- Project structure
- Extending the server
- Troubleshooting
| Tool group | Tools |
|---|---|
| Calculator | add, subtract, multiply, divide, power, sqrt |
| Date & Time | getCurrentDateTime, getCurrentDate, formatDateTime, listTimezones |
- Spring Boot 4.0.3 with Spring AI 1.0.0-M6
- MCP SSE transport — runs as an HTTP server (default port
8080) - Spring Boot Actuator — health, info, and mappings endpoints to verify SSE endpoint availability
- Logs written to stdout and to
mcp-server.login the system temp directory (override withLOG_PATH)
| Requirement | Version |
|---|---|
| Java | 17 or later |
| Maven | 3.6+ |
Verify with:
java -version
mvn -version# Clone (if you haven't already)
git clone https://github.com/TinusJ/MCP_SERVER.git
cd MCP_SERVER
# Package into a fat JAR
mvn package -DskipTests
# Run the tests (optional)
mvn testThe fat JAR is created at:
target/mcp-server-demo-0.0.1-SNAPSHOT.jar
The server starts an HTTP server on port 8080 with SSE transport:
java -jar target/mcp-server-demo-0.0.1-SNAPSHOT.jarOnce running, the following MCP endpoints are available:
| Endpoint | Method | Description |
|---|---|---|
/sse |
GET | SSE stream — clients connect here to receive events |
/mcp/message |
POST | Message endpoint — clients send JSON-RPC requests here |
# Check the server is running
curl http://localhost:8080/actuator/health
# Connect to the SSE endpoint (Ctrl+C to stop)
curl http://localhost:8080/ssemvn package -DskipTests
java -jar target/mcp-server-demo-0.0.1-SNAPSHOT.jarThe server must be running before IntelliJ can connect.
-
Open IntelliJ IDEA (2024.3 or later with the GitHub Copilot plugin installed and signed in).
-
Go to Settings → Tools → GitHub Copilot → MCP Servers
(or search "MCP" in the Settings search bar). -
Click + to add a new server.
-
Fill in the form:
Field Value Name demo-mcp-serverTransport SSEURL http://localhost:8080/sse -
Click OK and restart the Copilot chat session.
Open Copilot Chat (Alt+Shift+C / ⌥⇧C) and try:
What is 1234 divided by 56? Use the MCP calculator.
What is today's date in the America/Chicago timezone?
Copilot will call the server tools automatically and include the results in its reply.
The repository includes a .mcp.json at the project root.
Some MCP clients pick this up automatically:
Note: The server must be running before the client can connect.
Spring Boot Actuator is included to provide health checks and endpoint visibility.
The following actuator endpoints are exposed:
| Endpoint | Description |
|---|---|
/actuator/health |
Server health status (disk space, liveness, readiness) |
/actuator/info |
Application info |
/actuator/mappings |
All registered HTTP endpoints — use this to verify /sse and /mcp/message are mapped |
# Check health
curl http://localhost:8080/actuator/health
# List all mapped endpoints (look for /sse and /mcp/message)
curl http://localhost:8080/actuator/mappings | python3 -m json.tool| Tool | Description | Parameters |
|---|---|---|
add |
Add two numbers | a, b (double) |
subtract |
Subtract b from a |
a, b (double) |
multiply |
Multiply two numbers | a, b (double) |
divide |
Divide a by b |
a, b (double, b ≠ 0) |
power |
Raise base to exponent |
base, exponent (double) |
sqrt |
Square root of a number | number (double, ≥ 0) |
| Tool | Description | Parameters |
|---|---|---|
getCurrentDateTime |
Current date-time (ISO-8601) | timezone (string, e.g. UTC) |
getCurrentDate |
Current date only | timezone (string) |
formatDateTime |
Reformat a date-time string | dateTimeString, inputPattern, outputPattern |
listTimezones |
List all valid timezone IDs | (none) |
src/
├── main/
│ ├── java/com/example/mcpserver/
│ │ ├── McpServerApplication.java # Spring Boot entry point + tool registration
│ │ ├── config/
│ │ │ └── McpServerConfig.java # ObjectMapper bean for SSE transport
│ │ └── tools/
│ │ ├── CalculatorTools.java # @Tool-annotated calculator methods
│ │ └── DateTimeTools.java # @Tool-annotated date/time methods
│ └── resources/
│ ├── application.properties # SSE transport, actuator config
│ └── logback-spring.xml # Console + file logging
└── test/
└── java/com/example/mcpserver/
├── McpServerApplicationTests.java # Unit tests for all tools
├── actuator/
│ └── ActuatorEndpointTests.java # Actuator + SSE endpoint tests
└── config/
└── McpServerConfigTests.java # Configuration tests
- Create a new
@Serviceclass in thetoolspackage with methods annotated with@Tool. - Register it in
McpServerApplicationby adding a@Beanthat returns aToolCallbackProvider:
@Bean
public ToolCallbackProvider myToolCallbackProvider(MyTools myTools) {
return MethodToolCallbackProvider.builder().toolObjects(myTools).build();
}- Rebuild (
mvn package) and restart the server — the new tools appear automatically in the MCPtools/list.
-
Check the port is available — The server runs on port
8080by default. If the port is in use, change it inapplication.properties:server.port=9090 -
Check the log file — Logs are written to
mcp-server.login the system temp directory (e.g./tmpon Linux/macOS,%TEMP%on Windows). Override with theLOG_PATHenvironment variable. -
Verify Java is available — Run
java -versionin a terminal.
-
Make sure the server is running — Unlike STDIO transport, the SSE server must be started before the client connects:
java -jar target/mcp-server-demo-0.0.1-SNAPSHOT.jar
-
Verify the server is healthy:
curl http://localhost:8080/actuator/health
-
Check the SSE endpoint is mapped — Use the actuator mappings endpoint to confirm
/sseis registered:curl http://localhost:8080/actuator/mappings
-
Check the URL in IntelliJ — Make sure the URL is
http://localhost:8080/sse(or the custom port if changed).