Get the FREE Ultimate OpenClaw Setup Guide →

mcp -demo

基于 Spring AI 的 MCP 服务端示例项目,使用 stdio 传输方式对外提供企业工具能力

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio nageoffer-mcp-server-demo java -jar /absolute/path/to/mcp-server-demo/target/mcp-server-demo-1.0.0.jar

How to use

This MCP server is a Spring Boot application that implements the Model Context Protocol over a stdio transport. It exposes two built-in tools for enterprise tooling: getUserAnnualLeave, which returns a user’s annual leave balance, and getOrderStatus, which returns logistics status for an order. To connect, configure an MCP client (one that supports stdio) to launch the server process and communicate using the MCP protocol. The README provides an example client config that starts the server with java -jar and points to the server JAR, allowing the client to send tool invocations and receive structured results.

Once connected, you can invoke the tools via the MCP client by specifying the tool name and input payload. For example, getUserAnnualLeave expects a userId and will respond with remainingDays, totalDays, usedDays, and the year. getOrderStatus expects an orderId and will respond with status, location, estimatedDelivery, carrier, and trackingNumber. You can extend the server with additional tools by adding methods annotated with @Tool in EnterpriseTools and rebuilding, as described in the development notes.

How to install

Prerequisites:

  • JDK 17 or higher
  • Maven Wrapper (recommended, via ./mvnw)
  • Optional: a Java development environment and Maven if you prefer manual builds

Step-by-step:

  1. Obtain the source code (clone or download the project).

  2. Build the project using Maven Wrapper:

    ./mvnw clean package

  3. Run the server (one of the options):

    • Using Spring Boot Maven plugin: ./mvnw spring-boot:run

    • Or by running the packaged JAR directly: java -jar target/mcp-server-demo-1.0.0.jar

  4. Confirm logs and startup success. Logs by default are written to ./logs/mcp-server.log.

Additional notes

Notes and tips:

  • The server runs as a non-web application (web-application-type: none) and communicates with MCP clients via stdio.
  • Two built-in tools are available out of the box: getUserAnnualLeave and getOrderStatus. To add more tools, implement additional methods in EnterpriseTools annotated with @Tool and rebuild; MCPServerConfig will auto-register them.
  • Logs are stored under ./logs by default; adjust logging configuration if needed.
  • If you’re using a client example from the README, replace the absolute path to the JAR with your actual deployment path.
  • Common issues: ensure you are using Java 17+; using an older JRE may trigger class file version errors. If you see compilation/runtime version errors, switch to Java 17+ and re-run the build.

Related MCP Servers

Sponsor this space

Reach thousands of developers