This sample demonstrates how to host Agent Framework agents as A2A-compliant servers using the A2A (Agent2Agent) protocol.
Looking for client samples? See
samples/02-agents/a2a/for consuming remote A2A agents.
| Run this file | To... |
|---|---|
a2a_server.py |
Host an Agent Framework agent as an A2A-compliant server (multi-agent). |
agent_framework_to_a2a.py |
Minimal example: expose a single agent as an A2A server. |
| File | Description |
|---|---|
agent_definitions.py |
Agent and AgentCard factory definitions for invoice, policy, and logistics agents. |
invoice_data.py |
Mock invoice data and tool functions for the invoice agent. |
a2a_server.http |
REST Client requests for testing the server directly from VS Code. |
FOUNDRY_PROJECT_ENDPOINT— Your Azure AI Foundry project endpointFOUNDRY_MODEL— Model deployment name (e.g.gpt-4o)
All commands below should be run from this directory:
cd python/samples/04-hosting/a2aCopy .env.example to .env and fill in your values:
copy .env.example .envOption A — pip (standard):
python -m venv .venv
.venv\Scripts\Activate.ps1 # Windows
# source .venv/bin/activate # macOS / Linux
pip install -r requirements.txtOption B — uv:
uv run python a2a_server.py --agent-type policyNote (Option A — pip users): Replace
uv run pythonwithpythonin alluv runcommands below.uvis not required once the virtual environment is activated.
Pick an agent type and start the server (each in its own terminal):
uv run python a2a_server.py --agent-type invoice --port 5000
uv run python a2a_server.py --agent-type policy --port 5001
uv run python a2a_server.py --agent-type logistics --port 5002You can run one agent or all three — each listens on its own port.
Once a server is running, use any of the client samples in samples/02-agents/a2a/:
cd python/samples/02-agents/a2a
$env:A2A_AGENT_HOST = "http://localhost:5001/"
uv run python agent_with_a2a.py