The Agent-to-Agent (A2A) protocol enables autonomous communication between agents built with different frameworks, hosted in different environments, and managed by different teams.
A2A uses a client-server model:
from a2a import A2AServer, AgentCard
server = A2AServer()
@server.agent_card
def get_card():
return AgentCard(
name="WeatherAgent",
description="Provides weather information",
url="http://localhost:8000/a2a",
capabilities=["get_weather"]
)
@server.handle("get_weather")
async def get_weather(location: str):
# Call weather API
return {"temperature": 22, "conditions": "sunny"}
server.run(port=8000)
# Expose any Foundry agent as an A2A endpoint
from a2a import A2AAdapter
from azure.ai.projects import AIProjectClient
adapter = A2AAdapter(client, agent_id)
adapter.expose(port=8000)
A2A supports streaming for real-time agent communication:
async for chunk in a2a_client.send_message_stream("What's the weather?", agent_url):
print(chunk.text, end="")
Combine both protocols: use MCP for tool exposure and A2A for agent-to-agent communication. MCP provides tools; A2A provides agent orchestration across boundaries.
Deploy A2A servers to Azure Container Apps, AKS, or Azure Functions. Use Azure API Management to manage, secure, and monitor A2A endpoints.