Python SDK for building Agent Client Protocol (ACP) agents and clients, with generated Pydantic models and asyncio transports over stdio, Streamable HTTP, and WebSocket.
ACP v2 is in Preview: "Preview is the same stage our RFDs go through before we complete them. The work is implemented and ready for broad review. For v2, that means we think the design is settled enough to build on. If you were waiting for the Draft to stop moving before you started, this is the time to start." — ACP v2 is available in Preview · See the Protocol v2 (Preview) guide.
pip install agent-client-protocol
# or
uv add agent-client-protocolFor Streamable HTTP and 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 an agent to Zed, Toad, Lody, or T3 Code, or drive agents from Python.
- Protocol Features (v1) — Unstable opt-in methods, session notices, stateless MCP-over-ACP, cancellation, and extensions.
- Web Transport — Serve and consume ACP over Streamable HTTP and WebSocket (
[http]). - Protocol v2 (Preview) — Preview v2 runtime and dual-stack
AgentProtocolRouter. - API Reference — Core entrypoints, connection classes, transports, and contrib helpers.
- Examples · Contrib · Use Cases · Testing · Migration Guides
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.