A2A MCP服务器
一 MCP服务器 实现了一个 A2A客户端 为了 A2A协议. 服务器可用于连接A2A服务器(远程代理)并向其发送消息。
服务器需要用一个或多个初始化 代理卡 URL,每个URL都可以有用于身份验证、配置等的自定义标头。
所有代理(名称和描述)都可以通过以下方式查看 get_agents 工具,可以使用查看代理的技能(名称和描述) get_agent 工具,消息可以通过以下方式发送给代理 send_message 工具,可以使用轮询长时间运行的任务 get_task,以及 人工制品 可以通过以下方式查看 view_text_artifact 和 view_data_artifact 工具。
✨ 特性
- 6个MCP工具 —
get_agents,get_agent,send_message,get_task,view_text_artifact,以及view_data_artifact用于与A2A代理通信 - 简单消息发送 --通过ID向任何A2A代理发送消息;代理卡提取、标头和非阻塞流式传输都是自动处理的
- 多回合对话 --使用以下命令跨多条消息继续对话
context_id - 长期运行任务支持 --如果
send_message超时,使用get_task监视任务,直到它达到终端状态 - 自动伪影最小化 --LLM上下文窗口的大型文本和数据工件会自动最小化,并使用专用工具进行详细导航
- 任务和文件存储 --任务和文件工件保存在本地
~/.a2a-mcp/默认情况下 - 自定义标头和身份验证 -为API密钥和其他凭据配置per-agent自定义标头
- 可配置的超时和限制 --通过环境变量自定义超时、轮询间隔和字符限制
📋 需求
要运行服务器,如果还没有安装uv,则需要安装uv。
MacOS/Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh窗户:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"🚀 快速开始
- 下载 Claude桌面版
- 将以下内容添加到您的Claude Desktop配置中(
~/Library/Application Support/Claude/claude_desktop_config.json在macOS上):
{
"mcpServers": {
"a2a": {
"command": "uvx",
"args": ["a2anet-mcp"],
"env": {
"A2A_MCP_AGENT_CARDS": "{\"tweet-search\": {\"url\": \"https://example.com/.well-known/agent-card.json\"}}"
}
}
}
}提示: 如果您没有代理卡URL,请参阅: A2A网络演示
⚙️ 配置
所有配置都是通过前缀为的环境变量进行的 A2A_MCP_.
A2A_MCP_AGENT_CARDS (必填)
JSON对象将代理ID映射到其配置。每个代理都必须有一个 url 带有代理卡完整路径的密钥。它可以选择具有 custom_headers 表单中带有对象的键 {"header": "value"}:
export A2A_MCP_AGENT_CARDS='{
"tweet-search": {
"url": "https://example.com/.well-known/agent-card.json",
"custom_headers": {"X-API-Key": "your-key"}
}
}'可选设置
| 环境变量 | 默认值 | 描述 |
|---|---|---|
A2A_MCP_TASK_STORE | true | 通过以下方式实现任务持久性 JSONTaskStore |
A2A_MCP_FILE_STORE | true | 通过以下方式启用文件工件存储 LocalFileStore |
A2A_MCP_SEND_MESSAGE_CHARACTER_LIMIT | 50000 | 伪影最小化的字符限制 send_message |
A2A_MCP_MINIMIZED_OBJECT_STRING_LENGTH | 5000 | 最小化对象时的最大字符串长度 |
A2A_MCP_VIEW_ARTIFACT_CHARACTER_LIMIT | 50000 | 字符限制 view_text_artifact / view_data_artifact |
A2A_MCP_AGENT_CARD_TIMEOUT | 15 | 提取代理卡的超时时间(秒) |
A2A_MCP_SEND_MESSAGE_TIMEOUT | 60 | 超时时间(秒) send_message |
A2A_MCP_GET_TASK_TIMEOUT | 60 | 超时时间(秒) get_task |
A2A_MCP_GET_TASK_POLL_INTERVAL | 5 | 间隔(秒) get_task 民意调查 |
🛠️ 工具
get_agents
获取所有代理名称和描述。
get_agent
获取代理的名称、描述以及技能名称和描述。
| 参数 | 必填 | 说明 |
|---|---|---|
agent_id | 是 | 代理ID |
send_message
向代理发送消息。
| 参数 | 必填 | 说明 |
|---|---|---|
agent_id | 是 | 来自的代理ID get_agents |
message | 是 | 您的消息或请求 |
context_id | 否 | 继续现有对话 |
task_id | 否 | input_required流的任务ID |
timeout | 否 | 覆盖HTTP超时(秒) |
get_task
获取任务的当前状态。监控直到终端/可操作状态或超时。超时时,返回当前任务状态(可能仍然是非终端状态)。
| 参数 | 必填 | 说明 |
|---|---|---|
agent_id | 是 | 拥有该任务的代理ID |
task_id | 是 | 以前的任务ID send_message |
timeout | 否 | 覆盖监控超时(秒) |
poll_interval | 否 | 覆盖轮询之间的间隔(秒) |
view_text_artifact
通过可选的行或字符范围选择查看工件中的文本内容。
| 参数 | 必填 | 说明 |
|---|---|---|
agent_id | 是 | 生成工件的代理ID |
task_id | 是 | 包含工件的任务ID |
artifact_id | 是 | 要查看的工件 |
line_start | 否 | 起始行号(从1开始,包括1) |
line_end | 否 | 结束行号(从1开始,含1) |
character_start | 否 | 起始字符索引(从0开始) |
character_end | 否 | 结束字符索引(从0开始) |
view_data_artifact
通过可选的过滤从工件中查看结构化数据。
| 参数 | 必填 | 说明 |
|---|---|---|
agent_id | 是 | 生成工件的代理ID |
task_id | 是 | 包含工件的任务ID |
artifact_id | 是 | 要查看的工件 |
json_path | 否 | 提取特定字段的点分隔路径 |
rows | 否 | 行选择(索引、列表、范围字符串或“全部”) |
columns | 否 | 列选择(名称、列表或“全部”) |
📖 例子
列表代理
get_agents({}){
"tweet-search": {
"name": "Tweet Search",
"description": "Find and analyze tweets by keyword, URL, author, list, or thread. Filter by language, media type, engagement, date range, or location. Get a clean table of tweets with authors, links, media, and counts; then refine the table and generate new columns with AI."
}
}获取代理详细信息
get_agent({
"agent_id": "tweet-search"
}){
"name": "Tweet Search",
"description": "Find and analyze tweets by keyword, URL, author, list, or thread. Filter by language, media type, engagement, date range, or location. Get a clean table of tweets with authors, links, media, and counts; then refine the table and generate new columns with AI.",
"skills": [
{
"name": "Search Tweets",
"description": "Search X by keywords, URLs, handles, or conversation IDs. Filter by engagement (retweets/favorites/replies), dates, language, location, media type (images/videos/quotes), user verification status, and author/reply/mention relationships. Sort by Top or Latest. Return 1-10,000 results."
},
...,
{
"name": "Generate Table",
"description": "Generate a new table from any table with AI. Explain what table you want to generate from, what columns you want to keep, and what new columns you want to generate."
}
]
}发送消息
send_message({
"agent_id": "tweet-search",
"message": "Find tweets about AI from today (January 12, 2026)"
}){
"id": "tsk-123",
"context_id": "ctx-123",
"kind": "task",
"status": {
"state": "completed",
"message": {
"context_id": "ctx-123",
"kind": "message",
"parts": [
{
"kind": "text",
"text": "I found 10 tweets about \"AI\" posted on January 12, 2026. The search parameters used were:\n\n- Search Terms: AI\n- Start Date: 2026-01-12\n- End Date: 2026-01-13\n- Maximum Items: 10\n\nWould you like to see more tweets, or do you want a summary or analysis of these results?"
}
]
}
},
"artifacts": [
{
"artifact_id": "art-123",
"description": "Tweets about AI posted on January 12, 2026.",
"name": "AI Tweets from January 12, 2026",
"parts": [
{
"kind": "data",
"data": {
"records": {
"_total_rows": 10,
"_columns": [
{
"count": 1,
"unique_count": 1,
"types": [
{
"name": "int",
"count": 1,
"percentage": 100.0,
"sample_value": 213,
"minimum": 213,
"maximum": 213,
"average": 213
}
],
"name": "quote.author.mediaCount"
},
...,
{
"count": 10,
"unique_count": 1,
"types": [
{
"name": "bool",
"count": 10,
"percentage": 100.0,
"sample_value": false
}
],
"name": "isPinned"
}
]
},
"_tip": "Data was minimized. Call view_data_artifact() to navigate to specific data."
}
}
]
}
]
}处理长时间运行的任务
如果远程代理需要的时间超过 A2A_MCP_SEND_MESSAGE_TIMEOUT (默认值:60秒), send_message 返回当前状态的任务:
send_message({
"agent_id": "tweet-search",
"message": "Find tweets about AI from today (January 12, 2026)"
}){
"id": "tsk-123",
"context_id": "ctx-123",
"kind": "task",
"status": {
"state": "working",
"message": null
},
"artifacts": []
}使用 get_task 检查进度:
get_task({
"agent_id": "tweet-search",
"task_id": "tsk-123"
})完成后,响应将与中显示的格式匹配 发送消息。如果仍在工作,请致电 get_task 再次继续监测。
多回合对话
使用 context_id 要继续对话,请执行以下操作:
send_message({
"agent_id": "tweet-search",
"message": "Can you summarize each of the 10 tweets in the table in 3-5 words each? Just give me a simple list with the author name and summary.",
"context_id": "ctx-123"
}){
"id": "tsk-456",
"context_id": "ctx-123",
"kind": "task",
"status": {
"state": "completed",
"message": {
"context_id": "ctx-123",
"kind": "message",
"parts": [
{
"kind": "text",
"text": "Here is a simple list of each tweet's author and a 3-5 word summary:\n\n1. alienofeth – Real-time STT intent detection\n2. UnderdogEth_ – AI ownership discussion thread\n3. Count_Down_000 – Learning new vocabulary word\n4. ThaJonseBoy – AI and market predictions\n5. Evelyn852422353 – AI model comparison debate\n6. SyrilTchouta – Language learning with AI\n7. cx. – AI in marketing insights\n8. Halosznn_ – Graphic design course shared\n9. xmaquina – AI smarter models discussion\n10. Flagm8_ – AI and business strategy\n\nLet me know if you want more details or a different format!"
}
]
}
},
"artifacts": [
{
"artifact_id": "art-456",
"description": "A simple list of each tweet's author and a 3-5 word summary of the tweet content.",
"name": "AI Tweet Summaries 3-5 Words",
"parts": [
{
"kind": "data",
"data": {
"records": [
{
"author.userName": "ai_q2_",
"summary": "Possibly understand"
},
...,
{
"author.userName": "CallStackTech",
"summary": "Real-time STT intent detection"
}
]
}
}
]
}
]
}查看数据工件
view_data_artifact({
"agent_id": "tweet-search",
"task_id": "tsk-123",
"artifact_id": "art-123",
"json_path": "records",
"rows": "all",
"columns": ["author.userName", "text"]
}){
"artifact_id": "art-123",
"description": "Tweets about AI posted on January 12, 2026.",
"name": "AI Tweets from January 12, 2026",
"parts": [
{
"kind": "data",
"data": [
{
"author.userName": "ai_q2_",
"text": "@nyank_x わかるかもしれない"
},
...,
{
"author.userName": "CallStackTech",
"text": "Just built a real-time STT pipeline that detects intent faster than you can say \"Hello!\" 🎤✨ Discover how I used Deepgram to achieve su...\n\n🔗 https://t.co/dgbvdlATZ0\n\n#VoiceAI #AI #BuildInPublic"
}
]
}
]
}💾 数据存储
任务和文件工件在本地持久化 ~/.a2a-mcp/:
- 任务:
~/.a2a-mcp/tasks/ - 文件:
~/.a2a-mcp/files/
两者都可以通过环境变量禁用(A2A_MCP_TASK_STORE=false, A2A_MCP_FILE_STORE=false).
🔧 发展
Claude桌面设置
对于当地发展:
- 克隆存储库:
git clone https://github.com/a2anet/a2a-mcp.git - 下载 Claude桌面版.
- 添加到下面的Claude Desktop配置中(
~/Library/Application Support/Claude/claude_desktop_config.json在macOS上):
{
"mcpServers": {
"a2a": {
"command": "uv",
"args": ["--directory", "/path/to/a2a-mcp", "run", "a2anet-mcp"],
"env": {
"A2A_MCP_AGENT_CARDS": "{\"tweet-search\": {\"url\": \"https://example.com/.well-known/agent-card.json\"}}"
}
}
}
}📄 许可证
a2anet 根据《 阿帕奇-2.0 许可证。
🤝 加入A2A网络社区
A2A-Net是一个寻找和分享人工智能代理和开源社区的网站。加入我们,分享您的A2A代理,提出问题,了解最新的A2A新闻,成为第一个了解开源版本、教程等的人!
