Starting with Agent Comocol (ACP): Create a weather agent with Python

Agent Commonoy Protocol (ACP) is an open standard for enabling a burden communication between agents AIs, apps, and people. As AI programs are often constructed using a variety of structures and infrastructure, they may eventually be classified and restrict their partnership. ACP has directed this distinguishing by giving an acceptable API of united API.
- Multimodal connections
- Both messages agree with asynchronous
- The Real Time Distribution
- Support of active and attitude support
- Agent receipts, can be online or offline
- The killing of long running jobs
In this lesson, we will take our first steps through ACP by creating a basic server that provides London Climate Information and a simple client that can work with.
To set up the dependence
Installing libraries
pip install acp acp-sdk beeai-framework httpx
To create an ACP server
We will start with an ACP server, starting with the construction of Agent.uppy File.
We will start by introducing the required library libraries. To download London climate data, we will use the HTTPX library to apply to 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 explain the Asynchronous Help for the GET_LODON_Weather that takes the current weather in London using Open-Meteo API. This work sends a request to London links and returns the summary of the formatted weather including temperature, air speed, and weather code.
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 describes an ACP agent using @ server.Agent () decoration. London work is weather data and returns as an obvious text message. Finally, the server.run () starts ACP server and makes an agent available to manage applications
@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()
Using the server
Next, we will use an agent.py file to start the server. On the run, ACP agent will be available to manage applications at
To ensure that your agent has arisen and works, open the new terminal and removes the following curl command:
curl /agents
If all works well, you will receive a JSON feedback to write your agent, ensuring that it is available and ready to manage applications.
{
"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": [
"*/*"
]
}
]
}
Creating ACP Client
Now we will create ACP client (the client.) Communication with our server.
This client text uses ACP SDK to connect to London_Weather_weagent with an ACP server. Sends a permanent message asking for the weather using the route of the run_Sync. When an agent responds, the text sets back weather information.
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())
Running the client
In one end, use the following command to send an application to our ACP server
You must see the answer from the current weather conditions in London, restored by London_weather_agent.
Response from london_weather_agent:
- Weather in London: 20.8 °C, wind 10.1 km/h, code 3.
Look Codes. All credit for this study goes to research for this project. Also, feel free to follow it Sane, YouTube including Disclose and don't forget to join ours 100K + ml subreddit Then sign up for Our newspaper.
I am the student of the community engineering (2022) from Jamia Millia Islamia, New Delhi, and I am very interested in data science, especially neural networks and their application at various locations.



