a2a mcp
A centralized server that tracks and manages connected agents, providing a web interface to monitor their status while enabling agent communication through a central point.
A centralized server that tracks and manages connected agents, providing a web interface to monitor their status while enabling agent communication through a central point.
This project demonstrates two different approaches to agent communication: 1. Master Control Program (MCP) - A centralized server-based approach where agents communicate through a central server 2. Agent-to-Agent (A2A) - A decentralized peer-to-peer approach where agents communicate directly with each other
Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venvScriptsactivate
Install dependencies:
pip install -r requirements.txt
Start the MCP server:
python cli.py run-mcp-server
In separate terminals, start one or more MCP agents:
python cli.py run-mcp-agent --agent-id agent1
python cli.py run-mcp-agent --agent-id agent2
The MCP server will track all connected agents and their status. You can view the status by opening http://localhost:5000 in your browser.
Start the first A2A agent:
python cli.py run-a2a-agent --agent-id a2a1 --port 5001
Start additional A2A agents, connecting them to existing agents:
python cli.py run-a2a-agent --agent-id a2a2 --port 5002 --peer localhost:5001
python cli.py run-a2a-agent --agent-id a2a3 --port 5003 --peer localhost:5001 --peer localhost:5002
A2A agents will automatically discover other agents through their initial peers. You can type messages in any agent s terminal to broadcast them to all connected agents.
a2a_mcp/
├── agents/ # Agent implementations
│ ├── mcp_agent.py # MCP-based agent
│ └── a2a_agent.py # Peer-to-peer agent
├── mcp/ # MCP server implementation
│ └── server.py # Flask-based MCP server
├── cli.py # Command-line interface
└── requirements.txt # Python dependencies
Feel free to submit issues and pull requests to improve the demonstration.