⚡TL;DR
Want to build a smart agent that can be discovered and communicated with by any A2A-compliant client? This guide shows you how to create a complete Agent-to-Agent (A2A) weather system using Python, Tavily, and Gemini. You'll build an A2A-compliant weather bot server and a client that discovers it, sends weather queries, and receives polished responses. It’s the cleanest intro you’ll find to agent discovery, task handling, and structured communication with real AI output.
The Agent-to-Agent (A2A) protocol is redefining how autonomous agents collaborate. It replaces custom API spaghetti with a clean structure: agents self-discover, send tasks, and return results — all through standard JSON endpoints.
In this guide, you’ll build:
✅ A client agent that finds the server, sends a weather query, and displays a smart response
Let’s jump in.
🛠️ Project Setup (Minimal + Fast)
Let’s get your A2A weather agent project up and running in minutes — even if you’ve never built one before.
📁 Step 1: Set Up Your Project Folder
Open your terminal (Command Prompt, PowerShell, or Terminal app) and run:
bash
mkdir a2a-weather && cd a2a-weather
uv init
uv venv && source .venv/bin/activate # (Windows: .venv\Scripts\activate)
Install your dependencies:
requirements.txt
txt
flask==3.0.0
requests==2.31.0
tavily-python>=0.3.0
python-dotenv==1.0.0
tiktoken>=0.7.0
langchain-google-genai==1.0.10
bash
uv pip install -r requirements.txt
.env
ini
TAVILY_API_KEY=your_tavily_key
GOOGLE_API_KEY=your_gemini_key
🔑 Get your keys:
🧠 Build the Weather Server Agent
File: server/weather_server.py
This agent:
Exposes
/.well-known/agent.json
for discoveryAccepts tasks at
/tasks/send
Uses Tavily for real-time weather
Uses Gemini to summarize results
Key Endpoints:
python
@app.route("/.well-known/agent.json")
def agent_card():
return jsonify({
"name": "WeatherBot",
"description": "Get real-time weather with AI summaries",
"url": "http://127.0.0.1:5000",
"version": "1.0",
"capabilities": {"streaming": False, "pushNotifications": False}
})
@app.route("/tasks/send", methods=["POST"])
def handle_task():
task_data = request.get_json()
query = task_data["message"]["parts"][0]["text"]
# Tavily search
results = tavily.search(query=f"current weather {query}", max_results=3)
text_blobs = "\n\n".join([f"{r['title']}: {r['content']}" for r in results.get('results', [])])
# Gemini summary
prompt = f"""
Provide a weather summary for {query} using:
{text_blobs}
Keep it under 150 words. Include temp, humidity, wind, and alerts.
"""
summary = llm.invoke(prompt).content if text_blobs else "No data found."
return jsonify({
"id": task_data["id"],
"status": {"state": "completed"},
"messages": [
task_data["message"],
{"role": "agent", "parts": [{"text": summary}]}
]
})
🤖 Build the Client Agent
File: client/weather_client.py
This client:
Finds the weather agent via discovery
Sends tasks in A2A format
Parses and prints the agent's response
python
client = WeatherClient()
print("Discovering agent...")
client.discover_agent()
for city in ["London", "Tokyo", "New York"]:
print(f"\nGetting weather for {city}...")
print(client.ask_weather(city))
🔁 A2A Workflow, Step-by-Step
Discovery
GET /.well-known/agent.json
→ Returns agent name, description, and capabilities.Task Creation
Client generates UUID
Packages query in A2A format
Task Submission
POST /tasks/send
→ Server extracts message, queries Tavily, summarizes with Gemini.Response
→ Server returns original + enhanced messageClient Output
→ Client shows the summary from the agent’s message
💻 Test It Locally
In one terminal:
bash
python server/weather_server.py
In another:
bash
python client/weather_client.py
You’ll see weather summaries like:
Tokyo
26.2°C with light rain. Humidity: 89%. Winds NNW at 35.6 kph. Heat index: 30.5°C. No alerts.
London
18.4°C, partly cloudy. Light winds. Humidity: 68%. Met Office warns of deep low system approaching.
🧩 Why This Matters
This simple weather app is more than a toy — it demonstrates real A2A interoperability.
✅ Clients discover agents with no config
✅ Messages follow a universal schema
✅ Any A2A agent can plug into any other
It’s Lego blocks for agents. Plug-and-play AI.

What’s Next?
In future builds:
Use Google’s Agent Development Kit (ADK)
Connect multiple A2A agents in a network
Combine A2A with Model Context Protocol (MCP)
- Black Box Brief
Follow for weekly drops that bridge the gap between AI innovation and real-world adoption—made for founders, entrepreneurs, builders, operators, and curious outliers.