Copy
Ask AI
"""
Google ADK A2A Server for Cookbook Examples.
Uses Google's ADK to create an A2A-compatible agent.
Requires GOOGLE_API_KEY environment variable.
This server exposes a facts-agent that provides interesting facts,
using pure JSON-RPC at root "/" endpoint (Google ADK style).
Start this server before running 05_remote_adk_agent.py
"""
import os
from a2a.types import AgentCapabilities, AgentCard
from google.adk import Agent
from google.adk.a2a.utils.agent_to_a2a import to_a2a
from google.adk.tools import google_search
# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------
port = int(os.getenv("PORT", "7780"))
agent = Agent(
name="facts_agent",
model="gemini-2.5-flash-lite",
description="Agent that provides interesting facts.",
instruction="You are a helpful agent who provides interesting facts.",
tools=[google_search],
)
# Define A2A agent card
agent_card = AgentCard(
name="facts_agent",
description="Agent that provides interesting facts.",
url=f"http://localhost:{port}",
version="1.0.0",
capabilities=AgentCapabilities(
streaming=True, push_notifications=False, state_transition_history=False
),
skills=[],
default_input_modes=["text/plain"],
default_output_modes=["text/plain"],
)
app = to_a2a(agent, port=port, agent_card=agent_card)
# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=port)
Run the Example
Copy
Ask AI
# Clone and setup repo
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/05_agent_os/remote
# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate
# Export relevant API keys
export PORT="***"
python adk_server.py