AI Agent Communication Protocols: MCP, A2A, A2UI and the Modern Agent Stack
The ai-agent-book repository defines five core communication protocols that power modern LLM systems: MCP for tool integration, A2A for inter-agent collaboration, A2UI for safe user interfaces, vendor-specific function calling for single-provider workflows, and OpenTelemetry for observability.
Modern AI agents rely on standardized communication protocols to interact with tools, other agents, and user interfaces securely. The bojieli/ai-agent-book repository provides a comprehensive taxonomy of these protocols, from the Model Context Protocol (MCP) that normalizes tool calls to the Agent-to-Agent (A2A) specification that enables cross-organizational collaboration. Understanding these protocols is essential for building robust, interoperable agent systems that can scale across different environments and trust boundaries.
MCP: The Model Context Protocol for Tool Integration
MCP (Model Context Protocol) serves as a standardized client-server wire-format for tool calls, allowing any MCP-compatible server to expose a toolbox that agents such as Cursor, Claude Desktop, or OpenClaw can consume without rewriting each tool's definition.
According to the source code in chapter4/README.en.md, MCP handles request-response patterns, progress updates, and notifications between agents and tool servers. The repository describes this as a "socket-standard" analogy in book-en/chapter4.md, which provides deeper architectural discussion of MCP's limitations and hierarchical tool matching.
The implementation in chapter4/collaboration-tools/IMPLEMENTATION.md demonstrates how to bootstrap an MCP server using FastMCP:
from fastmcp import FastMCP, Tool
app = FastMCP()
@app.tool(name="search_web", description="Perform a DuckDuckGo search")
async def search_web(query: str) -> str:
# implementation omitted for brevity
return "search results …"
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
The FastMCP server automatically serializes request-response traffic according to the MCP specification, enabling consistent tool invocation across different agent implementations.
A2UI: Secure Agent-to-User-Interface Communication
A2UI (Agent-to-User-Interface) is a declarative UI-description protocol that prevents prompt-injection-driven XSS attacks. Instead of returning raw HTML or JavaScript that could execute malicious code, the agent emits a JSON manifest that a trusted client renders using a catalog of safe components.
As documented in book-en/chapter5.md, A2UI contrasts with raw code generation by enforcing a security-first design. When an MCP tool returns visual data, it can embed an A2UI payload inside the result field:
{
"type": "a2ui",
"payload": {
"components": [
{ "type": "table", "title": "Sales Data", "rows": 3, "cols": 2 }
]
}
}
The client receives this JSON and renders a safe table component rather than executing arbitrary HTML, effectively sandboxing the agent's output capabilities.
A2A: Agent-to-Agent Collaboration Protocol
A2A provides an interoperability layer for inter-organizational agent collaboration, defining a message-bus-style API that lets independently owned agents exchange intentions, results, and coordination signals across trust boundaries.
The specification in book-en/chapter10.md introduces three core elements of A2A: status updates, task lifecycle states, and usage scenarios. Agents communicate states such as executing, needs_input, completed, and failed through standardized HTTP endpoints:
POST /a2a/v1/tasks/42/status HTTP/1.1
Content-Type: application/json
{
"state": "executing",
"progress": 0.42,
"message": "Downloading dataset"
}
This protocol enables complex multi-agent workflows where one agent can hand off work or request assistance from another while maintaining clear visibility into task progress.
Vendor-Specific Function Calling Formats
While MCP provides standardization, many agents still interact directly with OpenAI or Anthropic function-calling formats when working with a single provider's SDK. These vendor-specific JSON schemas follow the pattern assistant.tool_calls → role=tool as documented in chapter4/README.en.md.
{
"role": "assistant",
"tool_calls": [
{
"id": "call_1",
"type": "function",
"function": {
"name": "search_web",
"arguments": "{\"query\": \"latest AI safety papers\"}"
}
}
]
}
The repository's tool-protocol audit shows how these native formats can be wrapped into MCP for consistency when migrating to multi-provider environments.
OpenTelemetry and OpenInference for Observability
OpenTelemetry/OpenInference provides a tracing protocol for agent observability, standardizing how execution metadata is emitted and consumed by back-ends. Unlike direct communication channels, this protocol captures LLM calls, tool invocations, and span hierarchies across all layers of the agent stack.
As detailed in book-en/chapter6.md, this observability layer emits standardized spans that enable unified logs, latency metrics, and error tracing across the entire system, regardless of which specific communication protocols are active at the tool or collaboration layers.
How These Protocols Stack Together
The ai-agent-book design encourages a layered approach where each protocol builds incrementally on the previous one:
- Tool Layer — Agents issue MCP messages to tool servers for capability execution
- Presentation Layer — Visual results are wrapped in A2UI payloads for safe client rendering
- Collaboration Layer — Multi-agent coordination occurs via A2A messages over HTTP or message buses
- Vendor Layer — Single-provider interactions use native function-calling formats, often wrapped into MCP for consistency
- Observability Layer — All interactions emit OpenTelemetry/OpenInference spans for monitoring and debugging
This modular architecture allows developers to swap individual protocols without rearchitecting the entire system, maintaining flexibility while ensuring interoperability.
Summary
- MCP standardizes tool calls using a client-server wire-format described in
chapter4/README.en.mdandbook-en/chapter4.md - A2UI prevents XSS attacks by using declarative JSON manifests for UI rendering rather than raw code execution
- A2A enables secure multi-agent collaboration across organizational boundaries with standardized status states (
executing,completed,failed) - Vendor function-calling remains useful for single-provider workflows but should be normalized through MCP for portability
- OpenTelemetry provides essential observability across all protocol layers, capturing execution metadata in
book-en/chapter6.md - The repository recommends a stacked architecture where protocols interoperate at different layers of the agent system
Frequently Asked Questions
What is the difference between MCP and A2A protocols?
MCP (Model Context Protocol) handles communication between agents and tools using a client-server request-response pattern, while A2A (Agent-to-Agent) facilitates peer-to-peer coordination between independent agents across trust boundaries. According to book-en/chapter4.md and book-en/chapter10.md, MCP focuses on tool integration whereas A2A manages task lifecycle states and multi-agent handoffs.
How does A2UI prevent security vulnerabilities compared to raw HTML generation?
A2UI uses a declarative JSON manifest that specifies safe components (tables, charts, buttons) which the client renders using a trusted component catalog, eliminating the risk of prompt-injection-driven XSS that occurs when agents generate raw HTML or JavaScript. This security-first design is detailed in book-en/chapter5.md.
Can these protocols work with existing LLM providers like OpenAI?
Yes, the repository demonstrates how to wrap OpenAI's native assistant.tool_calls → role=tool pattern into MCP for standardized tool calling, as shown in chapter4/README.en.md. While vendor-specific function calling works for single-provider setups, wrapping it in MCP enables portability across Claude Desktop, Cursor, and other MCP-compatible clients.
Why is OpenTelemetry important for AI agent systems?
OpenTelemetry and OpenInference provide standardized tracing spans that capture LLM calls, tool invocations, and execution metadata across the entire agent stack, enabling unified observability that is critical for debugging multi-step reasoning workflows and measuring latency across distributed tool calls and inter-agent communication.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →