Skip to main content
Glama

A2A ⚡ MCP 特工

该项目演示了两种不同的代理通信方法:

  1. 主控制程序 (MCP) - 一种基于集中式服务器的方法,代理通过中央服务器进行通信

  2. 代理对代理(A2A) ——一种去中心化的点对点方法,代理之间可以直接通信

安装

  1. 创建并激活虚拟环境:

python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
  1. 安装依赖项:

pip install -r requirements.txt

Related MCP server: Playwright MCP Server

用法

MCP 服务器和代理

  1. 启动 MCP 服务器:

python cli.py run-mcp-server
  1. 在单独的终端中,启动一个或多个 MCP 代理:

python cli.py run-mcp-agent --agent-id agent1 python cli.py run-mcp-agent --agent-id agent2

MCP 服务器会追踪所有已连接的代理及其状态。您可以在浏览器中打开http://localhost:5000查看状态。

A2A(代理到代理)网络

  1. 启动第一个 A2A 代理:

python cli.py run-a2a-agent --agent-id a2a1 --port 5001
  1. 启动其他 A2A 代理,并将它们连接到现有代理:

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 代理将通过其初始同伴自动发现其他代理。您可以在任何代理的终端中输入消息,以将其广播给所有连接的代理。

建筑学

MCP(主控制程序)

  • 跟踪所有代理的集中式服务器

  • 代理向服务器注册并通过心跳维持连接

  • 服务器提供Web界面来监控代理状态

  • 简单可靠,但存在单点故障

A2A(代理对代理)

  • 去中心化的点对点网络

  • 代理之间直接连接

  • 信息在网络上泛滥

  • 更具弹性,但需要更复杂的协调

  • 无单点故障

项目结构

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

贡献

请随意提交问题并请求改进演示。

-
security - not tested
-
license - not tested
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/khulnasoft-com/a2a-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server