⚔️ A2A vs MCP:Agent协议世纪大对决
两个协议,两种哲学——Agent世界要不要讲"普通话"?
世界上有两种Agent之间的对话方式。一种叫A2A,Google发明了它,就像给Agent们建了一个联合国——每个Agent有自己的语言,但大家用标准格式交流。
另一种叫MCP,Anthropic搞出来的,就像给Agent配了一个万能工具箱——不管你是什么Agent,都能用同一套工具。
它们不是敌人,更像是一对互补的搭档。一个负责"聊天",一个负责"干活"。
快速概览
🔵 A2A Protocol
全称:Agent-to-Agent Protocol
发起方:Google (2025年4月)
定位:Agent之间的通用通信协议
类比:Agent界的"微信"——让不同Agent能互加好友、聊天
🩷 MCP Protocol
全称:Model Context Protocol
发起方:Anthropic (2024年11月)
定位:AI模型与工具/数据源的标准接口
类比:Agent界的"USB接口"——标准化工具接入
核心区别对比
| 维度 |
A2A (Google) |
MCP (Anthropic) |
| 核心问题 |
Agent之间如何对话? |
Agent如何使用工具? |
| 通信方向 |
Agent ↔ Agent(对等通信) |
Model → Tool(单向调用) |
| 传输协议 |
HTTP + JSON-RPC |
stdio / HTTP+SSE |
| 消息格式 |
Task + Message + Part |
Request → Response |
| 状态管理 |
原生支持长期任务状态 |
无状态,每次调用独立 |
| 发现机制 |
Agent Card(自描述) |
手动配置 Server 列表 |
| 工具能力 |
有限(Agent间协作为主) |
丰富(三种工具类型) |
| 流式输出 |
原生支持Task事件流 |
SSE 流式传输 |
| 安全模型 |
信任 + 授权委托 |
权限提示 + 用户审批 |
| 适用场景 |
多Agent协作编排 |
工具集成与数据访问 |
| 生态系统 |
Google主导,增长中 |
社区驱动,生态繁荣 |
A2A Protocol 详解
A2A的核心思想是让Agent之间能像人一样协作——发送任务、讨论进度、交换结果。
{
"jsonrpc": "2.0",
"method": "tasks/send",
"params": {
"id": "task-001",
"message": {
"role": "user",
"parts": [
{ "type": "text", "text": "帮我分析这个数据集" },
{ "type": "file", "mimeType": "text/csv", "url": "..." }
]
}
}
}
{
"name": "Data Analyst Agent",
"description": "专门做数据分析的Agent",
"url": "https://agents.example.com/data-analyst",
"capabilities": {
"streaming": true,
"pushNotifications": true
},
"skills": ["data-analysis", "visualization"]
}
A2A 的优势
- 任务生命周期管理 - 提交、更新、完成、取消,全流程覆盖
- Agent Card发现 - Agent可以自动发现彼此
- 事件流 - 实时了解任务进展
- Push通知 - 任务完成时主动通知
MCP Protocol 详解
MCP的核心思想是标准化工具接入——一个Agent可以连接任意数量的工具服务器。
{
"name": "search_web",
"description": "搜索互联网",
"inputSchema": {
"type": "object",
"properties": {
"query": { "type": "string" }
}
}
}
{
"uri": "file:///data/report.pdf",
"name": "季度报告",
"mimeType": "application/pdf"
}
{
"name": "code_review",
"description": "代码审查模板",
"arguments": [
{ "name": "code", "required": true }
]
}
MCP 的优势
- 工具标准化 - 写一次工具,所有MCP客户端都能用
- 本地+远程 - stdio本地进程和HTTP远程服务都支持
- 丰富生态 - 大量现成的MCP Server可直接使用
- 安全模型 - 用户对工具调用有审批权
A2A + MCP = 完美搭档
这两个协议不是竞争关系,而是互补的。最好的Agent系统会同时使用两者:
Agent A
├── MCP Server: "Web Search"
├── MCP Server: "Database"
└── MCP Server: "File System"
Agent B
├── MCP Server: "Email"
├── MCP Server: "Calendar"
└── MCP Server: "Slack"
Agent A ←——A2A——→ Agent B
简单理解:
MCP = Agent的"手"和"眼睛"——用来拿工具、看数据
A2A = Agent的"嘴巴"和"耳朵"——用来和其他Agent说话
它们合在一起,Agent才真正有了完整的"身体"。
OpenClaw 如何使用两个协议
mcp_servers:
web_search:
command: "npx"
args: ["@anthropic/mcp-server-brave-search"]
database:
command: "npx"
args: ["@anthropic/mcp-server-postgres"]
a2a:
enabled: true
peers:
- name: "coding_agent"
url: "https://agents.example.com/coder"
- name: "review_agent"
url: "https://agents.example.com/reviewer"
选择建议
| 场景 |
推荐协议 |
原因 |
| 给Agent添加工具(搜索、数据库等) |
MCP |
工具标准化,生态丰富 |
| 多个Agent协作完成复杂任务 |
A2A |
Agent间通信原支持 |
| Agent需要访问外部数据源 |
MCP |
Resource类型天然支持 |
| 长时间任务需要状态同步 |
A2A |
Task生命周期管理 |
| 构建完整的多Agent系统 |
A2A + MCP |
两者互补,效果最佳 |
常见问题
你需要知道:
- ❌ A2A和MCP不是二选一——它们解决不同问题
- ❌ MCP工具不能直接被A2A协议使用——需要转换层
- ❌ 两个协议都在快速演进——API可能变化
- ✅ OpenClaw同时支持两种协议