spring-boot-ai-mongo
A Spring Boot AI-powered Model Context Protocol Server for interacting with MongoDB
claude mcp add --transport stdio bootcamptoprod-spring-boot-ai-mongo-mcp-server java -jar spring-boot-ai-mongo-server.jar \ --env MONGO_URI="mongodb://localhost:27017/mydb"
How to use
This MCP server is a MongoDB-backed service built with Spring Boot AI. It exposes a collection of database operations as callable tools through the MCP framework by annotating methods with @Tool and registering them via ToolCallbackProvider. To interact with it, start the server with the provided command and connect an MCP client (such as the Claude desktop app) to call the available tools. The tools perform typical MongoDB operations (e.g., find, insert, update, delete) and are surfaced as discrete callable endpoints that MCP clients can invoke in a structured, model-driven way. When connected, you’ll be able to browse or invoke the registered tools and pass the required parameters just like other MCP tools, receiving results back from the server.
How to install
Prerequisites:
- Java (JDK 17 or newer) installed and available on PATH
- MongoDB running locally (default URI mongodb://localhost:27017/mydb or your configured URI)
- Build tooling (Maven or Gradle) to compile the Spring Boot application
Steps:
- Clone the repository containing the Spring Boot AI Mongo MCP Server.
- Ensure MongoDB is running locally or adjust the connection URI in the environment (see mcp_config.env for placeholder usage).
- Build the project (examples):
- If using Maven: mvn clean package
- If using Gradle: ./gradlew build
- Run the server:
- java -jar spring-boot-ai-mongo-server.jar
- Verify the server starts and is listening on the expected port (default Spring Boot port 8080) and then connect your MCP client to the server.
Additional notes
Notes and tips:
- The server exposes MongoDB operations as tools via @Tool annotations; ensure your methods are properly annotated and registered with ToolCallbackProvider.
- If you need to change the MongoDB connection, set MONGO_URI in the environment or configure Spring properties (e.g., spring.data.mongodb.uri) as needed.
- If the MCP client cannot discover tools, check that the ToolCallbackProvider is correctly initialized at startup and that the server logs indicate tool registration success.
- Ensure MongoDB user permissions and network access allow the Spring Boot service to connect from your runtime environment.
- For troubleshooting, review application logs for any issues related to MongoDB connectivity, tool registration, or MCP client compatibility.
Related MCP Servers
mcp-for-beginners
This open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
api2mcp4j
This is a revolutionary AI MCP plugin with excellent pluggable and encapsulated features. With just a few lines of configuration, it can easily integrate into your Spring boot web program and give it MCP capabilities,inheriting the powerful engineering capabilities of the Spring series framework
mcp-java-sdk-examples
A collection of MCP server examples developed by various Java SDKs
mcp-annotated-java-sdk
Annotation-driven MCP dev 🚀 No Spring, Zero Boilerplate, Pure Java
antlr4
ANTLR4 MCP Server
spring-boot-ai-confluence
A Spring Boot AI-powered Model Context Protocol Server for interacting with Confluence Cloud