๐Ÿค– Google A2A RAG with Spring, Java, and MongoDB Atlas

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. It is deployed live on Hugging Face at:

https://vishalmysore-a2amcpmongo.hf.space/

You can discover active agents via:

https://vishalmysore-a2amcpmongo.hf.space/.well-known/agent.json

a2ajava is a Swiss Army knife for building agentic applications. It is multi-protocol โ€” works seamlessly with both A2A (Agent-to-Agent) and MCP (Model Context Protocol). It is multi-language โ€” supports Java, Kotlin, and Groovy. It is multi-platform โ€” compatible with Gemini, OpenAI, Claude, and Grok. It is multi-client โ€” includes A2A and MCP clients with connectors in Java, Node, and Python. It offers multi-integration โ€” out-of-the-box support for Selenium, human-in-the-loop workflows, and multi-LLM voting for consensus-based decision making. Agents built using the A2A protocol with a2ajava run seamlessly on MCP as well, ensuring maximum interoperability across platforms.

๐ŸŒŸ Key Features

๐Ÿ› ๏ธ Technology Stack

Architecture

๐Ÿ“ How It Works

Vector Storage Integration

@Override
public void preProcessing(String method, Object params) {
    vectorService.ragStorage(method, params);
}

Task Management

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;
    }
}

๐Ÿ“ธ Visual Guide

1. Agent Setup

Agent Addition

2. Chat Interface

Chat Interface

3. Data Storage

MongoDB Storage

4. Event Monitoring

Event Tracking

5. Claude

Claude tool calling

6. Claude tool chain

Claude tool calling

๐Ÿ” Using the API

Swagger

https://vishalmysore-a2amcpmongo.hf.space/swagger-ui/index.html

Task Retrieval Example

GET https://vishalmysore-a2amcpmongo.hf.space/taskText?name="cricket"
Task Retrieval

A2A Curl

curl -H "Content-Type: application/json" -d {"id": "adk-342d4575-992d-40ce-a375-55081b3744cd", "args": {"agent_name": "LaundryAssistant", "message": "wash my golf clothes and make them really shiny"}, "name": "send_task"}

๐Ÿงบ Laundry Machine Agent Curl Commands for Claude

# List Tool
curl -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"method": "tools/list",
"params": {

}
},
"id": 1
}' https://vishalmysore-a2amcpmongo.hf.space/
# Start Washing
curl -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "startWashing",
    "arguments": {
      "provideAllValuesInPlainEnglish": {}
    }
  },
  "id": 1
}' https://vishalmysore-a2amcpmongo.hf.space/

# Stop Washing
curl  -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "stopWashing",
    "arguments": {
      "provideAllValuesInPlainEnglish": {}
    }
  },
  "id": 2
}' https://vishalmysore-a2amcpmongo.hf.space/

# Set Temperature to 40
curl -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "setTemperature",
    "arguments": {
      "provideAllValuesInPlainEnglish": {
        "arg0": 40
      }
    }
  },
  "id": 3
}' https://vishalmysore-a2amcpmongo.hf.space/

# Set Cycle Type to 'delicate'
curl -u user:password -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "setCycleType",
    "arguments": {
      "provideAllValuesInPlainEnglish": {
        "arg0": "delicate"
      }
    }
  },
  "id": 4
}' https://vishalmysore-a2amcpmongo.hf.space/

# Get Quote for Laundry
curl -u user:password -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "getQuoteForLaundry",
    "arguments": {
      "provideAllValuesInPlainEnglish": {
        "arg0": "cotton",
        "arg1": "3kg"
      }
    }
  },
  "id": 5
}' https://vishalmysore-a2amcpmongo.hf.space/

# Get Machine Status
curl -u user:password -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "getStatus",
    "arguments": {
      "provideAllValuesInPlainEnglish": {}
    }
  },
  "id": 6
}' https://vishalmysore-a2amcpmongo.hf.space/

๐Ÿš€ Getting Started

  1. Clone the repository
  2. Configure MongoDB Atlas connection in application.yml
  3. Set up environment variables:
  4. Build and run with Maven:
    mvn spring-boot:run

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.