mcp-rag
MCP (Model Context Protocol) Server for Retrieval Augmented Generation using Mongo and Gemini, OpenAI, with A2A support Grok
claude mcp add --transport stdio vishalmysore-mcp-rag-server java -jar target/mcp-rag.jar \ --env JAVA_OPTS="-Xms512m -Xmx1024m" \ --env SPRING_PROFILES_ACTIVE="default"
How to use
This MCP server implements a dual-protocol RAG backend that supports both the Model Context Protocol (MCP) and Google A2A (Agent-to-Agent) protocols. Built with Spring Boot and Java, it exposes a unified knowledge retrieval and RAG pipeline that can be consumed by MCP-compatible AI models as well as A2A agents. After building, run the server and connect clients via MCP endpoints for model-context interactions or via A2A channels for agent-to-agent coordination. The A2A integration exposes a Java-based agent framework (A2ARagService) and related controllers to manage agents, conversations, and card-based interactions, while the MCP side exposes conversation and retrieval flows to integrate with MCP-enabled models. The configuration supports both MCP and A2A flows through a common RAG backend, enabling seamless knowledge retrieval and contextual augmentation for multi-protocol clients.
How to install
Prerequisites:
- Java Development Kit (JDK 17 or newer)
- Maven
- Git
Installation steps:
-
Clone the repository git clone https://github.com/your-org/mcp-rag.git cd mcp-rag
-
Build the project with Maven mvn clean install
-
Run the server java -jar target/mcp-rag.jar
-
Verify the server is running
- Access the MCP endpoint (default port 8080) or check logs for startup confirmation.
- If you need to customize profiles, you can pass environment variables or Spring profile flags when launching the jar.
Notes:
- If you prefer to run with a different Spring profile, set SPRING_PROFILES_ACTIVE accordingly, e.g. SPRING_PROFILES_ACTIVE=prod
- Ensure that any required database connections (e.g., MongoDB Atlas) are reachable if configured in application.yml or properties files.
Additional notes
Tips and common considerations:
- The server bundles both MCP and A2A integrations; endpoints and controllers are organized to support both protocols within a single runnable artifact.
- For production deployments, consider configuring environment-specific application.yml files and enabling appropriate Spring profiles.
- If you encounter Java memory issues, adjust the JAVA_OPTS or container memory limits (e.g., -Xms and -Xmx values).
- Review configuration files (application.yml and tools4ai.properties) to tailor RAG settings, retrieval parameters, and protocol-specific behaviors.
- Ensure network access to any external services (databases, search indices) required by the RAG pipeline; verify credentials and access controls.
- When upgrading dependencies, re-build with Maven and re-test both MCP and A2A flows to confirm compatibility.