A2A (Agent-to-Agent Protocol)

Google's open protocol for agents to discover, communicate, and collaborate across platforms.

MCP Connects Agents to Tools. A2A Connects Agents to Agents.

MCP solves tool integration. But what happens when your travel agent (built with LangGraph) needs to talk to a payment agent (built with CrewAI on a different server)? A2A, created by Google, standardizes how agents discover each other, negotiate capabilities, and collaborate across organizational boundaries.

A2A vs MCP

MCP (Agent ↔ Tools) Agent 🗄️ DB 📁 Files 🌐 API A2A (Agent ↔ Agent) Travel Agent Payment Agent A2A Calendar Agent Agent Cards (/.well-known/agent.json)

How A2A Works

  1. Agent Card: Every A2A agent publishes a JSON file at /.well-known/agent.json describing its capabilities, accepted inputs, and auth requirements.
  2. Task Lifecycle: The client agent sends a Task (JSON-RPC message). The remote agent processes it. Tasks have states: submitted → working → completed.
  3. Streaming: For long-running tasks, A2A supports Server-Sent Events (SSE) for real-time updates.
  4. Artifacts: Rich outputs (files, images, structured data) are returned as Artifacts attached to the Task.

MCP + A2A Together

These protocols are complementary, not competing. MCP gives an agent access to tools internally. A2A lets that agent collaborate with other agents externally. Production systems use both.

Code Example

A2A Agent Card and basic task flow.

python
1# Agent Card (hosted at /.well-known/agent.json)
2agent_card = {
3    "name": "TravelBookingAgent",
4    "description": "Books flights and hotels",
5    "url": "https://travel-agent.company.com",
6    "version": "1.0.0",
7    "capabilities": {
8        "streaming": True,
9        "pushNotifications": False
10    },
11    "skills": [{
12        "id": "book_flight",
13        "name": "Book Flight",
14        "description": "Search and book flights between cities",
15        "inputModes": ["text/plain", "application/json"],
16        "outputModes": ["application/json"]
17    }],
18    "authentication": {"schemes": ["Bearer"]}
19}
20
21# Client Agent sending a Task via A2A
22import httpx
23
24async def send_a2a_task(agent_url: str, task_description: str):
25    # 1. Discover agent capabilities
26    card = httpx.get(f"{agent_url}/.well-known/agent.json").json()
27    print(f"Agent: {card['name']}")
28    
29    # 2. Send task via JSON-RPC
30    response = httpx.post(f"{agent_url}/a2a", json={
31        "jsonrpc": "2.0",
32        "method": "tasks/send",
33        "params": {
34            "id": "task-001",
35            "message": {
36                "role": "user",
37                "parts": [{"type": "text", "text": task_description}]
38            }
39        }
40    })
41    result = response.json()
42    print(f"Status: {result['result']['status']['state']}")
43    return result

Use Cases

Enterprise agent mesh — different departments publish agents that discover and call each other
Cross-company agent collaboration (your agent books via a partners booking agent)
Agent marketplaces where third-party agents register capabilities via Agent Cards
Microservice-to-agent migration — wrap existing services as A2A agents

Common Mistakes

Confusing A2A with MCP — MCP is for tools, A2A is for agent-to-agent communication
Not implementing proper authentication on Agent Cards — any agent could call your endpoints
Treating A2A as synchronous RPC — long tasks need streaming and async polling
Over-splitting into too many A2A agents when a single multi-tool agent would be simpler

Interview Insight

Relevance

High - Emerging standard for cross-platform agent interoperability.

AI Tutor

Ask about the topic

Sign in Required

Please sign in to use the AI tutor

Sign In