The A2A specification is still evolving. Anvil isolates all protocol logic behind an adapter layer (
A2AServer and a2aHttpHandler), so spec updates require changes only to the adapter — not to your agent definitions.What is A2A?
Agent2Agent (A2A) is an open protocol proposed by Google for standardized communication between AI agents. It allows one agent to call another agent’s capabilities using a JSON-RPC 2.0 transport. Agents advertise their skills via an Agent Card — a JSON document served at a well-known URL — and callers discover and invoke those skills via themessage/send method.
Anvil’s implementation covers:
- Agent Card — served at
/.well-known/agent-card.json(and the alias/agent.json) so external agents can discover your skills message/send— synchronous task execution; calls the target skill and returns a completed Task artifacttasks/get— retrieve a previously created task by ID
Setting up an A2A server
Create an AgentRegistry with your agents
A2AServer dispatches incoming A2A requests to agents by skill ID. Each skill ID must match a registered agent name.A2AServer API
Constructor options
A2AServerOptions
A2AServerOptions
| Option | Type | Required | Description |
|---|---|---|---|
registry | AgentRegistry | ✅ | The agent registry that backs skill execution |
name | string | ✅ | Human-readable name for this A2A server, advertised in the Agent Card |
description | string | ✅ | Human-readable description advertised in the Agent Card |
url | string | ✅ | The public URL of the A2A endpoint, included in the Agent Card |
version | string | — | Server version string. Defaults to '0.0.1' |
skills | A2ASkill[] | — | Skills to advertise. Each id must be a registered agent name. Defaults to all agents in the registry |
defaultSkill | string | — | Skill to invoke when message/send includes no skillId. Defaults to the first skill |
server.agentCard()
Returns the AgentCard object that describes this server’s capabilities. The HTTP handler serves this automatically at the card path.
server.handle(message)
Process a raw JSON-RPC 2.0 request object. Returns a JSON-RPC response or null for notifications (requests with no id). You can call this directly if you are integrating with a custom transport.
Supported JSON-RPC methods
| Method | Description |
|---|---|
message/send | Send a message to a skill and receive a completed Task artifact synchronously |
tasks/get | Retrieve a previously created task by its id |
-32601 Unknown method error.
AgentCard and skill discovery
External agents discover your capabilities by fetching the Agent Card from/.well-known/agent-card.json. Anvil serves it automatically:
A2ASkill fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | ✅ | Must match a registered agent name in the AgentRegistry |
name | string | ✅ | Human-readable skill name |
description | string | ✅ | What the skill does — shown to calling agents during discovery |
tags | string[] | — | Optional categorization tags |
a2aHttpHandler options
| Option | Type | Default | Description |
|---|---|---|---|
path | string | '/a2a' | The path for the JSON-RPC endpoint |
cardPath | string | '/.well-known/agent-card.json' | The path to serve the Agent Card. The alias /.well-known/agent.json is always served at this path too |
One definition, three protocols
BecauseA2AServer wraps the same AgentRegistry your application already uses, enabling A2A requires only a few extra lines — your agent logic and tools are defined once and reused: