The agent's communication protocol (ACP) is an open standard designed to allow transparent communication between AI agents, applications and humans. As AI systems are often developed using various executives and infrastructures, they can end up being isolated and incompatible, which limits their ability to collaborate. ACP addresses this fragmentation by offering a unified restaurant that facilitates:
- Multimodal communication
- Synchronous and asynchronous messaging
- Real -time streaming
- Support for agent interactions with state and without state
- Discovery of agents, whether online or offline
- Execution of longtime tasks
In this tutorial, we will take our first steps with ACP by building a basic server that provides weather information from London and a simple customer who can interact with him.
Dependencies configuration
Installation of libraries
pip install acp acp-sdk beeai-framework httpx
Creation of the ACP server
We will start by configuring the ACP server, starting with the creation of a agent.py deposit.
We will start by importing the necessary libraries. To recover the weather data from London, we will use the HTTPX library to apply for 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()
Then, we will define an asynchronous assistance function called Get_London_Weather which recovers the current weather in London using the Open-Meteo API. This function sends a request with the coordinates of London and returns a summary of the formatted weather conditions, including the temperature, wind speed and the code of weather conditions.
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 = "https://api.open-meteo.com/v1/forecast"
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 manages incoming messages by first giving a reflection message, then asynchronously recovering the current weather in London using the assistance Get_London_Weather (). The weather data is then returned as a gross text message. Finally, Server.run () starts the ACP server and makes the agent available to manage requests
@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()
Server
Then we will run the agent.py file to start the server. Once in progress, the ACP agent will be available to process requests on http: // localhost: 8000
To verify that your agent is operational, open a new terminal and run the following curl command:
curl http://localhost:8000/agents
If everything is working properly, you will receive a JSON response listing your agent, confirming that it is available and ready to manage requests.
{
"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": (
"*/*"
)
}
)
}
Creation of the ACP customer
We will now create an ACP client (client.Py) to interact with our server.
This customer script uses the SDK ACP to connect to the London_Weather_AGENT Locally executed via the ACP server on http: // Localhost: 8000. It sends a synchronous message requesting the weather using the RUN_SYNC method. Once the agent is answered, the script prints the details of the returned weather.
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="http://localhost:8000") 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())
Customer
In another terminal, run the following order to send a request to our ACP server
You should see an response from the server containing the current weather in London, returned by London_weather_agent.
Response from london_weather_agent:
- Weather in London: 20.8 °C, wind 10.1 km/h, code 3.
Discover the Codes. All the merit of this research goes to researchers in this project. Also, don't hesitate to follow us Twitter,, YouTube And Spotify And don't forget to join our Subseubdredit 100k + ml and subscribe to Our newsletter.
