Agent Protocols Explained: MCP and A2A in Depth
This article breaks down the two main categories of agent protocols: MCP, which standardizes how agents access external context and tools, and A2A, which defines how multiple agents collaborate. It covers their architecture, core primitives, transport options, engineering best practices, a layered deployment reference, and common pitfalls to avoid.
1. Why Agents Need a Protocol Layer
Early agent implementations often hardcoded prompts, tool calls, and business logic into a single application: tool lists were fixed in configuration, external systems were integrated through custom wrappers, and collaboration between agents relied on point-to-point calls. This approach is efficient for prototypes, but problems scale quickly in production: every new data source requires changes to the main program; switching models or host applications means rewriting the tool adaptation layer; and when multiple agents collaborate, inconsistent message formats, error semantics, and timeout policies make troubleshooting extremely costly.
The value of a protocol layer is to converge these “private conventions” into “public conventions,” with three main benefits:
- Interoperability: the same tool service can be reused across different host applications and models, avoiding repeated adaptation.
- Extensibility: new capabilities scale horizontally as services while the main program stays stable.
- Operability: clear interface boundaries allow logging, monitoring, rate limiting, and authentication to be enforced consistently at the boundary.
The industry generally divides agent-related protocols into two categories: one focused on context, addressing how agents obtain external data and tool capabilities; and one focused on inter-agent communication, addressing how multiple agents divide work, negotiate, and deliver tasks. MCP represents the former, and A2A represents the latter.
2. MCP: A Universal Interface for Context
2.1 Architectural Roles
MCP uses a classic client-server structure, but semantically it has three layers:
- Host: the application that runs the large model interaction, such as an AI coding tool, a desktop chat application, or an IDE plugin.
- Client: the connector that negotiates capabilities with the server, routes messages, and maintains session state. One host can hold multiple clients connected to different servers.
- Server: a lightweight standalone service that exposes capabilities such as files, databases, and business APIs.
2.2 Capability Primitives
MCP capabilities are typically abstracted into a few primitives: tools (executable actions), resources (readable context data), prompt templates (reusable instruction skeletons), and sampling (the server requesting the model to generate results in the reverse direction). The benefit of this abstraction is decoupling “what to do” from “how to connect”: the host does not need to know whether data comes from a file or a database, and only needs to invoke it with unified semantics.
2.3 Transport and Connection Options
Common transports fall into two categories: local in-process communication and remote message streaming. The local option suits tool services deployed on the same machine as the host, offering low latency with no extra network configuration; the remote option suits shared services across machines and environments, requiring additional consideration for authentication, timeouts, and reconnection. An illustrative interaction flow:
Host -> Client: initialize (version and capability negotiation)Client -> Server: tools/list (retrieve tool list)Host -> Client: model decides to call a toolClient -> Server: tools/call (with parameters)Server -> Client: result or structured errorClient -> Host: fill context back in, continue reasoning
2.4 Engineering Best Practices
- Tool descriptions are the API documentation: description quality directly affects how accurately the model selects tools, so state the applicable scenarios, parameter constraints, and failure semantics clearly.
- Least privilege: the server exposes only necessary capabilities, and write operations require secondary confirmation or separate authorization.
- Idempotency and retryability: external calls are inherently unreliable, so design for repeated execution without side effects.
- A unified error model: distinguish timeouts, authentication failures, and invalid parameters into recoverable and non-recoverable categories to support model decisions.
3. A2A: Inter-Agent Communication
3.1 The Problem It Solves
When a task is too complex for a single agent to complete end to end, multiple roles must collaborate: one handles retrieval, one handles coding, and one handles review. A2A focuses on a collaboration protocol where agents participate as equals. The core is not calling a function, but delegating a task and tracking its lifecycle.
3.2 Key Abstractions
- Capability declaration: describing the task types an agent can handle in a structured way for discovery and routing.
- Task object: a state machine (submitted, in progress, needs input, completed, failed) that supports long-running work and human intervention.
- Messages and artifacts: messages carry instructions and context references, while artifacts are delivered as addressable attachments to avoid passing large objects in messages.
3.3 Division of Labor with MCP
A practical rule of thumb: use the context protocol when you need to “get data or perform an action”; use the communication protocol when you need to “hand a task to another role and wait for the result.” They are not competing but are different stages in the same pipeline.
4. A Layered Deployment Reference
A recommended design splits the system into four layers: the access layer (host and user interaction), the protocol layer (MCP clients and A2A clients), the capability layer (tool services and agent implementations), and the infrastructure layer (object storage, message queues, container platforms, logging services, and monitoring and alerting).
{"agent": "reviewer","capabilities": ["code_review", "static_analysis"],"mcp_servers": ["file_service", "repo_service"],"task_policy": { "timeout_seconds": 120, "max_retry": 2 }}
On cloud platforms such as Baidu AI Cloud, these layers can map to general product categories: the capability layer runs on a container platform for elastic scaling, artifacts and context are stored in object storage, long-running and decoupled tasks are connected through message queues, and operational quality is closed-loop through logging services and monitoring and alerting.
5. Common Pitfalls and Conclusion
There are three common pitfalls: treating a protocol as just an “integration SDK” and overlooking that semantic standardization is the real source of value; letting the host hold a large number of long-lived connections, making state hard to govern; and lacking unified authentication and auditing, making accountability impossible in production.
The conclusion is clear: MCP lets agents “reach out with their hands,” and A2A lets agents “hand off the work.” First converge tool and data access with MCP, then split roles and long-running workflows with A2A, and finally back it all with a unified observability and permission system. Only then can you build a flexible and operable foundation for an agent ecosystem.
