ant_ai.acp.server
ACPServer
pydantic-model
Bases: BaseModel
Serve an ant-ai agent over the Agent Client Protocol (ACP).
Supports two modes:
- ASGI / WebSocket – call :meth:
starlette_appor :meth:fastapi_appto get an ASGI application that exposes the agent at/acp/ws. - stdio – call :meth:
serve_stdioto run the agent as a stdio ACP process that editors such as Zed or Gemini CLI can spawn directly.
To serve both A2A and ACP from a single process, combine the routes from each server's ASGI app — they occupy disjoint paths and compose cleanly:
from starlette.applications import Starlette
a2a = A2AServer(agent=agent, workflow=wf, agent_card=card)
acp = ACPServer(agent=agent, workflow=wf)
app = Starlette(routes=[*a2a.starlette_app().routes, *acp.starlette_app().routes])
# A2A: POST / and GET /.well-known/agent-card.json
# ACP: WS /acp/ws
Config:
arbitrary_types_allowed:True
Fields:
-
agent(Agent) -
workflow(Workflow) -
host(str) -
port(int) -
commands(list[ACPCommand]) -
context_class(type[InvocationContext])
Source code in src/ant_ai/acp/server.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
context_class
pydantic-field
context_class: type[InvocationContext] = InvocationContext
The InvocationContext (sub)class built for each prompt. Subclass InvocationContext to carry your own fields through the run.
starlette_app
starlette_app() -> Starlette
Create a Starlette application serving ACP over WebSocket.
Source code in src/ant_ai/acp/server.py
144 145 146 | |
fastapi_app
fastapi_app() -> FastAPI
Create a FastAPI application serving ACP over WebSocket.
Source code in src/ant_ai/acp/server.py
148 149 150 | |
serve
serve() -> None
Start a uvicorn server exposing ACP over WebSocket at /acp/ws.
Source code in src/ant_ai/acp/server.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
serve_stdio
serve_stdio() -> None
Run the agent as a stdio ACP process (for editors/CLIs that spawn agents).
Source code in src/ant_ai/acp/server.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
build_acp_ws_route
build_acp_ws_route(
agent: Agent,
workflow: Workflow,
*,
commands: list[ACPCommand] | None = None,
context_class: type[
InvocationContext
] = InvocationContext,
) -> WebSocketRoute
Return a Starlette WebSocketRoute that bridges ACP over WebSocket at /acp/ws.
Source code in src/ant_ai/acp/server.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |