Agent Protocols Explained: MCP and A2A in Depth

    This article breaks down the two main protocol categories in the agent ecosystem: MCP (Model Context Protocol) for context access and A2A (Agent to Agent) for inter-agent collaboration. It explains the roles and architecture of each protocol, how they complement rather than compete with each other, and how to structure a production-grade agent system across access, protocol, capability, and governance layers. You will also find practical guidance on capability discovery, least-privilege exposure, prompt injection defense, observability, and version compatibility.

    1. Why Agents Need a Protocol Layer

    The ceiling on a single agent’s capability is set by the context it can reach and the peers it can collaborate with. As workloads evolve from “one prompt plus one call” to multi-agent division of labor and long-running automation, the real bottleneck is no longer model reasoning power but fragmented interfaces: every new data source requires a bespoke adapter, and every new collaborator requires renegotiating the message format. This is exactly what a protocol layer solves — it turns point-to-point integration into standardized plug-in connectivity.

    The value of standardized protocols comes down to three main lines:

    • Interoperability: the same semantics work across different hosts, tools, and vendor implementations, eliminating repeated adaptation.
    • Extensibility: new capabilities are added as plug-ins, so system complexity grows roughly linearly instead of exploding quadratically.
    • Operability: unified interfaces, error codes, logs, and tracing fields give troubleshooting and governance a shared language.

    The industry generally splits agent-related protocols into two categories: context-oriented protocols and inter-agent communication protocols. The former answers “where do I get data and tools from,” while the latter answers “how do I collaborate with others.”

    2. Context-Oriented: The Role and Architecture of MCP

    MCP (Model Context Protocol) focuses on how an agent obtains data, tools, and service context from the outside world. It uses a classic client-server structure with three roles:

    • Host: the interactive application that runs the large model, such as an AI coding tool, a desktop assistant, or an IDE plugin.
    • Client: a connector inside the host that handles capability negotiation, message routing, and lifecycle management. One host can hold multiple client connections at the same time.
    • Server: an independent, lightweight process or remote service that exposes capabilities such as files, databases, and business APIs.

    In one sentence: MCP is the universal interface between an agent and the outside world.

    Its engineering value shows up in three areas. First, capability discovery and negotiation: once a connection is established, both sides exchange lists of supported capabilities, and the host renders the available tools dynamically instead of hard-coding them. Second, decoupling of transport and form: local process communication and remote calls can use different transports while business code stays the same. Third, least-privilege exposure: a server only exposes resources and operations that are explicitly declared, which naturally forms a permission boundary.

    An illustrative interaction flow (pseudocode, semantics only):

    1. Host -> Client: initialize(capabilities, protocolVersion)
    2. Client -> Server: initialize response (resources/tools/prompts list)
    3. Host -> Client: tools/list
    4. Client -> Server: tools/list -> return tool definitions and parameter schemas
    5. Host -> Client: tools/call(name, arguments)
    6. Client -> Server: execute and return structured result or error

    Three common pitfalls in engineering practice: vague tool descriptions that lead the model to pick the wrong tool; oversized responses that crowd out the context window; and unreadable error messages that leave the model unable to self-correct. The corresponding practices are to write clear purpose and constraint descriptions for each tool, paginate and summarize results, and convert exceptions into structured errors that carry suggested actions.

    3. Collaboration-Oriented: The Role and Boundaries of A2A

    A2A (Agent to Agent) addresses collaboration between heterogeneous agents. It assumes every agent is an independent, autonomous participant with its own identity, capability declaration, and execution state. Collaboration happens at the level of “task delegation” rather than “function invocation.”

    Its core abstractions typically include:

    • Agent Card: a structured declaration of “what I can do and how to interact with me,” used for discovery and routing.
    • Task and state machine: a task has a lifecycle (submitted, in progress, needs input, completed, failed) and supports long-running work and streaming feedback.
    • Messages and artifacts: interaction content is split into immediate messages and final deliverables, making it easier for downstream systems to consume.
    • Collaboration modes: request/response, streaming notifications, and task push, adapted to different latency requirements.

    MCP and A2A are not competing; they are complementary layers: MCP faces inward, connecting tools and data; A2A faces outward, connecting agent to agent. A typical combination is an orchestrating agent that dispatches subtasks to multiple specialized agents over A2A, with each sub-agent then reaching databases, files, and business APIs through MCP. A simple rule for deciding which to use is whether the counterpart has autonomous decision-making ability: if yes, use A2A; if not, use MCP.

    4. Deployment Architecture and Governance

    To build a production-ready agent system in a cloud environment, organize it into four layers:

    1. Access layer: unified authentication, tenant isolation, and quotas, with all protocol traffic entering and exiting through a gateway.
    2. Protocol layer: MCP servers and A2A endpoints deployed independently, with capability declarations centrally registered and support for canary rollout and version coexistence.
    3. Capability layer: data and tools carried by common cloud product categories such as object storage, relational databases, message queues, container platforms, log services, and monitoring and alerting, which hide underlying differences.
    4. Governance layer: full-chain tracing, evaluation regression, and cost and rate-limiting policies.

    Security and governance deserve particular attention:

    • Least privilege and credential custody: tool-side credentials are managed centrally by a key management capability and never enter the model context.
    • Prompt injection and privilege escalation defense: treat externally returned content as untrusted input, and apply parameter whitelists and secondary confirmation to tool calls.
    • Observability: record the protocol method, latency, token consumption, and result status for every call to form a traceable chain.
    • Compatibility evolution: protocol version negotiation plus capability degradation, so old and new implementations do not block each other.

    5. Conclusion

    MCP and A2A form the foundation of the agent ecosystem: one makes the world visible, the other makes collaboration possible. For enterprises, the real payoff is not adopting a particular protocol name but turning capability onboarding, task orchestration, permission boundaries, and observability into platform standards. Carried by the general cloud product capabilities offered by Baidu AI Cloud, teams can focus their energy on business semantics and evaluation systems, moving agents from demos to sustainable operations.