Pattern Code Copy # A2A + MCP Bridge Architecture
## Overview
Agent-to-Agent (A2A) handles **inter-agent communication**
MCP handles **agent-to-tool communication**
```
┌─────────────────────────────────────────┐
│ Orchestrator │
│ (A2A Client + MCP Host) │
└──────┬──────────┬──────────┬────────────┘
│ A2A │ A2A │ A2A
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Research │ │ Coding │ │ Review │
│ Agent │ │ Agent │ │ Agent │
│ (Remote) │ │ (Local) │ │ (Remote) │
└────┬─────┘ └────┬─────┘ └────┬─────┘
│ MCP │ MCP │ MCP
▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌─────────┐
│ Web │ │ GitHub │ │ Sentry │
│ Search │ │ MCP │ │ MCP │
│ MCP │ │ Server │ │ Server │
└─────────┘ └─────────┘ └─────────┘
```
## Agent Card (A2A Discovery)
```json
{
"name": "coding-agent",
"description": "Implements code changes per specification",
"url": "https://agents.example.com/coding",
"capabilities": {
"streaming": true,
"pushNotifications": true
},
"skills": [
{ "id": "implement", "name": "Code Implementation" },
{ "id": "refactor", "name": "Code Refactoring" }
],
"mcpServers": [
{ "name": "github", "transport": "stdio" },
{ "name": "postgres", "transport": "streamable-http" }
]
}
```
## Orchestration Flow
```typescript
// 1. Discover available agents via A2A
const agents = await a2aClient.discover();
// 2. Create task for research agent
const researchTask = await a2aClient.createTask(
agents.find(a => a.skills.includes('research')),
{ message: "Research best practices for auth middleware" }
);
// 3. Wait for research, then delegate to coding agent
const researchResult = await a2aClient.waitForTask(researchTask.id);
const codingTask = await a2aClient.createTask(
agents.find(a => a.skills.includes('implement')),
{
message: "Implement auth middleware based on research",
context: researchResult.artifacts
}
);
// 4. Each agent uses MCP internally for tool access
// coding-agent → GitHub MCP (create branch, commit)
// coding-agent → PostgreSQL MCP (check schema)
// review-agent → Sentry MCP (check error patterns)
```
## Key Design Principles
1. **A2A for delegation**: agents don't call each other's tools directly
2. **MCP for tools**: each agent manages its own MCP connections
3. **Agent Cards for discovery**: no hardcoded agent endpoints
4. **Task lifecycle via A2A**: submitted → working → completed/failed
Copy this pattern into your project configuration to implement.