a2a-bridge
Enables bidirectional A2A communication between AI coding agents, allowing Claude Code to reach out to and be reached by other A2A agents via an MCP bridge and an HTTP server.
README
A2A Bridge — Bidirectional Multi-Agent Communication
Two companion servers enabling full bidirectional A2A communication between AI coding agents:
- a2a-bridge (MCP server) — Outbound: Claude Code/Gemini/OpenCode reach A2A agents
- a2a-server (HTTP server) — Inbound: A2A agents reach Claude Code
Architecture
Outbound (MCP bridge)
Claude Code ─┐
Gemini CLI ─┤─ MCP (stdio) ─► a2a-bridge ─► Elastic Agent Builder
OpenCode ─┘ ─► Gemini CLI A2A Server
─► Any standard A2A agent
Inbound (A2A server)
Gemini CLI ──A2A──► a2a-server (HTTP :3008) ──subprocess──► claude -p
Other agents /.well-known/agent-card.json
Tools
| Tool | Description |
|---|---|
list_agents |
List all agents across all configured providers |
get_agent_card |
Get an agent's A2A card (capabilities, skills, metadata) |
send_message |
Send a message to an agent via A2A and get a response |
Agent IDs use compound format: provider/agentId (e.g., elastic/dev_assistant, gemini-local/default). Bare IDs auto-resolve when only one provider is configured.
Prerequisites
- Node.js 18+
- At least one A2A-compatible agent endpoint (Elastic Agent Builder, Gemini CLI A2A server, etc.)
Quick Start
Initial Setup (One-Time)
- Clone and install:
git clone <repo-url>
cd native-api
npm install
npm run build
- Create a
.envfile (sole source of truth for all credentials):
# For Elastic provider
KIBANA_URL=https://your-deployment.kb.elastic-cloud.com
ELASTIC_API_KEY=your-api-key
# Optional: For Gemini or other A2A servers
# MY_AGENT_TOKEN=your-token-here
- (Optional) Create
agents.jsonfor multi-provider setup:
cp agents.json.example agents.json
# Edit agents.json to add your providers
Without agents.json, the system auto-creates an Elastic provider from .env variables.
Running Bidirectional A2A (Three Terminals)
Open three terminal windows and run these commands in parallel:
Terminal 1 — Claude Code A2A Server (receives messages from Gemini):
npm run serve
# Output: "A2A server listening on http://127.0.0.1:3008"
Terminal 2 — Gemini CLI A2A Server (receives messages from Claude):
npm run gemini-a2a
# Output: "A2A server listening on port 41965"
Terminal 3 — Claude Code or Gemini CLI for testing:
# In Claude Code, use the MCP bridge:
# List the available A2A agents
# Ask the gemini-local/default agent to [task]
# Or from Gemini CLI:
# /agents list
# /ask claude-code "do something"
Claude Code Integration
Open the project in Claude Code. The .mcp.json auto-starts the MCP bridge:
- Verify the server:
/mcp— you should seea2a-bridgelisted - Try: "List the available A2A agents" → should show agents including
gemini-local/default - Try: "Ask the gemini-local/default agent to list files in the current directory"
Gemini CLI Integration
Configure Gemini to discover Claude Code as an A2A agent:
-
Copy the agent config:
mkdir -p ~/.gemini/agents cp examples/gemini-agents/claude-code.md ~/.gemini/agents/ -
Verify:
/agents listin Gemini CLI should showclaude-code -
Try:
/ask claude-code "list my open files"
Usage
Outbound (MCP bridge — npm start)
> List the available A2A agents
> Get the agent card for elastic/dev_assistant
> Ask the elastic/dev_assistant agent to list the available indices
> Send a message to gemini-local/default asking it to summarize this file
Inbound (A2A server — npm run serve)
Start the A2A server to let other agents talk to Claude Code:
npm run serve
This exposes Claude Code at http://localhost:3008 with a standard A2A agent card. Gemini CLI (or any A2A client) can discover and message it. See Bidirectional Demo for a full walkthrough.
Configuration
Credentials (.env)
.env is the single source of truth for all secrets. Never put credentials in agents.json or .mcp.json.
KIBANA_URL=https://your-deployment.kb.elastic-cloud.com
ELASTIC_API_KEY=your-api-key
MY_AGENT_TOKEN=your-token-here
Provider Registry (agents.json)
agents.json defines which A2A providers to connect to. It references env var names for secrets — never raw values. This file is safe to commit.
{
"providers": [
{
"type": "elastic",
"name": "elastic",
"baseUrl": "${KIBANA_URL}",
"auth": {
"scheme": "api-key",
"envVar": "ELASTIC_API_KEY",
"headers": { "kbn-xsrf": "true" }
}
},
{
"type": "a2a",
"name": "gemini-local",
"baseUrl": "http://localhost:41965",
"auth": { "scheme": "none" }
},
{
"type": "a2a",
"name": "my-remote-agent",
"baseUrl": "https://agent.example.com",
"auth": {
"scheme": "bearer",
"envVar": "MY_AGENT_TOKEN"
}
}
]
}
Provider types:
elastic— Elastic Agent Builder (Kibana-specific endpoints and auth)a2a— Standard A2A agent (well-known discovery at/.well-known/agent-card.json)
Auth schemes:
api-key—Authorization: ApiKey <value>headerbearer—Authorization: Bearer <value>headerheader— Custom static headers onlynone— No authentication (local agents)
Backward Compatibility
If no agents.json exists, the server auto-creates an Elastic provider from KIBANA_URL and ELASTIC_API_KEY environment variables. Existing setups work without changes.
MCP Config (.mcp.json)
{
"mcpServers": {
"a2a-bridge": {
"command": "node",
"args": ["--env-file=.env", "dist/index.js"]
}
}
}
Using in Other Clients
See the docs/ directory for client-specific setup guides:
User-level MCP config (Claude Code)
Register the server once for all Claude Code sessions:
claude mcp add --scope user a2a-bridge node -- --env-file=/path/to/project/.env /path/to/project/dist/index.js
A2A Protocol Details
- Standard A2A: Discovery via
/.well-known/agent-card.json, messaging viaPOSTwith JSON-RPC 2.0message/send - Elastic A2A: Agent card at
/api/agent_builder/a2a/{id}.json, messaging at/api/agent_builder/a2a/{id} - Part format:
kind: "text"discriminator (A2A v0.3+) - Streaming: Not currently supported
Security
.envis the sole credential store (gitignored, 600 permissions)- HTTPS enforced for all non-localhost URLs
- Agent ID validation:
[a-zA-Z0-9_.-]{1,128}per segment - 30s request timeout, 32KB message size limit
- Error sanitization: internal details logged to stderr only
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。