spring-boot -example
一个简单的spring-boot-mcp-server示例
claude mcp add --transport stdio jinjunfn-spring-boot-mcp-server-example docker run -i jinjunfn-spring-boot-mcp-server-example \ --env JAVA_OPTS="Optional Java runtime options" \ --env SPRING_PROFILES_ACTIVE="default"
How to use
This MCP server implements the Model Controller Protocol using Spring Boot. It exposes an MCP endpoint at /mcp and provides a set of tools that can be invoked by AI agents or client applications via the standard MCP protocol. The service supports both synchronous and asynchronous processing modes, controlled by the configuration, and can automatically scan and register tools through annotation-based discovery. The built-in health check endpoint at GET /mcp/tools/healthy helps you monitor availability, while the protocol endpoint enables standard interaction with a suite of tools and services defined under the com.mcp_server.mcp package.
To start using it, run the server (via Maven in development or via your deployment method). Once running, you can interact with MCP endpoints to list available tools, request tool execution, and receive results in the MCP-compliant format. If you enable annotation scanning, new tools can be automatically discovered and registered as part of the MCP service, simplifying integration of custom AI tools or assistants into your application workflow.
How to install
Prerequisites:
- Java 17+ JDK
- Maven or a Maven wrapper (mvn or mvnw)
- Optional: Docker if you plan to run via container
Install steps:
- Clone the repository git clone <repository-url>
- Navigate to the project directory cd mcp-server
- Build the project (Maven wrapper is recommended) ./mvnw clean package
- Run the application locally (development) ./mvnw spring-boot:run or run the packaged JAR from target (example): java -jar target/bi-chatter.jar
- Verify the MCP endpoint
- Default endpoint: /mcp
- Health check: GET /mcp/tools/healthy
If you prefer Docker:
- Build or pull the Docker image (if provided by the project)
- Run the container to expose the MCP endpoint inside the container network
- Access the endpoint at the container's mapped port (e.g., localhost:8088 by default)
Additional notes
Notes and tips:
- The project uses Java 17+ and Spring Boot 3.5.x; ensure your runtime matches.
- The MCP endpoint is typically exposed at /mcp; adjust streamable-http.mcp-endpoint in configuration if you customize the path.
- Enable annotation-scanner in the configuration to auto-register tools discovered via annotations.
- For asynchronous processing, confirm your messaging or executor configuration is compatible with your workload.
- If you encounter port conflicts, you can change the server port in application.yaml under spring.ai.mcp.server.port (or via standard Spring Boot server.port).
- When running in production, consider using a reverse proxy and proper security measures for MCP endpoint access.