This project demonstrates how to build a powerful Retrieval-Augmented Generation (RAG) search application that integrates Google's Agent-to-Agent (A2A) protocol with Spring Boot and MongoDB Atlas. The system enables intelligent task management and semantic search capabilities through vector embeddings.
A2AJava is the Java implementation of the Google A2A protocol you can check the project here .
- A2A Protocol Integration: Seamless communication between AI agents
- Vector-Based Search: Powered by MongoDB Atlas for semantic task retrieval
- Real-time Task Storage: Automatic storage of A2A tasks in vector database
- RESTful API: Easy-to-use endpoints for task management
- Spring Boot Framework: Built with enterprise-grade Java technology
- Extensible Architecture: Adaptable for various use cases
- Backend: Spring Boot 3.x
- Database: MongoDB Atlas with Vector Search
- Protocol: Google A2A (Agent-to-Agent)
- Search: Vector-based semantic search
- API Documentation: OpenAPI/Swagger
The system automatically stores A2A tasks in MongoDB's vector store through a preprocessing hook:
@Override
public void preProcessing(String method, Object params) {
vectorService.ragStorage(method, params);
}
The service handles various A2A task types:
- Task sending and querying
- Task subscriptions
- Push notifications
- Task cancellations
- Resubscriptions
Here's a brief overview of the task storage mechanism:
public void ragStorage(String method, Object params) {
switch (method) {
case "tasks/send":
addTask(new ObjectMapper().convertValue(params, TaskSendParams.class));
break;
case "tasks/get":
addTask(new ObjectMapper().convertValue(params, TaskQueryParams.class));
break;
// Additional task types handled...
}
}
Adding an A2A agent to your client application
Example of normal chat interaction
Task data stored in MongoDB Atlas
Event tracking and monitoring interface
GET http://localhost:8080/getTask?name="cricket"
This endpoint demonstrates the semantic search capabilities, retrieving tasks related to the given query using vector similarity.
- Clone the repository
- Configure MongoDB Atlas connection in
application.yml
- Set up environment variables:
DB_USER
DB_PASSWORD
OPENAI_API_KEY
- Build and run with Maven:
mvn spring-boot:run
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.