Chapter 12 of 32 · ~15 min read & lab+65 XP
Chapter 12 · Agentic AI

Agent-to-Agent (A2A) Protocol vs. MCP: Cross-Agent Interoperability

Understand how MCP connects an agent to tools and data while A2A connects autonomous agents across teams, frameworks, and organizations

What Is It?

The Agent-to-Agent (A2A) protocol is an open HTTP/JSON-RPC standard for independent AI agents to discover each other via Agent Cards and collaborate on asynchronous tasks—complementing MCP, which connects an agent to tools and data.

Why Is It Required?

Enterprises quickly end up with separate agents built on different stacks (a billing agent in LangGraph, a travel agent in ADK, an HR agent in CrewAI) that must delegate work without exposing each other's internal prompts, memory, or tools.

Everyday Analogy: MCP is the USB-C cable connecting your laptop to a monitor or external drive (agent-to-tool); A2A is email and Slack between two independent specialists collaborating on a project without sharing their private desk drawers (agent-to-agent).
Why ML Engineers & Data Scientists Actually Need This

In 2025–2026 system design interviews, 'MCP vs. A2A' is one of the fastest-rising architecture questions for Senior AI Engineers.

ML / AI Engineer

You decide where to draw the boundary: expose deterministic functions/resources via MCP servers, and expose opaque, multi-turn specialist agents via A2A Agent Cards and task endpoints.

Data Scientist

You trace cross-agent delegation latency, task handoff failure rates, and artifact quality across organizational boundaries.

Interview & Debug Edge

Never frame MCP and A2A as competitors. The winning answer is that they are complementary layers: an A2A specialist agent internally uses MCP to talk to its own databases and APIs.

Step 0 · Test Your Gut Before Any Math!

Your Travel Planning Agent needs to delegate hotel booking to a partner company's Hotel Concierge Agent, which may take 3 minutes and ask a clarifying question. Which protocol fits best?

What You Will Master in This Chapter
  • Model Context Protocol (MCP) Architecture
  • Familiarity with HTTP REST/JSON-RPC APIs and asynchronous tasks
Story-First Intuition, Visual Diagrams & Interactive Walkthroughs

Think of MCP as vertical integration (one agent reaching down to its tools, databases, and files) and A2A as horizontal integration (peer agents delegating goals across team or company boundaries while keeping their internals encapsulated).

1. MCP vs. A2A Side-by-Side Comparison

DimensionModel Context Protocol (MCP)Agent-to-Agent (A2A) Protocol
Primary RelationshipAgent ↔ Tool / Data SourceClient Agent ↔ Remote Specialist Agent
Abstraction LevelLow-level deterministic calls (tools/call, resources/read)Goal-oriented tasks, artifacts & multi-turn messages
Discovery MechanismServer capability negotiation (tools/list)Public Agent Card at /.well-known/agent.json
Execution LifecycleTypically short request/responseAsync stateful tasks (submitted, working, input-required, completed)
EncapsulationExposes exact tool schemasOpaque: hides remote agent's prompts, memory & private MCP tools

2. How an A2A Agent Card & Task Lifecycle Work

  1. Discovery: The client agent fetches https://specialist.example.com/.well-known/agent.json to read the remote agent's skills, supported modalities (text, files, JSON), and auth requirements (OAuth2 / API key).
  2. Task Creation (tasks/send or tasks/sendSubscribe): The client sends a goal message and receives a task_id with status working (plus optional SSE progress updates).
  3. Interactive Clarification: If the remote agent needs missing info, it transitions to input-required and asks the client agent—no fragile timeout hacks.
  4. Artifact Delivery: On completion, the remote agent returns typed Artifacts (reports, structured JSON, charts) and marks the task completed.

3. When to Use MCP + A2A Together

In mature enterprise architectures, both protocols run simultaneously:

  • Your Orchestrator Agent talks to the Billing Specialist Agent and Logistics Specialist Agent over A2A.
  • Inside its private boundary, the Billing Specialist Agent uses MCP to query Stripe, Postgres, and internal PDF invoice storage.
  • This enforces least-privilege security: the Orchestrator never holds Stripe credentials!
“Wait, I'm Confused...” · Teacher Office Hours Q&A

The exact honest questions almost every beginner wonders — answered in plain English without hiding behind jargon.

No! Wrapping a simple deterministic database query or calculator in an A2A agent adds unnecessary LLM latency and nondeterminism. Use MCP for tools/data and A2A only when delegating to another reasoning agent.

Interactive Visual Lab
Lab Challenge: Trace how standardized protocol buses decouple agents from brittle custom integrations.
Interactive Animation • 2.5 Deep Lab

Model Context Protocol (MCP) JSON-RPC 2.0 Discovery & Call Bus

Switch MCP Servers to see how ONE standard MCP Client discovers and invokes completely different tools over JSON-RPC.

GitHub MCP Server
1. Client → Server: tools/list (JSON-RPC 2.0)
0%
RPC Message 1 / 4
Intuition Takeaway: Use MCP to give an agent tools and data; use A2A to let independent agents discover each other and collaborate asynchronously across framework and organizational boundaries.
Production NumPy & PyTorch Code Patterns
# Minimal A2A Agent Card Discovery & Stateful Task Lifecycle Simulator
AGENT_CARDS = {
    "tax-agent": {
        "name": "TaxComplianceAgent",
        "skills": ["vat_calculation", "invoice_audit"],
        "auth": "oauth2",
    },
    "travel-agent": {
        "name": "CorporateTravelAgent",
        "skills": ["flight_search", "hotel_booking"],
        "auth": "oauth2",
    },
}

def discover_agent(required_skill: str):
    for agent_id, card in AGENT_CARDS.items():
        if required_skill in card["skills"]:
            return agent_id, card
    return None, None

def send_a2a_task(agent_id: str, payload: dict) -> dict:
    if "country" not in payload:
        return {"task_id": "t-101", "state": "input-required", "prompt": "Missing tax country code."}
    return {
        "task_id": "t-101",
        "state": "completed",
        "artifact": {"agent": agent_id, "vat_rate": 0.20 if payload["country"] == "UK" else 0.0},
    }

agent_id, card = discover_agent("vat_calculation")
print("Discovered:", card["name"])
print("Turn 1:", send_a2a_task(agent_id, {"amount": 500}))
print("Turn 2:", send_a2a_task(agent_id, {"amount": 500, "country": "UK"}))
Common ML Interview Traps & Numerical Pitfalls
Trap #1: Saying 'A2A replaces MCP'
Best Practice: they solve orthogonal problems (agent-to-agent delegation vs. agent-to-tool integration).
Trap #2: Ignoring opaque boundaries: a huge advantage of A2A is that Agent A can delegate to Agent B without ever seeing Agent B's proprietary prompts, private RAG docs, or tool credentials.
Best Practice: Design deterministic guardrails and verify with offline trajectory evals.
Chapter Mastery Check (+65 XP)
Score: 0 / 1
1In a multi-agent enterprise system using both MCP and A2A, which statement is most accurate?

Apply What You Learned — Solve Matching Coding Problems