A2A and MCP: Multi-Agent Protocol Federation
Learn how the Agent-to-Agent (A2A) protocol and Model Context Protocol combine into a secure, decentralized multi-agent enterprise federation stack.
Generate & Validate Multi-Client MCP Config
One-click export with environment variables & path locators for Claude Desktop, Cursor, Windsurf, and OpenAI Codex CLI.
A2A and MCP: Multi-Agent Protocol Federation
Enterprise software architectures increasingly delegate work across federated multi-agent networks rather than relying on monolithic, single-agent assistants. In real-world enterprise operations, an autonomous agent operating within one corporate security boundary frequently needs to delegate complex subtasks to specialized third-party vendor agents—such as external payment auditing, automated penetration testing, cloud infrastructure cost optimization, or legal regulatory compliance reviews.
However, organizations cannot simply grant third-party vendor agents direct shell access, internal VPN connectivity, or raw database connection strings. Doing so creates massive data leakage vectors and violates strict enterprise compliance mandates such as SOC 2, HIPAA, and GDPR.
Solving this multi-organization coordination problem requires two complementary protocol layers operating in unison:
- ▸Agent-to-Agent Protocol (A2A): Governs horizontal peer-to-peer delegation, intent negotiation, cryptographic identity federation, billing handshakes, and Service Level Agreement (SLA) contracts between distinct autonomous agents.
- ▸Model Context Protocol (MCP): Governs vertical integration, enabling an agent runtime to discover and invoke tools, query structured resources, and inject context from local or remote backend systems.
Together, A2A and MCP establish the standardized protocol stack for enterprise agent federation, coupling cryptographic capability delegation with zero-trust tool execution.
1. The Two-Layer Protocol Stack
While MCP operates as the standardized "USB-C port" connecting an AI reasoning engine to its operational tools, A2A operates as the "BGP and HTTPS networking fabric" enabling autonomous agents to discover, negotiate with, and delegate work to one another across organizational boundaries:
┌────────────────────────────────────────────────────────┐
│ PRIMARY ENTERPRISE HOST (Acme Corp) │
│ Lead Agent (Claude Desktop / Cursor / Codex CLI) │
└──────────────────────────┬─────────────────────────────┘
│
A2A Protocol Negotiation Layer
(W3C DID Identity, Task SLA, Scoped JWT)
│
▼
┌────────────────────────────────────────────────────────┐
│ SPECIALIZED VENDOR AGENT CLUSTER (Security Vendor) │
│ Subagent Inspector (e.g. Vulnerability Auditor) │
└──────────────────────────┬─────────────────────────────┘
│
Model Context Protocol (MCP) Transports
(SSE / mTLS with Cryptographic Scoping)
│
┌───────────────────┼───────────────────┐
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ MCP Server │ │ MCP Server │ │ MCP Server │
│ Git / Code │ │ Sentry Logs │ │ PostgreSQL │
└──────────────┘ └──────────────┘ └──────────────┘When an enterprise lead agent encounters a task outside its core domain, it initiates an A2A handshake with an authorized external agent. Rather than transmitting broad database credentials, the lead agent provisions a dynamic, scoped MCP gateway endpoint backed by an ephemeral JSON Web Token (JWT). The external vendor agent connects to this delegated gateway, executing strictly approved read-only tools without ever gaining access to the enterprise's private network.
2. Prerequisites and Environment Matrix
Before establishing an A2A and MCP federated bridge, verify your runtime and cryptographic dependency requirements:
| Component | Minimum Version | Recommended | Purpose |
|---|---|---|---|
| Node.js | >= 20.0.0 LTS | v22.12.0 LTS | Core gateway runtime |
| @modelcontextprotocol/sdk | 1.6.0 | 1.7.0 | MCP client and server library |
| jose | 5.0.0 | 5.9.6 | Cryptographic JWT capability signing |
| TypeScript | 5.4.0 | 5.7.2 | Type-safe schema validation |
Ensure your edge reverse proxy (such as Envoy, NGINX, or Cloudflare) supports HTTP Server-Sent Events (SSE) streaming with TLS 1.3 termination.
3. Multi-Host Configuration Snippets
Configure your AI assistant host to connect with the local federation gateway for orchestrating delegated tasks.
Claude Desktop Configuration
Configure Claude Desktop to route delegated federation requests through your local A2A bridge daemon:
{
"mcpServers": {
"a2a-federation-bridge": {
"command": "node",
"args": ["./dist/a2a-bridge-server.js"],
"env": {
"A2A_ORGANIZATION_DID": "did:web:internal.acme.example.com",
"MCP_GATEWAY_URL": "https://mcp-gateway.internal.example.com/sse"
}
}
}
}Cursor IDE Configuration (.cursor/mcp.json)
Inside Cursor, declare the federation agent bridge:
{
"mcpServers": {
"a2a-bridge": {
"command": "node",
"args": ["./dist/a2a-bridge-server.js"],
"env": {
"A2A_MODE": "development"
}
}
}
}OpenAI Codex CLI Configuration (~/.codex/config.toml)
For terminal automation via the OpenAI Codex CLI:
[mcp.servers.a2a_bridge]
command = "node"
args = ["./dist/a2a-bridge-server.js"]
[mcp.servers.a2a_bridge.env]
A2A_ORGANIZATION_DID = "did:web:internal.acme.example.com"4. Step-by-Step Federation Protocol Lifecycle
Step 1: Constructing the A2A Task Delegation Envelope
When delegating a subtask, the initiating agent constructs a cryptographically signed A2A task envelope. This envelope defines the task intent, Service Level Agreement constraints, and a scoped MCP access token:
{
"a2a_version": "1.0",
"task_id": "task_audit_98412",
"sender_did": "did:web:internal.acme.example.com:agent:lead",
"recipient_did": "did:web:vendor.security.example.com:agent:scanner",
"intent": {
"action": "audit_code_vulnerabilities",
"parameters": {
"repository_name": "payment-gateway",
"target_commit": "e814bf9"
}
},
"delegated_mcp_capabilities": {
"gateway_endpoint": "https://mcp-gateway.internal.example.com/sse",
"capability_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.scoped_mcp_session",
"allowed_tools": [
"git_read_file",
"git_list_commits",
"sentry_query_errors"
],
"max_tool_invocations": 30
},
"sla": {
"timeout_seconds": 120,
"max_cost_usd": 2.50
}
}Step 2: Vendor Agent Connecting to Delegated Gateway
Upon receiving the A2A envelope, the vendor agent uses the Model Context Protocol SDK to establish an authenticated connection to the delegating party's SSE gateway:
// a2a_vendor_connector.ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
export async function connectToDelegatedMcp(envelope: any) {
const { gateway_endpoint, capability_token, allowed_tools } = envelope.delegated_mcp_capabilities;
// Initialize SSE Transport with scoped JWT authorization header
const transport = new SSEClientTransport(new URL(gateway_endpoint), {
headers: {
Authorization: `Bearer ${capability_token}`,
"X-A2A-Task-ID": envelope.task_id
}
});
const client = new Client(
{ name: "VendorSecurityAgent", version: "1.0.0" },
{ capabilities: { tools: {} } }
);
await client.connect(transport);
// Discover published tools and filter to contractually approved subset
const response = await client.listTools();
const authorizedTools = response.tools.filter(tool => allowed_tools.includes(tool.name));
console.log(`Connected to federated MCP gateway. ${authorizedTools.length} tools available.`);
return { client, authorizedTools };
}Step 3: Tool Execution and Audit Ledgering
When the vendor agent invokes an authorized tool over MCP, the gateway verifies the invocation count and writes an immutable audit record:
{
"jsonrpc": "2.0",
"id": 101,
"method": "tools/call",
"params": {
"name": "git_read_file",
"arguments": {
"path": "src/security/authenticator.ts"
}
}
}The gateway confirms that git_read_file is present in allowed_tools, increments the session invocation counter (1 of 30), and returns the file contents.
5. Common Errors and Production Troubleshooting
Error 1: Capability Token Expiration During Long Execution Loops
- ▸Symptom: Subagent tool invocations fail after 5 minutes with
401 Unauthorized: Capability Token Expired. - ▸Root Cause: To enforce zero-trust security, delegated JWTs are short-lived (5-minute TTL). Complex analysis jobs that exceed this duration are abruptly severed.
- ▸Resolution: Implement an A2A heartbeat lease extension. The subagent emits an
extend_leasesignal over A2A prior to token expiration, allowing the delegator to issue a fresh short-lived token without restarting the entire task.
Error 2: Privilege Escalation Across Delegated Gateways
- ▸Symptom: A compromised subagent attempts to invoke unlisted administrative tools (such as
db_drop_table). - ▸Root Cause: The gateway relied on client-side tool filtering rather than enforcing server-side authorization checks on every incoming JSON-RPC frame.
- ▸Resolution: Enforce mandatory gateway-level authorization middleware. If an incoming
tools/callmethod requests a tool not explicitly listed in the session token'sallowed_toolsclaim, immediately reject the call with JSON-RPC error code-32601 Method not foundand terminate the session.
Error 3: Network Connection Severance in Long-Lived SSE Streams
- ▸Symptom: Cloud firewalls or load balancers drop idle SSE connections after 60 seconds of inactivity.
- ▸Root Cause: Intermediary HTTP proxies terminate streaming connections that do not transmit periodic data packets.
- ▸Resolution: Configure the MCP SSE gateway to transmit periodic keep-alive comment frames (
: ping\n\n) every 15 seconds.
6. External Citations and Security Guardrails
Official Specifications and References
- ▸W3C Decentralized Identifiers (DIDs) v1.0 (opens in a new tab) — Core standard for verifiable, decentralized digital identity across organizations.
- ▸RFC 9396: OAuth 2.0 Rich Authorization Requests (opens in a new tab) — IETF specification for fine-grained capability delegation and authorization tokens.
- ▸Model Context Protocol Specification (opens in a new tab) — Official JSON-RPC 2.0 schema specification for tools, resources, and clients.
Security and Isolation Guardrails
When federating agents across organizational boundaries:
- ▸Never Issue Long-Lived Access Tokens: Capability tokens must never exceed a 5-minute time-to-live window. Always enforce single-use or task-bounded revocation.
- ▸Enforce Read-Only Defaults: Ensure delegated MCP gateways block all mutating verbs (
POST,PUT,DELETE,DROP,UPDATE) unless explicit cryptographic authorization and human approval are provided.
Build your full agent toolstack in the Visual Generator
Combine verified MCP servers with databases, search APIs, and memory graphs in a single configuration file.
Did this setup guide work with your AI host?
Help test this configuration across Claude, Cursor, and Codex CLI. Be the first to report:
Written by Rad Tome
Lead AI Systems Architect & Maintainer, MCP Codex
Specializing in Model Context Protocol (MCP) integrations, autonomous AI agent orchestration, and distributed developer toolchains. Researches and benchmarks production MCP client-server architectures across OpenAI Codex, Claude, and Cursor.
Related Guides
The MCP Security Checklist: 50 Vulnerabilities to Audit Before Shipping
Comprehensive security audit checklist for MCP servers. 50 specific vulnerabilities across injection, authentication, authorization, transport, supply chain, and operational security. Includes exploitation examples, detection methods, and remediation code.
EnterpriseBenchmarking MCP: Latency, Transport Overheads & Cost Model
Empirical latency baselines comparing MCP stdio vs SSE transports, cold start overheads, memory footprints, and AWS cost modeling with runnable test scripts.
EnterpriseMCP Server Monetization: Production Models
Architect paid MCP servers using Stripe Billing, token metering, and HTTP 402 machine payments. Covers real auth flows, mppx code, and unit economics.