---
title: 'Registering Agents for Discovery with A2A Cards'
date: '2026-11-16T09:24:00+07:00'
description: 'How agents become discoverable in the A2A ecosystem: authoring the Agent Card, publishing at /.well-known/agent-card.json, signing and versioning it, and building registries and catalogs so orchestrators can find agents at runtime.'
author: 'AI Assistant'
image: 'https://blog.redlinesoft.net/images/post/registering-agents-discovery-a2a-cards.jpg'
alt: 'A library card catalog drawer open with index cards, representing registering agents for discovery with A2A cards'
tags: ['a2a', 'agents', 'agent-discovery', 'registry', 'protocol', 'interoperability']
---

An agent nobody can find cannot be delegated to. Yet most agent deployments are addressed the way microservices were in 2015: a URL in a config file, a service name hardcoded in a client, a wiki entry nobody updates. That works for a two-agent demo and collapses the moment an orchestrator - your own, or a partner's - needs to decide *at runtime* which agent handles a request. Discovery has to be a first-class, machine-readable, continuously valid fact, or it is not discovery.

The **Agent2Agent (A2A) protocol** answers this with the **Agent Card**: a self-describing JSON manifest every A2A server MUST publish, which clients fetch before doing anything else. In this tutorial you will learn what "registered" means in A2A - authoring the card, publishing it at the well-known URL, signing and versioning it, and layering registries and catalogs on top when one card per server is not enough.

## Prerequisites

- Python 3.11+ with FastAPI and httpx (`pip install fastapi uvicorn httpx`)
- Familiarity with the A2A task/message basics (see the [A2A repository](https://github.com/google/A2A))
- HTTPS termination in production (self-signed works for local testing only)
- Optional: a signing key pair for JWS card signatures

## Step 1: Author the Card

Registration starts with the manifest itself. The required surface in the 1.0 line is deliberately small; everything else is optional signal:

```python
from a2a.types import (
    AgentCapabilities, AgentCard, AgentSkill,
)

def build_card(base_url: str) -> AgentCard:
    return AgentCard(
        name="Freight Quote Agent",
        description="B2B freight quoting across ocean, air, and road",
        version="1.2.0",
        url=f"{base_url}/rpc",                      # where JSON-RPC is served
        preferredInterface="jsonrpc-1.0",
        protocolVersion="1.0",
        capabilities=AgentCapabilities(
            streaming=True,
            pushNotifications=True,
            extendedAgentCard=True,
        ),
        skills=[
            AgentSkill(
                id="quote-ocean",
                name="Ocean Freight Quote",
                description="Quote an ocean shipment by lanes, volume, and date",
                inputModes=["text", "file"],
                outputModes=["text"],
                tags=["logistics", "quote"],
            ),
            AgentSkill(
                id="quote-air",
                name="Air Freight Quote",
                description="Quote an air shipment by weight and routing",
                inputModes=["text"],
                outputModes=["text"],
                tags=["logistics", "quote"],
            ),
        ],
    )
```

Registration decisions that matter for discoverability:

- **`skills[].id` is your API.** Orchestrators match on it. Renaming an id is a breaking change for every consumer that routed on the old one; treat ids like endpoints.
- **`description` is retrieval text, not prose for humans.** Include the nouns and verbs a router would search for ("quote," "shipment," "customs clearance"). The more a skill description mirrors how requesters phrase work, the better it matches.
- **`capabilities.*` must be true or the feature must be absent.** Declaring `streaming: true` while returning errors on `SendStreamingMessage` breaks clients that trusted your card. Interop test suites (see our [interoperability testing post](/posts/verifying-a2a-interoperability-test-suite)) assert exactly this.
- **`version` feeds cache invalidation.** Bump it when the contract changes; clients use it to decide whether their cached card is stale.

## Step 2: Publish at the Well-Known URL

A card is registered by being *reachable at a standardized location*. The specification registers `agent-card.json` as a well-known URI:

```text
https://agent.example.com/.well-known/agent-card.json
```

With FastAPI:

```python
import json
from fastapi import FastAPI, Response

app = FastAPI()
CARD = build_card("https://agent.example.com")
CARD_JSON = CARD.model_dump_json(by_alias=True, exclude_none=True)

@app.get("/.well-known/agent-card.json")
def agent_card(if_none_match: str | None = None) -> Response:
    etag = f'W/"{CARD.version}"'
    if if_none_match == etag:
        return Response(status_code=304)
    return Response(
        content=CARD_JSON,
        media_type="application/json",
        headers={
            "Cache-Control": "public, max-age=300",
            "ETag": etag,
        },
    )
```

Publishing details that separate a registration from a mistake:

- **TLS is mandatory in production.** Discovery happens before any authenticated exchange; an HTTP card endpoint leaks your capability map to anyone on the path and will be rejected by serious clients anyway.
- **Caching headers are part of the contract.** `ETag` + `Cache-Control` (or `Last-Modified`) let orchestrators revalidate cheaply. Without them, a fleet re-downloading cards becomes your discovery traffic.
- **The card URL and the RPC URL are different things.** The well-known path is where you are *found*; `card.url` (or the declared interface entries) is where you are *called*. Keeping them on the same origin with the same TLS story avoids mixed-origin surprises.
- **Serve the same bytes everywhere.** Staging and production cards should differ only where they genuinely differ (URL, version). Divergent skills between environments is a classic source of "works in staging, unroutable in prod."

## Step 3: Sign the Card

On the open web, a reachable card is not a *trustworthy* card. The specification supports card signatures (JWS over a canonicalized payload, JCS RFC 8785) so clients can verify the card came from who they think:

```python
import base64, json

def sign_card(card_json: str, private_pem: bytes) -> dict:
    from cryptography.hazmat.primitives import hashes, serialization
    from cryptography.hazmat.primitives.asymmetric import padding

    payload = json.dumps(json.loads(card_json), sort_keys=True,
                         separators=(",", ":")).encode()   # JCS-style canonical form
    key = serialization.load_pem_private_key(private_pem, password=None)
    der_sig = key.sign(payload, padding.PKCS1v15(), hashes.SHA256())
    b64 = base64.urlsafe_b64encode(der_sig).rstrip(b"=").decode()

    card = json.loads(card_json)
    card.setdefault("signatures", []).append({
        "protected": {"alg": "RS256", "kid": "card-2026-11"},
        "signature": b64,
    })
    return card
```

Consumers verify by resolving the public key (a JWKS endpoint or your PKI), re-canonicalizing the payload, and checking the signature. Not every deployment signs - inside a single trust domain, TLS plus registry admission may be enough - but for *cross-organization* discovery, signatures are how a partner's orchestrator distinguishes your real card from a spoofed one served from a lookalike domain.

## Step 4: Version and Evolve Without Breaking Discovery

Registration is a lifecycle, not an event. The safe-evolution rules:

- **Additive changes are routine:** new skills, new optional fields, additional interfaces. Clients must tolerate them (the spec assigns clients that responsibility).
- **Removing or renaming a skill, changing `url`, or dropping a capability is breaking.** Do it behind a major `version` bump, and expect orchestrators to alert on the diff.
- **Publish a diff check in CI:**

```python
def card_diff(old: dict, new: dict) -> list[str]:
    changes = []
    if old.get("version") != new.get("version"):
        changes.append(f"version {old['version']} -> {new['version']}")
    old_skills = {s["id"] for s in old.get("skills", [])}
    new_skills = {s["id"] for s in new.get("skills", [])}
    changes += [f"removed skill: {s}" for s in sorted(old_skills - new_skills)]
    changes += [f"added skill: {s}" for s in sorted(new_skills - old_skills)]
    for cap in ("streaming", "pushNotifications", "extendedAgentCard"):
        before = (old.get("capabilities") or {}).get(cap, False)
        after = (new.get("capabilities") or {}).get(cap, False)
        if before and not after:
            changes.append(f"capability dropped: {cap}")
    return changes
```

Gate the deploy on `removed skill` and `capability dropped` findings the same way you would gate an OpenAPI breaking change.

## Step 5: Extended Cards - Register More Than You Publish

Sometimes the public card should advertise presence without advertising everything. With `capabilities.extendedAgentCard: true`, the public card is the discovery minimum and the **extended card** is the authenticated contract: additional skills, internal endpoints, stricter security requirements. Clients that authenticate fetch it with `GetExtendedAgentCard` and SHOULD replace their cached public card with the result for the duration of the session.

```text
Public card (unauthenticated):  2 skills, base capabilities
Extended card (authenticated):  6 skills, internal interfaces, scoped security
```

This gives you a two-tier registration: strangers can *discover* you; partners can *use* you.

## Step 6: Registries and Catalogs - When You Have More Than a Few Cards

One server, one card, one well-known URL scales fine for dozens of agents. At hundreds - an enterprise fleet, a multi-vendor platform - you need a directory layer. A2A does not mandate a registry design, but the pattern that works is: **cards remain authoritative at their origins; the registry is a cache with metadata.**

A minimal registry:

```python
from pydantic import BaseModel

class Registration(BaseModel):
    base_url: str          # origin that serves /.well-known/agent-card.json
    owner: str             # team or tenant
    tier: str = "internal"
    approved: bool = False

async def register(reg: Registration) -> None:
    card = await fetch_card(reg.base_url)      # validate at registration time
    assert card.get("name") and card.get("skills"), "incomplete card"
    await db.registrations.upsert(reg)
    await db.card_cache.put(reg.base_url, card, version=card["version"])

async def refresh_loop(interval_s: int = 300) -> None:
    while True:
        for reg in await db.registrations.all():
            try:
                fresh = await fetch_card(reg.base_url)
            except Exception:
                await mark_unhealthy(reg)      # unreachable != deregistered
                continue
            cached = await db.card_cache.get(reg.base_url)
            if cached and cached["version"] != fresh["version"]:
                changes = card_diff(cached, fresh)
                await notify_owner(reg, changes)   # breaking-change alerts
            await db.card_cache.put(reg.base_url, fresh, version=fresh["version"])
        await asyncio.sleep(interval_s)
```

Design rules borrowed from service-registry hardening, adapted to A2A:

- **Validate on registration, revalidate forever.** A registry that trusts initial input rots; periodic card fetches with version diffs keep the catalog honest.
- **Unhealthy is a state, not a deletion.** Agents go down; removing them from the catalog because one probe failed causes discovery flapping.
- **Index what routers search:** skills, tags, owner, tenant, tier. The registry's job is fast candidate selection; the card remains the contract.
- **Never serve a cached card as truth after a version bump.** Fetch from the origin before routing high-stakes work, or honor the card's own cache directives.
- **Multi-tenant platforms:** scope registrations per tenant and include tenant identity in routing decisions, so one tenant's agent never becomes another tenant's candidate.

## Putting It All Together

Registration in A2A is a loop, not a step:

1. **Author** the card with stable skill ids and retrieval-friendly descriptions.
2. **Publish** it at `/.well-known/agent-card.json` over TLS, with `ETag`/`Cache-Control`.
3. **Sign** it where the trust domain crosses organizational boundaries.
4. **Version** it, and gate breaking diffs in CI.
5. **Extend** it behind authentication when the full contract is partner-only.
6. **Register** the origin in a catalog that refreshes, diffs, and alerts - while the card at the origin stays authoritative.

An orchestrator then does what the protocol intends: fetch, cache, revalidate, match a skill, delegate a task. No config file, no wiki page, no outage meeting to ask "what URL does that team's agent live on again?"

## Conclusion & Next Steps

Discoverability is the price of admission for agent collaboration, and A2A makes it a protocol property rather than an operational habit: one well-known URL, one self-describing manifest, one version number to diff. Build the publishing discipline right - signed where trust crosses orgs, versioned like an API, cataloged with refresh loops - and your agents become findable by any conformant client, including the ones your partners have not written yet.

Homework:

- Move one hardcoded agent URL in your codebase to card-based discovery.
- Add card signing plus client-side verification to a cross-team integration.
- Stand up a 10-entry registry with a refresh loop and breaking-change alerts.

Sources: [A2A Protocol repository (google/A2A)](https://github.com/google/A2A), [A2A Protocol Specification - Agent Discovery Objects and Well-Known URI Registration](https://a2a-protocol.org/latest/specification/), [A2A Agent Discovery Documentation](https://a2a-protocol.org/latest/documentation/)
