# AI Agent Communication Protocols

> Use when designing, reviewing, or testing how AI agents communicate: agent-to-agent (A2A) protocols, Model Context Protocol (MCP) transports, agent discovery and capability advertisement, message authentication and integrity, and protocol comparison for a multi-agent system. Covers choosing between A2A, MCP, and plain HTTP APIs, securing agent identity and delegation, preventing agent impersonation and message forgery, and auditing agent-to-agent traffic. Also use when an agent system spans trust boundaries, vendors, or organizations.

- Skill: `mizazhaider-ceh/ai-agent-communication-protocols` (Agent Skill)
- Install (CLI): `npx get-skill add mizazhaider-ceh/ai-agent-communication-protocols`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mizazhaider-ceh/ai-agent-communication-protocols/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Product & Planning
- Author: mizazhaider-ceh (https://skillmd.com/u/mizazhaider-ceh)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/mizazhaider-ceh/ai-agent-communication-protocols

---


A single agent is a tool user. A multi-agent system is a distributed
system, with all the distributed-system problems: identity, trust,
delegation, replay, and discovery. Two agents that talk to each other
need to answer questions a single agent never faces: who are you,
who sent you, what are you allowed to ask me to do, and how do I know
this message is really from you and not a replay of an old one? This
skill covers the main agent communication protocols, how to compare
them, and how to secure the traffic between agents. Work only against
systems you own or have written permission to test.

## Quick Workflow

1. Map the agent graph: every agent, every channel between agents,
   and every trust boundary the traffic crosses.
2. Identify the protocol on each channel: A2A, MCP, plain HTTP API,
   message queue, or a custom format, and record its version.
3. Check identity on each channel: how an agent proves who it is,
   whether messages are signed, and what happens with a missing or
   forged credential.
4. Check discovery: how agents find each other, who can publish a
   capability advertisement, and whether a malicious agent can
   advertise a trusted capability.
5. Check delegation: when agent A asks agent B to act for a user,
   what proof of the user's authorization travels with the request,
   and how far down the chain it is honored.
6. Test message integrity and replay: tamper with a message, replay
   an old message, and reorder messages, and confirm each is rejected.
7. Test impersonation: present as a trusted agent, present as a
   different agent, and advertise a capability you do not have.
8. Compare protocols against the system's needs (discovery, long
   tasks, streaming, tool use) and record why the chosen protocol
   fits, plus which of its optional security features are enabled.

## 1. Map the protocols in play

Agent communication protocols solve different problems, and mixing
them up is a common design flaw. MCP connects an agent to tools and
context. A2A connects agents to each other for tasks. A plain HTTP API
connects anything to anything, with no agent semantics at all.

```bash
# Inventory: for each agent endpoint, record protocol, auth, and
# whether it is reachable beyond its intended boundary
cat > /tmp/agentproto/inventory.md <<'EOF'
| Agent | Endpoint | Protocol | Auth | Reachable from |
| planner | internal:8001 | A2A | signed JWT, per-agent key | agent network only |
| researcher | internal:8002 | A2A | signed JWT, per-agent key | agent network only |
| tools-gateway | internal:3001 | MCP over HTTP | bearer token per client | agent network only |
| public-assistant | public:443 | HTTP API | user session token | internet |
EOF
cat /tmp/agentproto/inventory.md

# Any row where "Reachable from" is wider than "Auth" can support
# is a finding: an internet-reachable A2A endpoint with no agent
# authentication is an open door to task injection.
```

The comparison to make explicit: MCP is client-server and tool
centric, with a defined tool, resource, and prompt surface. A2A is
peer-to-peer and task centric, with agent cards for discovery,
message and task objects, and support for long-running tasks with
status updates and artifacts. Neither replaces the other; a system
that needs both tool access and agent delegation usually needs both,
with a gateway between them, not a single protocol stretched to
cover both jobs.

## 2. Test agent discovery and agent cards

In A2A, an agent card advertises what an agent can do. If anyone can
publish a card, anyone can impersonate a capability. Discovery must
be authenticated, and cards must be verified, not just fetched.

```bash
# Fetch an agent card the way a peer agent would, then check what
# it actually proves
curl -s 'http://planner.internal:8001/.well-known/agent.json' \
  | python3 -m json.tool | head -40

# Questions to answer from the card and its transport:
# - Is the card served over TLS with a certificate for this agent?
# - Is the card signed, so a tampered card is detectable?
# - Does the card list skills the agent demonstrably has, or claims?
# - Can an unauthenticated party publish a card for this agent name?
```

Test the spoof directly in a staging environment: publish a card
with the same agent name and a more attractive skill list from an
untrusted host, and see whether peer agents prefer it, or at least
accept it. If they do, discovery needs an allowlist of trusted card
sources, signature verification on cards, or both. The same check
applies to MCP server registries: a registry entry is a claim, and
an unverified registry is a shadowing vector (see the tool-injection
skill for the tool-level version of this attack).

## 3. Test message authentication and integrity

An agent message without authentication is a suggestion from
whoever can reach the endpoint. Test each channel with missing,
forged, and replayed credentials.

```bash
# A2A task request with no credential: must be rejected, not queued
curl -s -o /dev/null -w 'no credential: %{http_code}\n' \
  -X POST 'http://planner.internal:8001/tasks' \
  -H 'Content-Type: application/json' \
  -d '{"task":"summarize the quarterly report","requester":"researcher"}'

# Same request with a valid credential, then replayed verbatim:
# the replay must be rejected by nonce, timestamp, or idempotency key
curl -s -X POST 'http://planner.internal:8001/tasks' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $AGENT_TOKEN" \
  -d '{"task":"summarize the quarterly report","requester":"researcher","idempotency_key":"test-001"}' \
  | head -20
curl -s -o /dev/null -w 'replay: %{http_code}\n' \
  -X POST 'http://planner.internal:8001/tasks' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $AGENT_TOKEN" \
  -d '{"task":"summarize the quarterly report","requester":"researcher","idempotency_key":"test-001"}'
```

A 200 on the replay, or a second execution of the same task, is a
replay vulnerability: an attacker who captures one legitimate agent
message can re-run it, possibly with side effects. Require per-agent
keys (never one shared agent key), message signatures or tokens with
short expiry, timestamps with a tight acceptance window, and
idempotency keys for any task with side effects.

## 4. Compare protocols before choosing one

Use a decision table, and record the decision, so the next engineer
does not re-litigate it or silently swap protocols mid-system.

```python
# Protocol comparison helper: score each candidate against the
# system's actual requirements, and print the gaps to close
REQUIREMENTS = {
    "agent_discovery": "agents must find peers and their skills",
    "long_running_tasks": "tasks run for minutes, with status updates",
    "tool_access": "agents need structured tools and resources",
    "streaming": "partial results stream back as they arrive",
    "cross_org": "agents from different organizations interoperate",
}

CANDIDATES = {
    "A2A": ["agent_discovery", "long_running_tasks", "streaming", "cross_org"],
    "MCP": ["tool_access", "streaming"],
    "Plain HTTP API": [],
}

for name, strengths in CANDIDATES.items():
    gaps = [req for req in REQUIREMENTS if req not in strengths]
    print(f"{name}: covers {len(strengths)} of {len(REQUIREMENTS)}")
    for gap in gaps:
        print(f"  gap: {gap} - {REQUIREMENTS[gap]}")
print("rule: a gap is not a reason to reject a protocol, it is a")
print("requirement to fill with a second protocol or a gateway")
```

Also compare security maturity honestly: a newer protocol may have
a thinner ecosystem of authentication libraries, audit tooling, and
published attack research than a plain HTTP API with mutual TLS and
mature identity providers. Choosing the newer protocol is fine, but
its missing pieces become your build list, not an accepted risk you
never wrote down.

## 5. Secure delegation across agents

Delegation is where multi-agent security usually breaks. Agent A
acts for a user, asks agent B to do a subtask, and B asks agent C.
If the user's authorization does not travel with the chain, each hop
relies on trusting the previous agent, and compromising one agent
compromises the chain.

```json
{
  "delegation_token": {
    "subject": "user:alice",
    "original_agent": "planner",
    "delegated_to": "researcher",
    "scope": ["read_docs:quarterly"],
    "not_before": "2026-10-27T00:00:00Z",
    "expires": "2026-10-27T01:00:00Z",
    "max_chain_depth": 2,
    "rules": [
      "each hop re-validates scope and expiry",
      "scope can only narrow, never widen, down the chain",
      "a token for one user never authorizes another user's data"
    ]
  }
}
```

Test the chain: present a delegation token scoped to read-only
documents and ask the downstream agent for a write action, present
an expired token, present a token issued for a different user, and
present a chain deeper than the allowed depth. Each must be refused
by the receiving agent itself, not merely by the first agent in the
chain. Log the full chain (agent, scope, token id) with every task,
so an incident review can trace a bad action back to the hop where
authorization failed.

## 6. Audit agent-to-agent traffic

Agent traffic is harder to audit than user traffic because the
"user" is another model, and its requests may be paraphrases of
injected content. Log the structured facts, not just free text.

```bash
# Agent traffic audit: who asked whom, for what, under whose authority
jq -c 'select(.channel == "agent_to_agent")' \
  /var/log/agents/traffic.jsonl | head -20

# Tasks requested by an agent that is not on the allowlist for
# that task type, or with no delegation token at all
jq -c 'select(.delegation_token == null or .requester_allowlisted == false)' \
  /var/log/agents/traffic.jsonl | head -20

# Cross-boundary traffic: an internal agent contacted from outside
# the agent network, or an agent reaching an external agent directly
jq -r 'select(.crosses_trust_boundary == true) | "\(.from) -> \(.to) : \(.task_type)"' \
  /var/log/agents/traffic.jsonl | sort | uniq -c | sort -rn | head -20
```

Set alerts on the patterns that indicate protocol abuse: a new agent
identity appearing, a spike in tasks from one agent, tasks outside
an agent's advertised skills, and delegation chains at maximum depth.
Review agent cards and registry entries on the same cadence as
code: a changed card is a changed attack surface.

## Edge cases

- Version skew: agents speaking different protocol versions may
  silently drop security fields (signatures, scope, expiry) that the
  newer version adds. Negotiate versions explicitly and reject
  downgrades to versions without authentication.
- Streaming and long tasks create windows for hijack: a task that
  runs for an hour can be tampered with mid-run if status updates
  and artifacts are not authenticated per message, not just at start.
- Human-in-the-loop steps break the chain if the approval is not
  bound to the exact task and arguments: an approval for task A must
  not authorize a mutated task A prime.
- Cross-organization agents cannot share one identity provider, so
  federated identity, signed cards, and per-organization allowlists
  are required; a shared secret across organizations is a breach
  waiting for one organization to leak it.
- Protocol gateways that translate A2A to MCP or to HTTP APIs must
  translate authorization too, not just message format. A gateway
  that drops the delegation token while translating is a privilege
  escalation path.
- Agent discovery over public directories (registries, search) means
  an attacker can enumerate your agents and their skills. Publish
  only the cards that external peers genuinely need, and keep
  internal capability detail out of public cards.

## Key references

- Agent-to-agent (A2A) protocol specification: agent cards, tasks,
  messages, artifacts, and authentication guidance.
- Model Context Protocol specification: transports (stdio, HTTP
  with SSE), lifecycle, and security considerations for servers and
  clients.
- OAuth 2.0 and OpenID Connect guidance for delegated authorization
  and token chaining, applied to agent-to-agent delegation.
- NIST guidance on distributed system and API security: mutual
  authentication, message integrity, replay protection, and audit
  logging across trust boundaries.

