|
| 1 | +--- |
| 2 | +title: "A2A Protocol" |
| 3 | +--- |
| 4 | + |
| 5 | +A2A (Agent-to-Agent) lets your Magec agents talk to external AI systems — and lets external systems talk to yours. When you enable A2A on an agent, it becomes discoverable and callable by any application that speaks the [A2A protocol](https://a2a-protocol.org/latest/specification/). |
| 6 | + |
| 7 | +In practice: you flip a toggle, and your agent gets a URL that other tools can connect to. They discover what the agent can do, authenticate, and send it messages — all without you writing any code. |
| 8 | + |
| 9 | +## Why would I use this? |
| 10 | + |
| 11 | +Think of A2A as giving your agent a phone number that other AI systems can call. |
| 12 | + |
| 13 | +- **Connect agents across platforms.** An agent running in another tool (Claude Desktop, a custom app, another Magec instance) can discover and invoke your agent directly. |
| 14 | +- **Build multi-agent systems.** A coordinator agent somewhere else can delegate tasks to your specialized agents — your "database expert" handles queries, your "email writer" drafts responses, each on their own Magec instance. |
| 15 | +- **Expose agents as services.** Instead of building a custom API for each agent, A2A gives you a standard protocol that any compatible client already knows how to use. |
| 16 | + |
| 17 | +If you're running Magec for personal use or within a single app, you probably don't need A2A. It becomes useful when you want agents to collaborate across different systems. |
| 18 | + |
| 19 | +## How it works |
| 20 | + |
| 21 | +When you enable A2A on an agent, Magec does three things: |
| 22 | + |
| 23 | +1. **Publishes an agent card** — a JSON document describing the agent's name, capabilities, skills, and how to authenticate. This is the discovery mechanism. |
| 24 | +2. **Exposes a JSON-RPC endpoint** — the URL where clients send messages to the agent. Supports both synchronous and streaming responses. |
| 25 | +3. **Auto-generates skills from the agent's tools** — MCP servers, built-in tools, and the agent's instructions are all reflected in the card so clients know what the agent can do. |
| 26 | + |
| 27 | +You don't configure any of this manually. The card and skills are derived from the agent's existing setup. |
| 28 | + |
| 29 | +## Enabling A2A |
| 30 | + |
| 31 | +1. Open an agent in the Admin UI |
| 32 | +2. Toggle **A2A Protocol** on |
| 33 | +3. Save |
| 34 | + |
| 35 | +That's it. The agent is now discoverable and invocable via A2A. |
| 36 | + |
| 37 | +## Endpoints |
| 38 | + |
| 39 | +| Endpoint | Auth | Description | |
| 40 | +|----------|------|-------------| |
| 41 | +| `/.well-known/agent-card.json` | No | Lists all A2A-enabled agents | |
| 42 | +| `/api/v1/a2a/{agentId}/.well-known/agent-card.json` | No | Agent card for a specific agent | |
| 43 | +| `/api/v1/a2a/{agentId}` | Bearer token | JSON-RPC invocation endpoint | |
| 44 | + |
| 45 | +Discovery endpoints are public so that external clients can find your agents. The invocation endpoint requires a **Bearer token** — this is a regular Magec client token, the same ones you create in the Admin UI under Clients. |
| 46 | + |
| 47 | +## Connecting a client |
| 48 | + |
| 49 | +Give the external A2A client this URL: |
| 50 | + |
| 51 | +``` |
| 52 | +https://your-server/api/v1/a2a/{agentId} |
| 53 | +``` |
| 54 | + |
| 55 | +The client will automatically fetch the agent card from the `.well-known` path relative to that URL, read the security requirements, and use the Bearer token you provide to send messages. |
| 56 | + |
| 57 | +## Public URL |
| 58 | + |
| 59 | +By default, agent cards reference `http://localhost:{port}` as the agent's URL. This works for local development but not when your server is behind a reverse proxy or exposed to the internet. |
| 60 | + |
| 61 | +Set `publicURL` in your config so that agent cards contain the correct address: |
| 62 | + |
| 63 | +```yaml |
| 64 | +server: |
| 65 | + publicURL: https://magec.example.com |
| 66 | +``` |
| 67 | +
|
| 68 | +{{< callout type="info" >}} |
| 69 | +If you don't set `publicURL`, everything still works locally. You only need it when external systems need to reach your server from outside. |
| 70 | +{{< /callout >}} |
| 71 | + |
| 72 | +## What's in an agent card? |
| 73 | + |
| 74 | +The agent card is what clients read to understand your agent. Here's what it contains: |
| 75 | + |
| 76 | +| Field | Description | |
| 77 | +|-------|-------------| |
| 78 | +| `name` | Agent's display name | |
| 79 | +| `description` | What the agent does | |
| 80 | +| `url` | JSON-RPC endpoint for invocation | |
| 81 | +| `skills` | Auto-generated list of capabilities (from system prompt + tools) | |
| 82 | +| `securitySchemes` | How to authenticate (Bearer token) | |
| 83 | +| `capabilities` | Protocol features supported (streaming) | |
| 84 | + |
| 85 | +Skills are generated automatically from the agent's configuration. Each MCP tool the agent has access to appears as a separate skill. The agent's system prompt is reflected in the primary skill description, so external clients can understand what the agent is good at without any manual setup. |
| 86 | + |
| 87 | +## Hot-reload |
| 88 | + |
| 89 | +Like everything in Magec, A2A configuration reloads automatically. Enable or disable A2A on an agent, save, and the change is live — no restart needed. |
0 commit comments