Get started with Agent Communication Protocol (ACP): Establish a Weather Proxy with Python

Agent Communication Protocol (ACP) is an open standard designed to enable seamless communication between AI agents, applications and humans. Since AI systems are often developed using various frameworks and infrastructure, they may end up being isolated and incompatible, limiting their ability to collaborate. ACP resolves this split by providing a unified Restful API that facilitates:
- Multimode communication
- Synchronous and asynchronous messaging
- Real-time streaming
- Support status and stateless agent interactions
- Discover the modern dealer, whether online or offline
- Perform long-term tasks
In this tutorial, we will take the first step of ACP by building a basic server that provides London weather information and a simple client that can interact with.
Set up dependencies
Install the library
pip install acp acp-sdk beeai-framework httpx
Create an ACP server
We will first set up the ACP server, from the creation agent.py document.
We will first import the necessary libraries. To get the weather data for London, we will use the HTTPX library to make a request to the Open -Meteo API.
import asyncio
from collections.abc import AsyncGenerator
import httpx
from acp_sdk.models import Message, MessagePart
from acp_sdk.server import Context, RunYield, RunYieldResume, Server
server = Server()
Next, we will define an asynchronous accessibility feature called get_london_weather, which uses the Open -Meteo API to retrieve the current weather in London. This feature sends a request for London coordinates and returns a formatted weather summary including temperature, wind speed and weather condition codes.
async def get_london_weather() -> str:
"""Fetch current London weather from the free Open‑Meteo API."""
params = {
"latitude": 51.5072, # London coordinates
"longitude": -0.1276,
"current_weather": True,
"timezone": "Europe/London"
}
url = "
async with httpx.AsyncClient(timeout=10) as client:
resp = await client.get(url, params=params)
resp.raise_for_status()
cw = resp.json()["current_weather"]
return (
f"Weather in London: {cw['temperature']} °C, "
f"wind {cw['windspeed']} km/h, code {cw['weathercode']}."
)
This code defines an ACP-compatible agent using the @server.agent() decorator. The London_Weather_Agent function first emits an idea message to handle incoming messages, and then uses the get_london_weather() helper to get the current weather from London asynchronously. The weather data is then returned as a plain text message. Finally, server.run() starts the ACP server and makes the proxy available to handle the request
@server.agent()
async def london_weather_agent(
input: list[Message], context: Context
) -> AsyncGenerator[RunYield, RunYieldResume]:
"""Returns current London weather."""
for _ in input:
yield {"thought": "Fetching London weather..."}
weather = await get_london_weather()
yield Message(
role="agent",
parts=[MessagePart(content=weather, content_type="text/plain")]
)
server.run()
Run the server
Next, we will run the Agent.py file to start the server. After running, the ACP agent will be able to
To verify that your agent is up and running, open a new terminal and execute the following curl command:
curl /agents
If everything works properly, you will receive a JSON response listing your agent, confirming that it can be used and ready to process the request.
{
"agents": [
{
"name": "london_weather_agent",
"description": "Returns current London weather.",
"metadata": {
"annotations": null,
"documentation": null,
"license": null,
"programming_language": null,
"natural_languages": null,
"framework": null,
"capabilities": null,
"domains": null,
"tags": null,
"created_at": null,
"updated_at": null,
"author": null,
"contributors": null,
"links": null,
"dependencies": null,
"recommended_models": null
},
"input_content_types": [
"*/*"
],
"output_content_types": [
"*/*"
]
}
]
}
Create an ACP client
We will now create an ACP client (Client) Interact with our server.
This client script uses the ACP SDK to connect to the locally running London_Weather_Agent through the ACP server. It sends a synchronous message through the run_sync method asking for weather. After the broker responds, the script will print out the returned weather details.
import asyncio
from acp_sdk.client import Client
from acp_sdk.models import Message, MessagePart
async def call_london_weather_agent() -> None:
async with Client(base_url="") as client:
run = await client.run_sync(
agent="london_weather_agent",
input=[
Message(
parts=[MessagePart(content="Tell me the weather", content_type="text/plain")]
)
],
)
print("Response from london_weather_agent:")
for message in run.output:
for part in message.parts:
print("-", part.content)
if __name__ == "__main__":
asyncio.run(call_london_weather_agent())
Run the client
In another terminal, run the following command to send the request to our ACP server
You should see the response of the London_Weather_Agent returned by the current weather server.
Response from london_weather_agent:
- Weather in London: 20.8 °C, wind 10.1 km/h, code 3.
Check Code. All credits for this study are to the researchers on the project. Also, please stay tuned for us twitter,,,,, Youtube and Spotify And don’t forget to join us 100K+ ml reddit And subscribe Our newsletter.
I am a civil engineering graduate in Islamic Islam in Jamia Milia New Delhi (2022) and I am very interested in data science, especially neural networks and their applications in various fields.