A server agent is the receiving role in an agent-to-agent (A2A) interaction. It exposes compatible endpoints, processes a client agent’s request within its own isolated context, and returns results. The roles are dynamic: the same agent can act as a client when it delegates a subtask. section 7.8.1
An agent card lets clients discover the server’s capabilities before sending work. The card can describe its skills, supported interfaces, feature flags, and security requirements. A client uses that information to select an interface and submit task context. section 7.8.1 section 7.9.6
Simplified weather server
A Flask server publishes an agent card and accepts a message:send request. The client fetches the card, selects an interface, and sends a location in a message. The server extracts the location and returns a completed task-shaped response with an artifact; the weather values are randomly generated. section 7.9.6
Listing 7.7 Flask server snippet for handling a simplified A2A message request
@app.route('/message:send', methods=['POST'])
def send_message():
request_payload = request.json or {}
message = request_payload.get("message", {})
parts = message.get("parts", [])
location = "an unspecified location"
for part in parts:
text = part.get("text", "")
if "location:" in text.lower():
location = text.split(":", 1)[1].strip()
break
weather = random.choice(["Sunny", "Cloudy", "Windy"]) #1
temperature = random.randint(30, 90)
response_text = f"The current weather in {location} is {weather}
at {temperature} degrees F."
response_payload = {
"task": {
"id": str(uuid.uuid4()),
"contextId": str(uuid.uuid4()),
"status": {"state": "TASK_STATE_COMPLETED"},
"artifacts": [
{
"artifactId": str(uuid.uuid4()),
"name": "Current weather",
"parts": [{"text": response_text}]
}
]
}
}
return jsonify(response_payload), 200, {"Content-Type":
"application/a2a+json"}
Inspect the server’s message handler, location extraction, and completed task-shaped response. section 7.9.6
The weather server is a teaching scaffold, not a conformant A2A implementation. Production systems should select the protocol binding from the agent card, validate capabilities, authenticate requests, handle task and context identifiers correctly, and support the required interaction mechanism. Consult the current specification because A2A continues to evolve. section 7.9.6 section 7.8.1
