Cross-Protocol SQL Agent

An open-source initiative to bridge A2A and MCP protocols in Java

Built with ❤️ by the community, for the community

Project Vision

This project represents my initiative to create a bridge between different AI agent protocols. Built as an open-source effort, it demonstrates how to create a database agent that works seamlessly with both A2A (Agent-to-Agent) and MCP (Model Context Protocol) specifications.

Community Contribution

This is an open-source project aimed at fostering collaboration in the AI agent ecosystem. Your feedback and contributions are welcome!

Security Implementation

The agent implements robust security using Spring Security with method-level permissions. Different operations require different access levels:

# User-level operations
@PreAuthorize("hasRole('USER')")
@Action(description = "Create tables")
public String createTables(TableData tableData) { ... }

# Admin-level operations
@PreAuthorize("hasRole('ADMIN')")
@Action(description = "Create database")
public String createDatabase(String name) { ... }

# Public operations
@PreAuthorize("permitAll()")
@Action(description = "View database info")
public String getDatabaseInfo() { ... }
Security Features
  • Method-level authorization using @PreAuthorize
  • Role-based access control (USER, ADMIN roles)
  • Actions annotated with @Action for protocol compatibility
  • Integration with both A2A and MCP authentication flows

About a2ajava

The project is built on a2ajava, an open-source framework I developed to simplify agent development. It's designed to be:

Join the Development

Love working with AI agents? Check out the GitHub repository to contribute or provide feedback!

API Examples

Note: Replace localhost with https://vishalmysore-a2amcpdatabase.hf.space/ for the hosted version.

A2A Authentication Examples

# Basic user authentication
curl -u user:password http://localhost:7860/.well-known/agent.json

# No authentication
curl http://localhost:7860/.well-known/agent.json

# Admin authentication
curl -u admin:admin http://localhost:7860/.well-known/agent.json

A2A Task Execution

curl -v -u user:password \
-H "Content-Type: application/json" \
-d '{
    "jsonrpc": "2.0",
    "method": "tasks/send",
    "params": {
        "id": "0e2fc442-180f-4cd2-b316-08b384bb236f",
        "sessionId": "fbe485db-c295-40d0-bb9c-bb16367df091",
        "message": {
            "role": "user",
            "parts": [
                {
                    "type": "text",
                    "text": "can you start the database server cookgpt",
                    "metadata": null
                }
            ]
        }
    }
}' \
http://localhost:7860/

MCP Tools Management

# List available tools
curl -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"tools/list","params":{},"id":9}' \
    http://localhost:7860/

# Create database (admin only)
curl -u admin:admin \
    -H "Content-Type: application/json" \
    -d '{
        "jsonrpc": "2.0",
        "method": "tools/call",
        "params": {
            "name": "createDatabase",
            "arguments": {
                "provideAllValuesInPlainEnglish": {
                    "name": "cookgpt"
                }
            }
        },
        "id": 25
    }' \
    http://localhost:7860/