Python SDK for building Agent Client Protocol (ACP) agents and clients, with generated Pydantic models and asyncio transports over stdio, Streamable HTTP, and WebSocket.
pip install agent-client-protocol
# or
uv add agent-client-protocolFor experimental HTTP/WebSocket transports, install the http extra (pip install "agent-client-protocol[http]"). Requires Python 3.10–3.15.
import asyncio
from typing import Any
from uuid import uuid4
from acp import PROTOCOL_VERSION, Agent, InitializeResponse, NewSessionResponse, PromptResponse, run_agent
from acp.interfaces import Client
from acp.schema import AgentMessageChunk, TextContentBlock
class EchoAgent(Agent):
def on_connect(self, conn: Client) -> None:
self._conn = conn
async def initialize(self, protocol_version: int, **kwargs: Any) -> InitializeResponse:
return InitializeResponse(protocol_version=PROTOCOL_VERSION)
async def new_session(self, cwd: str, **kwargs: Any) -> NewSessionResponse:
return NewSessionResponse(session_id=uuid4().hex)
async def prompt(self, session_id: str, prompt: list[Any], **kwargs: Any) -> PromptResponse:
for block in prompt:
text = getattr(block, "text", "")
await self._conn.session_update(
session_id=session_id,
update=AgentMessageChunk(content=TextContentBlock(text=text)),
)
return PromptResponse(stop_reason="end_turn")
if __name__ == "__main__":
asyncio.run(run_agent(EchoAgent()))import asyncio
import sys
from typing import Any
from acp import PROTOCOL_VERSION, Client, spawn_agent_process
from acp.schema import TextContentBlock
class SimpleClient(Client):
async def session_update(self, session_id: str, update: Any, **kwargs: Any) -> None:
print(session_id, update)
async def main() -> None:
async with spawn_agent_process(SimpleClient(), sys.executable, "examples/echo_agent.py") as (conn, _proc):
await conn.initialize(protocol_version=PROTOCOL_VERSION)
session = await conn.new_session(cwd=".", mcp_servers=[])
await conn.prompt(session_id=session.session_id, prompt=[TextContentBlock(text="Hello ACP!")])
asyncio.run(main())- Quickstart — Connect your agent to Zed, Toad, Lody, or T3 Code, or drive agents programmatically.
- Protocol Features — Unstable opt-in methods, session notices, stateless MCP-over-ACP, cancellation, and extensions (
schema-v1.35.0). - Web Transport — Serve and consume ACP over Streamable HTTP and WebSocket (
[http]). - Experimental Protocol v2 — Preview v2 runtime (
schema-v2.0.0-beta.4) and dual-stackAgentProtocolRouter. - Examples · Contrib · Use Cases · Testing
make install # Set up uv environment and pre-commit hooks
make check # Format, lint, type-check, and dependency check
make test # Run pytest suiteJoin the conversation on GitHub Discussions, Zulip, or agentclientprotocol.com.