aclientp
Class info¶
Re-exported classes¶
| Class | Module | Description |
|---|---|---|
| Agent | aclientp.agent.protocol | Base agent interface for ACP. |
| AgentAuthCapabilities | aclientp.schema.capabilities | Authentication-related capabilities supported by the agent. |
| AgentMessageChunk | aclientp.schema.session_updates | A chunk of the agent's response being streamed. |
| AgentSideConnection | aclientp.agent.connection | Agent-side connection. |
| AllowedOutcome | aclientp.schema.tool_call | The user selected one of the provided options. |
| Annotations | aclientp.schema.content_blocks | Optional annotations for the client. |
| ArchiveSessionRequest | aclientp.schema.client_requests | UNSTABLE: Request parameters for archiving a session. |
| ArchiveSessionResponse | aclientp.schema.agent_responses | UNSTABLE: Response to session/archive. |
| AuthCapabilities | aclientp.schema.capabilities | Authentication capabilities supported by the client. |
| AuthMethodAgent | aclientp.schema.common | Agent handles authentication itself. |
| AuthMethodTerminal | aclientp.schema.common | Terminal authentication method. |
| AuthStatusRequest | aclientp.schema.client_requests | UNSTABLE: Request the agent's current authentication state. |
| AuthStatusResponse | aclientp.schema.agent_responses | UNSTABLE: Response to auth/status. |
| AuthStatusUpdateNotification | aclientp.schema.notifications | UNSTABLE: The agent's authentication state changed (auth/status_update). |
| AuthenticateRequest | aclientp.schema.client_requests | Request parameters for the authenticate method. |
| AuthenticateResponse | aclientp.schema.agent_responses | Response to authenticate method. |
| AvailableCommand | aclientp.schema.slash_commands | Information about a command. |
| BooleanPropertySchema | aclientp.schema.elicitation | Schema for boolean properties in an elicitation form. |
| CancelNotification | aclientp.schema.notifications | Notification to cancel ongoing operations for a session. |
| CancelRequestNotification | aclientp.schema.notifications | Notification to cancel an ongoing request ($/cancel_request). |
| Client | aclientp.client.protocol | Base client interface for ACP. |
| ClientCapabilities | aclientp.schema.capabilities | Capabilities supported by the client. |
| ClientSideConnection | aclientp.client.connection | Client-side connection. |
| CloseSessionRequest | aclientp.schema.client_requests | Request parameters for closing an active session. |
| CloseSessionResponse | aclientp.schema.agent_responses | Response from closing a session. |
| CreateTerminalRequest | aclientp.schema.agent_requests | Request to create a new terminal and execute a command. |
| CreateTerminalResponse | aclientp.schema.client_responses | Response containing the ID of the created terminal. |
| DefaultACPClient | aclientp.client.implementations.default_client | Default implementation of ACP Client interface for basic operations. |
| DeleteSessionRequest | aclientp.schema.client_requests | Request parameters for deleting a session from session/list. |
| DeleteSessionResponse | aclientp.schema.agent_responses | Response to session/delete. |
| DeniedOutcome | aclientp.schema.tool_call | The prompt turn was cancelled before the user responded. |
| ElicitationCapabilities | aclientp.schema.elicitation | Elicitation capabilities supported by the client. |
| ElicitationCompleteNotification | aclientp.schema.elicitation | Notification sent by the agent when a URL-based elicitation is complete. |
| ElicitationFormCapabilities | aclientp.schema.elicitation | Form-based elicitation capabilities. |
| ElicitationRequest | aclientp.schema.elicitation | Request from the agent to elicit structured user input (elicitation/create). |
| ElicitationResponse | aclientp.schema.elicitation | Response from the client to an elicitation request. |
| ElicitationSchema | aclientp.schema.elicitation | Type-safe elicitation schema for requesting structured user input. |
| ElicitationUrlCapabilities | aclientp.schema.elicitation | URL-based elicitation capabilities. |
| EnumOption | aclientp.schema.elicitation | A titled enum option with a const value, human-readable title and optional description. |
| EnvVariable | aclientp.schema.common | An environment variable to set when launching an MCP server. |
| FileSystemCapabilities | aclientp.schema.capabilities | File system capabilities that a client may support. |
| ForkSessionRequest | aclientp.schema.client_requests | UNSTABLE: Request parameters for forking an existing session. |
| ForkSessionResponse | aclientp.schema.agent_responses | UNSTABLE: Response from forking an existing session. |
| HeadlessACPClient | aclientp.client.implementations.headless_client | Headless ACP client with real filesystem and terminal operations. |
| HttpMcpServer | aclientp.schema.mcp | HTTP transport configuration. |
| HttpTransport | aclientp.transports | Configuration for the Streamable HTTP & WebSocket server transport (experimental). |
| HttpTransportError | aclientp.http_transport | The ACP server rejected the connection or became unreachable. |
| Implementation | aclientp.schema.common | Describes the name and version of an ACP implementation. |
| InitializeRequest | aclientp.schema.client_requests | Request parameters for the initialize method. |
| InitializeResponse | aclientp.schema.agent_responses | Response from the initialize method. |
| IntegerPropertySchema | aclientp.schema.elicitation | Schema for integer properties in an elicitation form. |
| KillTerminalRequest | aclientp.schema.agent_requests | Request to kill a terminal command without releasing the terminal. |
| KillTerminalResponse | aclientp.schema.client_responses | Response to the terminal/kill method. |
| ListSessionsRequest | aclientp.schema.client_requests | Request parameters for listing existing sessions. |
| ListSessionsResponse | aclientp.schema.agent_responses | Response from listing sessions. |
| LoadSessionRequest | aclientp.schema.client_requests | Request parameters for loading an existing session. |
| LoadSessionResponse | aclientp.schema.agent_responses | Response from loading an existing session. |
| LogoutCapabilities | aclientp.schema.capabilities | Logout capabilities supported by the agent. |
| LogoutRequest | aclientp.schema.client_requests | Request parameters for the logout method. |
| LogoutResponse | aclientp.schema.agent_responses | Response to the logout method. |
| MessageMcpNotification | aclientp.schema.mcp | UNSTABLE: An inner MCP notification tied to an active inner MCP request. |
| MessageMcpRequest | aclientp.schema.mcp | UNSTABLE: An inner MCP request sent to an acp MCP server via mcp/message. |
| MessageMcpResponse | aclientp.schema.mcp | UNSTABLE: Response to mcp/message: exactly one inner MCP outcome. |
| MultiSelectPropertySchema | aclientp.schema.elicitation | Schema for multi-select (array) properties in an elicitation form. |
| NewSessionRequest | aclientp.schema.client_requests | Request parameters for creating a new session. |
| NewSessionResponse | aclientp.schema.agent_responses | Response from creating a new session. |
| NoOpClient | aclientp.client.implementations.noop_client | Minimal client that returns default responses for all operations. |
| NumberPropertySchema | aclientp.schema.elicitation | Schema for number (floating-point) properties in an elicitation form. |
| PermissionOption | aclientp.schema.tool_call | An option presented to the user when requesting permission. |
| PlanEntry | aclientp.schema.agent_plan | A single entry in the execution plan. |
| PromptRequest | aclientp.schema.client_requests | Request parameters for sending a user prompt to the agent. |
| PromptResponse | aclientp.schema.agent_responses | Response from processing a user prompt. |
| ProtocolVersionError | aclientp.exceptions | The peer answered initialize with a protocol version this side does not speak. |
| ReadTextFileRequest | aclientp.schema.agent_requests | Request to read content from a text file. |
| ReadTextFileResponse | aclientp.schema.client_responses | Response containing the contents of a text file. |
| ReleaseTerminalRequest | aclientp.schema.agent_requests | Request to release a terminal and free its resources. |
| ReleaseTerminalResponse | aclientp.schema.client_responses | Response to terminal/release method. |
| RequestError | aclientp.exceptions | Raised when a JSON-RPC request fails. |
| RequestPermissionRequest | aclientp.schema.agent_requests | Request for user permission to execute a tool call. |
| RequestPermissionResponse | aclientp.schema.client_responses | Response to a permission request. |
| ResumeSessionRequest | aclientp.schema.client_requests | Request parameters for resuming an existing session. |
| ResumeSessionResponse | aclientp.schema.agent_responses | Response from resuming an existing session. |
| SessionMode | aclientp.schema.session_state | A mode the agent can operate in. |
| SessionModeState | aclientp.schema.session_state | The set of modes and the one currently active. |
| SessionNotification | aclientp.schema.notifications | Notification containing a session update from the agent. |
| SessionOptionsRequest | aclientp.schema.client_requests | UNSTABLE: Request the modes and config options a session would start with. |
| SessionOptionsResponse | aclientp.schema.agent_responses | UNSTABLE: The modes and config options a session would start with. |
| SessionStatusRequest | aclientp.schema.client_requests | UNSTABLE: Request parameters for checking whether the Agent has a session in memory. |
| SessionStatusResponse | aclientp.schema.agent_responses | UNSTABLE: Response to session/status. |
| SetSessionConfigOptionRequest | aclientp.schema.client_requests | Request parameters for setting a session configuration option. |
| SetSessionConfigOptionResponse | aclientp.schema.agent_responses | Response to session/set_config_option method. |
| SetSessionModeRequest | aclientp.schema.client_requests | Request parameters for setting a session mode. |
| SetSessionModeResponse | aclientp.schema.agent_responses | Response to session/set_mode method. |
| SetSessionTitleRequest | aclientp.schema.client_requests | UNSTABLE: Request parameters for renaming a session. |
| SetSessionTitleResponse | aclientp.schema.agent_responses | UNSTABLE: Response to session/set_title. |
| SseMcpServer | aclientp.schema.mcp | SSE transport configuration. |
| StdioMcpServer | aclientp.schema.mcp | Stdio transport configuration. |
| StdioTransport | aclientp.transports | Configuration for stdio transport. |
| StreamTransport | aclientp.transports | Configuration for custom stream transport. |
| StringPropertySchema | aclientp.schema.elicitation | Schema for string properties in an elicitation form. |
| SystemPrompt | aclientp.schema.client_requests | Client-provided system-level instructions for a session. |
| TerminalHandle | aclientp.terminal_handle | Handle for a terminal session. |
| TerminalOutputRequest | aclientp.schema.agent_requests | Request to get the current output and status of a terminal. |
| TerminalOutputResponse | aclientp.schema.client_responses | Response containing the terminal output and exit status. |
| TextContentBlock | aclientp.schema.content_blocks | Text content. |
| TitledMultiSelectItems | aclientp.schema.elicitation | Items definition for titled multi-select enum properties. |
| ToolCallLocation | aclientp.schema.tool_call | A file location being accessed or modified by a tool. |
| ToolCallState | aclientp.tool_call_state | Tracks tool call state and sends delta updates. |
| ToolCallUpdate | aclientp.schema.tool_call | Details about the tool call requiring permission. |
| UnarchiveSessionRequest | aclientp.schema.client_requests | UNSTABLE: Request parameters for unarchiving a session. |
| UnarchiveSessionResponse | aclientp.schema.agent_responses | UNSTABLE: Response to session/unarchive. |
| UntitledMultiSelectItems | aclientp.schema.elicitation | Items definition for untitled multi-select enum properties. |
| UserMessageChunk | aclientp.schema.session_updates | A chunk of the user's message being streamed. |
| WaitForTerminalExitRequest | aclientp.schema.agent_requests | Request to wait for a terminal command to exit. |
| WaitForTerminalExitResponse | aclientp.schema.client_responses | Response containing the exit status of a terminal command. |
| WebSocketTransport | aclientp.transports | Configuration for WebSocket server transport. |
| WebSocketTransportError | aclientp.ws_transport | The WebSocket connection to the ACP server could not be opened. |
| WriteTextFileRequest | aclientp.schema.agent_requests | Request to write content to a text file. |
| WriteTextFileResponse | aclientp.schema.client_responses | Response to fs/write_text_file. |
🛈 DocStrings¶
Agent Client protocol (ACP) implementation.
AgentMethod
module-attribute
¶
AgentMethod = Literal[
"auth/status",
"authenticate",
"initialize",
"logout",
"mcp/message",
"providers/disable",
"providers/list",
"providers/set",
"session/archive",
"session/cancel",
"session/close",
"session/delete",
"session/fork",
"session/list",
"session/load",
"session/new",
"session/options",
"session/prompt",
"session/resume",
"session/set_config_option",
"session/set_mode",
"session/set_title",
"session/status",
"session/unarchive",
]
Methods handled by the agent.
AuthMethod
module-attribute
¶
AuthMethod = Annotated[
Annotated[AuthMethodAgent, Tag("agent")] | Annotated[AuthMethodTerminal, Tag("terminal")],
Discriminator(_auth_method_discriminator),
]
Describes an available authentication method.
The type field acts as the discriminator. When no type is present,
the method is treated as agent.
ClientMethod
module-attribute
¶
ClientMethod = Literal[
"auth/status_update",
"elicitation/complete",
"elicitation/create",
"fs/read_text_file",
"fs/write_text_file",
"mcp/message",
"session/request_permission",
"session/update",
"terminal/create",
"terminal/kill",
"terminal/output",
"terminal/release",
"terminal/wait_for_exit",
]
Methods handled by the client.
ElicitationContentValue
module-attribute
¶
Possible value types in elicitation content.
ElicitationPropertySchema
module-attribute
¶
ElicitationPropertySchema = Annotated[
Annotated[StringPropertySchema, Tag("string")]
| Annotated[NumberPropertySchema, Tag("number")]
| Annotated[IntegerPropertySchema, Tag("integer")]
| Annotated[BooleanPropertySchema, Tag("boolean")]
| Annotated[MultiSelectPropertySchema, Tag("array")],
Discriminator(_property_schema_discriminator),
]
Property schema for elicitation form fields.
Each variant corresponds to a JSON Schema "type" value.
MultiSelectItems
module-attribute
¶
MultiSelectItems = Annotated[
Annotated[UntitledMultiSelectItems, Tag("untitled")]
| Annotated[TitledMultiSelectItems, Tag("titled")],
Discriminator(_multi_select_items_discriminator),
]
Items for a multi-select (array) property schema.
Agent
¶
Bases: Protocol
Base agent interface for ACP.
Methods with a default body are optional and gated by a capability the agent
advertises. Their defaults reject the call with method not found.
Source code in src/aclientp/agent/protocol.py
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 92 93 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 | |
archive_session
async
¶
archive_session(params: ArchiveSessionRequest) -> ArchiveSessionResponse
auth_status
async
¶
auth_status(params: AuthStatusRequest) -> AuthStatusResponse
disable_provider
async
¶
disable_provider(params: DisableProviderRequest) -> DisableProviderResponse
list_providers
async
¶
list_providers(params: ListProvidersRequest) -> ListProvidersResponse
mcp_message
async
¶
mcp_message(params: MessageMcpRequest) -> MessageMcpResponse
UNSTABLE: Inner MCP request to an acp MCP server the agent declared.
mcp_notification
async
¶
mcp_notification(params: MessageMcpNotification) -> None
UNSTABLE: Inner MCP notification for an acp MCP server the agent declared.
session_options
async
¶
session_options(params: SessionOptionsRequest) -> SessionOptionsResponse
session_status
async
¶
session_status(params: SessionStatusRequest) -> SessionStatusResponse
set_provider
async
¶
set_provider(params: SetProviderRequest) -> SetProviderResponse
set_session_title
async
¶
set_session_title(params: SetSessionTitleRequest) -> SetSessionTitleResponse
unarchive_session
async
¶
unarchive_session(params: UnarchiveSessionRequest) -> UnarchiveSessionResponse
AgentAuthCapabilities
¶
Bases: AnnotatedObject
Authentication-related capabilities supported by the agent.
Source code in src/aclientp/schema/capabilities.py
logout
class-attribute
instance-attribute
¶
logout: LogoutCapabilities | None = None
Whether the agent supports the logout method.
status
class-attribute
instance-attribute
¶
status: AuthStatusCapabilities | None = None
UNSTABLE: Whether the agent supports auth/status.
AgentMessageChunk
¶
AgentSideConnection
¶
Bases: Client
Agent-side connection.
Use when you implement the Agent and need to talk to a Client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_agent
|
Callable[[AgentSideConnection], Agent] | Agent
|
factory that receives this connection and returns your Agent |
required |
input
|
ByteSendStream (local -> peer) |
required | |
output
|
ByteReceiveStream (peer -> local) |
required |
Source code in src/aclientp/agent/connection.py
91 92 93 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 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
__aenter__
async
¶
__aexit__
async
¶
__init__
¶
__init__(
to_agent: Callable[[AgentSideConnection], Agent] | Agent,
input_stream: ByteSendStream,
output_stream: ByteReceiveStream,
observers: list[StreamObserver] | None = None,
*,
debug_file: str | None = None,
) -> None
Initialize the agent-side connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_agent
|
Callable[[AgentSideConnection], Agent] | Agent
|
factory that receives this connection and returns your Agent |
required |
input_stream
|
ByteSendStream
|
ByteSendStream (local -> peer) |
required |
output_stream
|
ByteReceiveStream
|
ByteReceiveStream (peer -> local) |
required |
observers
|
list[StreamObserver] | None
|
list of StreamObserver instances to observe the connection |
None
|
debug_file
|
str | None
|
path to a file to write debug information to |
None
|
Source code in src/aclientp/agent/connection.py
auth_status_update
async
¶
auth_status_update(params: AuthStatusUpdateNotification) -> None
UNSTABLE: Notify the client that the authentication state changed.
Source code in src/aclientp/agent/connection.py
close
async
¶
create_terminal
async
¶
create_terminal(params: CreateTerminalRequest) -> CreateTerminalResponse
Create a terminal on the client.
Source code in src/aclientp/agent/connection.py
elicitation
async
¶
elicitation(params: ElicitationRequest) -> ElicitationResponse
Request structured user input from the client.
Source code in src/aclientp/agent/connection.py
elicitation_complete
async
¶
elicitation_complete(params: ElicitationCompleteNotification) -> None
Notify the client that a URL-based elicitation has completed.
Source code in src/aclientp/agent/connection.py
ext_method
async
¶
ext_notification
async
¶
kill_terminal
async
¶
kill_terminal(params: KillTerminalRequest) -> KillTerminalResponse
Kill a terminal on the client.
Source code in src/aclientp/agent/connection.py
mcp_message
async
¶
mcp_message(params: MessageMcpRequest) -> MessageMcpResponse
UNSTABLE: Send an inner MCP request to an acp MCP server the client declared.
Source code in src/aclientp/agent/connection.py
mcp_notification
async
¶
mcp_notification(params: MessageMcpNotification) -> None
UNSTABLE: Send an inner MCP notification over mcp/message.
Source code in src/aclientp/agent/connection.py
on_connection
classmethod
¶
on_connection(
connection: Connection, to_agent: Callable[[AgentSideConnection], Agent] | Agent
) -> tuple[AgentSideConnection, MethodHandler]
Serve v1 on an existing connection, returning the side and its handler.
Used by the version router (:mod:aclientp.router), which owns the connection
until initialize and then delegates incoming messages to the handler.
Source code in src/aclientp/agent/connection.py
read_text_file
async
¶
read_text_file(params: ReadTextFileRequest) -> ReadTextFileResponse
Read text file from the client.
Source code in src/aclientp/agent/connection.py
release_terminal
async
¶
release_terminal(params: ReleaseTerminalRequest) -> ReleaseTerminalResponse
Release a terminal on the client.
Source code in src/aclientp/agent/connection.py
request_permission
async
¶
request_permission(params: RequestPermissionRequest) -> RequestPermissionResponse
Request permission from the client.
Source code in src/aclientp/agent/connection.py
session_update
async
¶
session_update(params: SessionNotification) -> None
Send session update notification.
Source code in src/aclientp/agent/connection.py
terminal_output
async
¶
terminal_output(params: TerminalOutputRequest) -> TerminalOutputResponse
Show terminal output on the client.
Source code in src/aclientp/agent/connection.py
wait_closed
async
¶
wait_for_terminal_exit
async
¶
wait_for_terminal_exit(params: WaitForTerminalExitRequest) -> WaitForTerminalExitResponse
Wait for a terminal to exit on the client.
Source code in src/aclientp/agent/connection.py
write_text_file
async
¶
write_text_file(params: WriteTextFileRequest) -> WriteTextFileResponse
Write text file to the client.
Source code in src/aclientp/agent/connection.py
AllowedOutcome
¶
Bases: AnnotatedObject
The user selected one of the provided options.
Source code in src/aclientp/schema/tool_call.py
Annotations
¶
Bases: AnnotatedObject
Optional annotations for the client.
The client can use annotations to inform how objects are used or displayed.
Source code in src/aclientp/schema/content_blocks.py
audience
class-attribute
instance-attribute
¶
Audience for the annotated resource.
last_modified
class-attribute
instance-attribute
¶
Last modified timestamp of the annotated resource.
priority
class-attribute
instance-attribute
¶
Priority of the annotated resource.
optionally_create
classmethod
¶
optionally_create(
audience: Audience | None = None,
last_modified: datetime | str | None = None,
priority: float | None = None,
) -> Self | None
Create an annotations object if any value is given, otherwise return None.
Source code in src/aclientp/schema/content_blocks.py
ArchiveSessionRequest
¶
Bases: Request
UNSTABLE: Request parameters for archiving a session.
Only available if the Agent supports the session.archive capability.
Source code in src/aclientp/schema/client_requests.py
ArchiveSessionResponse
¶
AuthCapabilities
¶
Bases: AnnotatedObject
Authentication capabilities supported by the client.
Advertised during initialization to inform the agent which authentication method types the client can handle.
Source code in src/aclientp/schema/capabilities.py
terminal
class-attribute
instance-attribute
¶
Whether the client supports terminal authentication methods.
AuthMethodAgent
¶
Bases: AnnotatedObject
Agent handles authentication itself.
This is the default authentication method type.
When no type field is present, the method is treated as agent.
Source code in src/aclientp/schema/common.py
AuthMethodTerminal
¶
Bases: AnnotatedObject
Terminal authentication method.
Client runs the configured agent program as a separate interactive process for the user to authenticate.
Source code in src/aclientp/schema/common.py
args
class-attribute
instance-attribute
¶
Additional arguments to pass when running the agent binary for terminal auth.
description
class-attribute
instance-attribute
¶
Optional description providing more details about this authentication method.
env
class-attribute
instance-attribute
¶
Additional environment variables to set when running the agent binary for terminal auth.
type
class-attribute
instance-attribute
¶
Discriminator field.
AuthStatusRequest
¶
Bases: Request
UNSTABLE: Request the agent's current authentication state.
Only available if the Agent supports the auth.status capability.
Source code in src/aclientp/schema/client_requests.py
AuthStatusResponse
¶
Bases: Response
UNSTABLE: Response to auth/status.
Source code in src/aclientp/schema/agent_responses.py
accounts
class-attribute
instance-attribute
¶
accounts: Sequence[AuthAccount] = Field(default_factory=list)
The accounts the agent has configured, for display.
AuthStatusUpdateNotification
¶
Bases: AnnotatedObject
UNSTABLE: The agent's authentication state changed (auth/status_update).
Source code in src/aclientp/schema/notifications.py
accounts
class-attribute
instance-attribute
¶
accounts: Sequence[AuthAccount] = Field(default_factory=list)
The accounts the agent has configured, for display.
AuthenticateRequest
¶
Bases: Request
Request parameters for the authenticate method.
Specifies which authentication method to use.
Source code in src/aclientp/schema/client_requests.py
method_id
instance-attribute
¶
The ID of the authentication method to use.
Must be one of the methods advertised in the initialize response.
AuthenticateResponse
¶
AvailableCommand
¶
Bases: AnnotatedObject
Information about a command.
Source code in src/aclientp/schema/slash_commands.py
description
instance-attribute
¶
Human-readable description of what the command does.
input
class-attribute
instance-attribute
¶
input: AvailableCommandInput | None = None
Input for the command if required.
create
classmethod
¶
Create a new Command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the command. |
required |
description
|
str
|
Description of the command. |
required |
input_hint
|
str | None
|
Hint for the input. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
A new available command. |
Source code in src/aclientp/schema/slash_commands.py
BooleanPropertySchema
¶
Bases: AnnotatedObject
Schema for boolean properties in an elicitation form.
Source code in src/aclientp/schema/elicitation.py
CancelNotification
¶
Bases: AnnotatedObject
Notification to cancel ongoing operations for a session.
This is a notification sent by the client to cancel an ongoing prompt turn.
Upon receiving this notification, the Agent SHOULD:
- Stop all language model requests as soon as possible
- Abort all tool call invocations in progress
- Send any pending session/update notifications
- Respond to the original session/prompt request with StopReason::Cancelled
See protocol docs: Cancellation
Source code in src/aclientp/schema/notifications.py
CancelRequestNotification
¶
Bases: AnnotatedObject
Notification to cancel an ongoing request ($/cancel_request).
Either side may send it for a request it issued. The receiver should stop
the work and may reply with a -32800 (request cancelled) error or a normal
response. Unknown or already answered request IDs are ignored.
Source code in src/aclientp/schema/notifications.py
Client
¶
Bases: Protocol
Base client interface for ACP.
Methods with a default body are optional and gated by a capability the client
advertises (or by an acp MCP server the client declared).
Source code in src/aclientp/client/protocol.py
auth_status_update
async
¶
auth_status_update(params: AuthStatusUpdateNotification) -> None
mcp_message
async
¶
mcp_message(params: MessageMcpRequest) -> MessageMcpResponse
UNSTABLE: Inner MCP request to an acp MCP server the client declared.
mcp_notification
async
¶
mcp_notification(params: MessageMcpNotification) -> None
UNSTABLE: Inner MCP notification for an acp MCP server the client declared.
ClientCapabilities
¶
Bases: AnnotatedObject
Capabilities supported by the client.
Advertised during initialization to inform the agent about available features and methods.
See protocol docs: Client Capabilities
Source code in src/aclientp/schema/capabilities.py
auth
class-attribute
instance-attribute
¶
auth: AuthCapabilities | None = Field(default_factory=AuthCapabilities)
Authentication capabilities supported by the client.
elicitation
class-attribute
instance-attribute
¶
elicitation: ElicitationCapabilities | None = None
Elicitation capabilities supported by the client.
Determines which elicitation modes the agent may use.
fs
class-attribute
instance-attribute
¶
fs: FileSystemCapabilities | None = Field(default_factory=FileSystemCapabilities)
File system capabilities supported by the client.
Determines which file operations the agent can request.
plan
class-attribute
instance-attribute
¶
plan: PlanCapabilities | None = None
UNSTABLE: Client support for ID-addressed plan updates.
session
class-attribute
instance-attribute
¶
session: ClientSessionCapabilities | None = None
Session-related capabilities supported by the client.
subagents
class-attribute
instance-attribute
¶
subagents: SubagentCapabilities | None = None
UNSTABLE: Client support for subagent_update session updates.
terminal
class-attribute
instance-attribute
¶
Whether the Client support all terminal/* methods.
create
classmethod
¶
create(
read_text_file: bool | None = False,
write_text_file: bool | None = False,
terminal: bool | None = False,
auth: AuthCapabilities | None = None,
) -> Self
Create a new instance of ClientCapabilities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
read_text_file
|
bool | None
|
Whether the Client supports |
False
|
write_text_file
|
bool | None
|
Whether the Client supports |
False
|
terminal
|
bool | None
|
Whether the Client supports all |
False
|
auth
|
AuthCapabilities | None
|
Authentication capabilities supported by the client. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
A new instance of ClientCapabilities. |
Source code in src/aclientp/schema/capabilities.py
ClientSideConnection
¶
Bases: Agent
Client-side connection.
Use when you implement the Client and need to talk to an Agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_client
|
Callable[[Agent], Client] | Client
|
factory that receives this connection and returns your Client |
required |
input
|
ByteSendStream (local -> peer) |
required | |
output
|
ByteReceiveStream (peer -> local) |
required |
Source code in src/aclientp/client/connection.py
92 93 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 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
wait_closed
async
¶
CloseSessionRequest
¶
Bases: Request
Request parameters for closing an active session.
The agent must cancel any ongoing work related to the session
(treat it as if session/cancel was called) and then free up any resources
associated with the session.
Only available if the Agent supports the session.close capability.
Source code in src/aclientp/schema/client_requests.py
CloseSessionResponse
¶
CreateTerminalRequest
¶
Bases: BaseAgentRequest
Request to create a new terminal and execute a command.
Source code in src/aclientp/schema/agent_requests.py
args
class-attribute
instance-attribute
¶
Array of command arguments.
cwd
class-attribute
instance-attribute
¶
Working directory for the command (absolute path).
env
class-attribute
instance-attribute
¶
env: Sequence[EnvVariable] | None = None
Environment variables for the command.
output_byte_limit
class-attribute
instance-attribute
¶
Maximum number of output bytes to retain.
When the limit is exceeded, the Client truncates from the beginning of the output to stay within the limit.
The Client MUST ensure truncation happens at a character boundary to maintain valid string output, even if this means the retained output is slightly less than the specified limit.
CreateTerminalResponse
¶
Bases: Response
Response containing the ID of the created terminal.
Source code in src/aclientp/schema/client_responses.py
DefaultACPClient
¶
Bases: Client
Default implementation of ACP Client interface for basic operations.
This provides a basic client implementation that can be used for testing or as a base for more sophisticated client implementations.
Source code in src/aclientp/client/implementations/default_client.py
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 92 93 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 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
__init__
¶
__init__(
*,
allow_file_operations: bool = False,
permission_outcomes: list[dict[str, DeniedOutcome | AllowedOutcome]] | None = None,
use_real_files: bool = True,
) -> None
Initialize default ACP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
allow_file_operations
|
bool
|
Whether to allow file read/write operations |
False
|
permission_outcomes
|
list[dict[str, DeniedOutcome | AllowedOutcome]] | None
|
Queue of permission outcomes for testing |
None
|
use_real_files
|
bool
|
Whether to use real filesystem or in-memory storage |
True
|
Source code in src/aclientp/client/implementations/default_client.py
clear_session_updates
¶
create_terminal
async
¶
create_terminal(params: CreateTerminalRequest) -> CreateTerminalResponse
Create terminal (not implemented).
elicitation
async
¶
elicitation(params: ElicitationRequest) -> ElicitationResponse
Decline elicitation by default.
Source code in src/aclientp/client/implementations/default_client.py
elicitation_complete
async
¶
elicitation_complete(params: ElicitationCompleteNotification) -> None
get_session_updates
¶
get_session_updates() -> list[SessionNotification]
kill_terminal
async
¶
kill_terminal(params: KillTerminalRequest) -> KillTerminalResponse | None
Kill terminal (not implemented).
read_text_file
async
¶
read_text_file(params: ReadTextFileRequest) -> ReadTextFileResponse
Read text from file (if allowed).
Source code in src/aclientp/client/implementations/default_client.py
release_terminal
async
¶
release_terminal(params: ReleaseTerminalRequest) -> ReleaseTerminalResponse | None
Release terminal (not implemented).
request_permission
async
¶
request_permission(params: RequestPermissionRequest) -> RequestPermissionResponse
Default permission handler - grants all permissions or uses test queue.
Source code in src/aclientp/client/implementations/default_client.py
session_update
async
¶
session_update(params: SessionNotification) -> None
Handle session update notifications.
Source code in src/aclientp/client/implementations/default_client.py
terminal_output
async
¶
terminal_output(params: TerminalOutputRequest) -> TerminalOutputResponse
Get terminal output (not implemented).
wait_for_terminal_exit
async
¶
wait_for_terminal_exit(params: WaitForTerminalExitRequest) -> WaitForTerminalExitResponse
Wait for terminal exit (not implemented).
Source code in src/aclientp/client/implementations/default_client.py
write_text_file
async
¶
write_text_file(params: WriteTextFileRequest) -> WriteTextFileResponse
Write text to file (if allowed).
Source code in src/aclientp/client/implementations/default_client.py
DeleteSessionRequest
¶
Bases: Request
Request parameters for deleting a session from session/list.
Only available if the Agent supports the session.delete capability.
Source code in src/aclientp/schema/client_requests.py
DeleteSessionResponse
¶
DeniedOutcome
¶
Bases: Schema
The prompt turn was cancelled before the user responded.
When a client sends a session/cancel notification to cancel an ongoing
prompt turn, it MUST respond to all pending session/request_permission
requests with this Cancelled outcome.
See protocol docs: Cancellation
Source code in src/aclientp/schema/tool_call.py
ElicitationCapabilities
¶
Bases: AnnotatedObject
Elicitation capabilities supported by the client.
Source code in src/aclientp/schema/elicitation.py
form
class-attribute
instance-attribute
¶
form: ElicitationFormCapabilities | None = None
Whether the client supports form-based elicitation.
url
class-attribute
instance-attribute
¶
url: ElicitationUrlCapabilities | None = None
Whether the client supports URL-based elicitation.
ElicitationCompleteNotification
¶
Bases: AnnotatedObject
Notification sent by the agent when a URL-based elicitation is complete.
Source code in src/aclientp/schema/elicitation.py
ElicitationFormCapabilities
¶
Bases: AnnotatedObject
Form-based elicitation capabilities.
Source code in src/aclientp/schema/elicitation.py
ElicitationRequest
¶
Bases: Request
Request from the agent to elicit structured user input (elicitation/create).
The agent sends this to the client to request information from the user, either via a form or by directing them to a URL.
Mode and scope fields are flattened into the request on the wire:
mode: "form"carriesrequested_schema.mode: "url"carrieselicitation_idandurl.- Session scope sets
session_id(and optionallytool_call_id), request scope setsrequest_id(e.g. during auth before any session exists).
Source code in src/aclientp/schema/elicitation.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
elicitation_id
class-attribute
instance-attribute
¶
URL mode: the unique identifier for this elicitation.
request_id
class-attribute
instance-attribute
¶
Request scope: the JSON-RPC request this elicitation is tied to.
requested_schema
class-attribute
instance-attribute
¶
requested_schema: ElicitationSchema | None = None
Form mode: a JSON Schema describing the form fields to present to the user.
session_id
class-attribute
instance-attribute
¶
Session scope: the session this elicitation is tied to.
tool_call_id
class-attribute
instance-attribute
¶
Session scope: optional tool call within the session.
url
class-attribute
instance-attribute
¶
URL mode: the URL to direct the user to.
form
classmethod
¶
form(
message: str,
schema: ElicitationSchema,
*,
session_id: str | None = None,
tool_call_id: str | None = None,
request_id: int | str | None = None,
) -> Self
Create a form-based elicitation request.
Source code in src/aclientp/schema/elicitation.py
url_based
classmethod
¶
url_based(
message: str,
elicitation_id: str,
url: str,
*,
session_id: str | None = None,
tool_call_id: str | None = None,
request_id: int | str | None = None,
) -> Self
Create a URL-based elicitation request.
Source code in src/aclientp/schema/elicitation.py
ElicitationResponse
¶
Bases: Response
Response from the client to an elicitation request.
Source code in src/aclientp/schema/elicitation.py
content
class-attribute
instance-attribute
¶
content: dict[str, ElicitationContentValue] | None = None
For accept: the user-provided content, as an object matching the requested schema.
ElicitationSchema
¶
Bases: AnnotatedObject
Type-safe elicitation schema for requesting structured user input.
This represents a JSON Schema object with primitive-typed properties, as required by the elicitation specification.
Source code in src/aclientp/schema/elicitation.py
description
class-attribute
instance-attribute
¶
Optional description of what this schema represents.
properties
class-attribute
instance-attribute
¶
properties: dict[str, ElicitationPropertySchema] = Field(default_factory=dict)
Property definitions (must be primitive types).
required
class-attribute
instance-attribute
¶
List of required property names.
type
class-attribute
instance-attribute
¶
Type discriminator. Always "object".
ElicitationUrlCapabilities
¶
Bases: AnnotatedObject
URL-based elicitation capabilities.
Source code in src/aclientp/schema/elicitation.py
EnumOption
¶
Bases: AnnotatedObject
A titled enum option with a const value, human-readable title and optional description.
Source code in src/aclientp/schema/elicitation.py
EnvVariable
¶
Bases: AnnotatedObject
An environment variable to set when launching an MCP server.
Source code in src/aclientp/schema/common.py
FileSystemCapabilities
¶
Bases: AnnotatedObject
File system capabilities that a client may support.
See protocol docs: FileSystem
Source code in src/aclientp/schema/capabilities.py
ForkSessionRequest
¶
Bases: SessionSetupRequest
UNSTABLE: Request parameters for forking an existing session.
Creates a new, active session based on the context of an existing one.
Only available if the Agent supports the session.fork capability.
Source code in src/aclientp/schema/client_requests.py
cursor_id
class-attribute
instance-attribute
¶
UNSTABLE: Fork at this session cursor instead of the end of the session.
The new session's history is the source history before the cursor. Only IDs of
cursors announced on the source session that currently advertise
capabilities.fork are valid; Agents reject others with -32602.
ForkSessionResponse
¶
Bases: Response
UNSTABLE: Response from forking an existing session.
Source code in src/aclientp/schema/agent_responses.py
config_options
class-attribute
instance-attribute
¶
config_options: Sequence[SessionConfigOption] | None = None
The full list of config options with updated values.
modes
class-attribute
instance-attribute
¶
modes: SessionModeState | None = None
Initial mode state if supported by the Agent
See protocol docs: Session Modes
session_id
instance-attribute
¶
Unique identifier for the newly created forked session.
create
classmethod
¶
create(
session_id: str,
config_options: Sequence[SessionConfigOption] | None = None,
modes: Sequence[SessionMode] | None = None,
current_mode: str | None = None,
) -> Self
Create a response with the given session ID and config options.
Source code in src/aclientp/schema/agent_responses.py
HeadlessACPClient
¶
Bases: Client
Headless ACP client with real filesystem and terminal operations.
This client implementation: - Performs real filesystem operations - Uses ProcessManager for actual terminal/command execution - Automatically grants permissions for testing - Suitable for testing and standalone usage
Source code in src/aclientp/client/implementations/headless_client.py
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 92 93 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 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
__init__
¶
__init__(
*,
working_dir: Path | str | None = None,
allow_file_operations: bool = True,
auto_grant_permissions: bool = True,
) -> None
Initialize headless ACP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
working_dir
|
Path | str | None
|
Default working directory for operations |
None
|
allow_file_operations
|
bool
|
Whether to allow file read/write operations |
True
|
auto_grant_permissions
|
bool
|
Whether to automatically grant all permissions |
True
|
Source code in src/aclientp/client/implementations/headless_client.py
cleanup
async
¶
Clean up all resources.
Source code in src/aclientp/client/implementations/headless_client.py
clear_permission_requests
¶
clear_session_updates
¶
create_terminal
async
¶
create_terminal(params: CreateTerminalRequest) -> CreateTerminalResponse
Create a new terminal session using ProcessManager.
Source code in src/aclientp/client/implementations/headless_client.py
elicitation
async
¶
elicitation(params: ElicitationRequest) -> ElicitationResponse
Decline elicitation by default.
Source code in src/aclientp/client/implementations/headless_client.py
elicitation_complete
async
¶
elicitation_complete(params: ElicitationCompleteNotification) -> None
ext_method
async
¶
Handle extension method calls.
Source code in src/aclientp/client/implementations/headless_client.py
ext_notification
async
¶
get_permission_requests
¶
get_permission_requests() -> list[RequestPermissionRequest]
get_session_updates
¶
get_session_updates() -> list[SessionNotification]
kill_terminal
async
¶
kill_terminal(params: KillTerminalRequest) -> KillTerminalResponse | None
Kill terminal process.
Source code in src/aclientp/client/implementations/headless_client.py
list_active_terminals
¶
read_text_file
async
¶
read_text_file(params: ReadTextFileRequest) -> ReadTextFileResponse
Read text from file.
Source code in src/aclientp/client/implementations/headless_client.py
release_terminal
async
¶
release_terminal(params: ReleaseTerminalRequest) -> ReleaseTerminalResponse | None
Release terminal resources.
Source code in src/aclientp/client/implementations/headless_client.py
request_permission
async
¶
request_permission(params: RequestPermissionRequest) -> RequestPermissionResponse
Handle permission requests. Grants if auto_grant_permissions is True.
Source code in src/aclientp/client/implementations/headless_client.py
session_update
async
¶
session_update(params: SessionNotification) -> None
Handle session update notifications.
Source code in src/aclientp/client/implementations/headless_client.py
terminal_output
async
¶
terminal_output(params: TerminalOutputRequest) -> TerminalOutputResponse
Get output from terminal.
Source code in src/aclientp/client/implementations/headless_client.py
wait_for_terminal_exit
async
¶
wait_for_terminal_exit(params: WaitForTerminalExitRequest) -> WaitForTerminalExitResponse
Wait for terminal process to exit.
Source code in src/aclientp/client/implementations/headless_client.py
write_text_file
async
¶
write_text_file(params: WriteTextFileRequest) -> WriteTextFileResponse
Write text to file.
Source code in src/aclientp/client/implementations/headless_client.py
HttpMcpServer
¶
Bases: BaseMcpServer
HTTP transport configuration.
Only available when the Agent capabilities indicate mcp_capabilities.http is true.
Source code in src/aclientp/schema/mcp.py
headers
class-attribute
instance-attribute
¶
headers: Sequence[HttpHeader] = Field(default_factory=list)
HTTP headers to set when making requests to the MCP server.
type
class-attribute
instance-attribute
¶
HTTP transport type.
HttpTransport
dataclass
¶
Configuration for the Streamable HTTP & WebSocket server transport (experimental).
Serves ACP on one endpoint per the transport RFD: Streamable HTTP (POST/GET/DELETE)
and WebSocket upgrade. Each client connection gets its own agent instance. Requires
the bridge extra (starlette, uvicorn).
Attributes:
| Name | Type | Description |
|---|---|---|
host |
str
|
Host to bind to. |
port |
int
|
Port to listen on. |
path |
str
|
Endpoint path. |
authenticate |
Authenticate | None
|
Identifies callers (None rejects with 401); connections belong to their creator. None accepts every caller, for local use only. |
allow_origins |
list[str]
|
CORS origins for browser clients. |
max_buffered_bytes |
int
|
Output a connection may hold for its client before the agent's writes wait. |
max_output_stall |
float
|
Seconds a client may take no output while over that limit before its connection is closed. |
Source code in src/aclientp/transports.py
HttpTransportError
¶
Implementation
¶
Bases: AnnotatedObject
Describes the name and version of an ACP implementation.
Includes an optional title for UI representation.
Source code in src/aclientp/schema/common.py
name
instance-attribute
¶
Intended for programmatic or logical use.
Can be used as a display name fallback if title isn't present.
title
class-attribute
instance-attribute
¶
Intended for UI and end-user contexts.
Optimized to be human-readable and easily understood. If not provided, the name should be used for display.
version
instance-attribute
¶
Version of the implementation.
Can be displayed to the user or used for debugging or metrics purposes.
InitializeRequest
¶
Bases: Request
Request parameters for the initialize method.
Sent by the client to establish connection and negotiate capabilities.
See protocol docs: Initialization
Source code in src/aclientp/schema/client_requests.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
client_capabilities
class-attribute
instance-attribute
¶
client_capabilities: ClientCapabilities | None = Field(default_factory=ClientCapabilities)
Capabilities supported by the client.
client_info
class-attribute
instance-attribute
¶
client_info: Implementation | None = None
Information about the Client name and version sent to the Agent.
Note: in future versions of the protocol, this will be required.
protocol_version
instance-attribute
¶
The latest protocol version supported by the client.
create
classmethod
¶
create(
title: str,
name: str,
version: str,
terminal: bool = True,
read_text_file: bool = True,
write_text_file: bool = True,
protocol_version: int = 1,
terminal_auth: bool = False,
prompt_suggestions: bool = False,
compaction: bool = False,
notices: bool = False,
metadata: dict[str, Any] | None = None,
) -> Self
Create a new InitializeRequest instance.
Source code in src/aclientp/schema/client_requests.py
create_for_package
classmethod
¶
create_for_package(
package_name: str,
allow_terminal: bool = True,
allow_file_operations: bool = True,
terminal_auth: bool = False,
prompt_suggestions: bool = False,
compaction: bool = False,
notices: bool = False,
metadata: dict[str, Any] | None = None,
) -> InitializeRequest
Create ACP initialize request for app with given name (based on pkg metadata).
Source code in src/aclientp/schema/client_requests.py
InitializeResponse
¶
Bases: Response
Response from the initialize method.
Contains the negotiated protocol version and agent capabilities.
See protocol docs: Initialization
Source code in src/aclientp/schema/agent_responses.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
agent_capabilities
class-attribute
instance-attribute
¶
agent_capabilities: AgentCapabilities | None = Field(default_factory=AgentCapabilities)
Capabilities supported by the agent.
agent_info
class-attribute
instance-attribute
¶
agent_info: Implementation | None = None
Information about the Agent name and version sent to the Client.
Note: in future versions of the protocol, this will be required.
auth_methods
class-attribute
instance-attribute
¶
auth_methods: Sequence[AuthMethod] | None = Field(default_factory=list)
Authentication methods supported by the agent.
protocol_version
class-attribute
instance-attribute
¶
The protocol version the client specified if supported by the agent.
Or the latest protocol version supported by the agent. The client should disconnect, if it doesn't support this version.
create
classmethod
¶
create(
name: str,
title: str,
version: str,
protocol_version: int,
load_session: bool | None = False,
http_mcp_servers: bool = False,
sse_mcp_servers: bool = False,
audio_prompts: bool = False,
embedded_context_prompts: bool = False,
image_prompts: bool = False,
list_sessions: bool = False,
resume_session: bool = False,
close_session: bool = False,
auth_methods: Sequence[AuthMethod] | None = None,
) -> Self
Create an instance of AgentCapabilities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the agent. |
required |
title
|
str
|
The title of the agent. |
required |
version
|
str
|
The version of the agent. |
required |
protocol_version
|
int
|
The protocol version of the agent. |
required |
load_session
|
bool | None
|
Whether the agent supports |
False
|
http_mcp_servers
|
bool
|
Whether the agent supports HTTP MCP servers. |
False
|
sse_mcp_servers
|
bool
|
Whether the agent supports SSE MCP servers. |
False
|
audio_prompts
|
bool
|
Whether the agent supports audio prompts. |
False
|
embedded_context_prompts
|
bool
|
Whether the agent supports embedded context prompts. |
False
|
image_prompts
|
bool
|
Whether the agent supports image prompts. |
False
|
list_sessions
|
bool
|
Whether the agent supports |
False
|
resume_session
|
bool
|
Whether the agent supports |
False
|
close_session
|
bool
|
Whether the agent supports |
False
|
auth_methods
|
Sequence[AuthMethod] | None
|
The authentication methods supported by the agent. |
None
|
Source code in src/aclientp/schema/agent_responses.py
IntegerPropertySchema
¶
Bases: AnnotatedObject
Schema for integer properties in an elicitation form.
Source code in src/aclientp/schema/elicitation.py
KillTerminalRequest
¶
Bases: BaseAgentRequest
Request to kill a terminal command without releasing the terminal.
Source code in src/aclientp/schema/agent_requests.py
KillTerminalResponse
¶
ListSessionsRequest
¶
Bases: Request
Request parameters for listing existing sessions.
Only available if the Agent supports the session.list capability.
Source code in src/aclientp/schema/client_requests.py
archived
class-attribute
instance-attribute
¶
archived: SessionArchiveFilter | None = None
UNSTABLE: Which sessions to return by archive state. Defaults to exclude.
cursor
class-attribute
instance-attribute
¶
Opaque cursor token from a previous response's nextCursor field for pagination.
cwd
class-attribute
instance-attribute
¶
Filter sessions by working directory. Must be an absolute path.
ListSessionsResponse
¶
Bases: Response
Response from listing sessions.
Source code in src/aclientp/schema/agent_responses.py
next_cursor
class-attribute
instance-attribute
¶
Opaque cursor token. If present, pass this in the next request's cursor parameter to fetch the next page. If absent, there are no more results.
sessions
class-attribute
instance-attribute
¶
sessions: Sequence[SessionInfo] = Field(default_factory=list)
Array of session information objects.
LoadSessionRequest
¶
Bases: SessionSetupRequest
Request parameters for loading an existing session.
Only available if the Agent supports the loadSession capability.
See protocol docs: Loading Sessions
Source code in src/aclientp/schema/client_requests.py
LoadSessionResponse
¶
Bases: Response
Response from loading an existing session.
Source code in src/aclientp/schema/agent_responses.py
config_options
class-attribute
instance-attribute
¶
config_options: Sequence[SessionConfigOption] | None = None
The full list of config options with updated values.
modes
class-attribute
instance-attribute
¶
modes: SessionModeState | None = None
Initial mode state if supported by the Agent
See protocol docs: Session Modes
LogoutCapabilities
¶
Bases: AnnotatedObject
Logout capabilities supported by the agent.
By supplying {} it means that the agent supports the logout method.
Source code in src/aclientp/schema/capabilities.py
LogoutRequest
¶
Bases: Request
Request parameters for the logout method.
Terminates the current authenticated session.
After a successful logout, all new sessions will require authentication. There is no guarantee about the behavior of already running sessions.
Source code in src/aclientp/schema/client_requests.py
LogoutResponse
¶
MessageMcpNotification
¶
Bases: AnnotatedObject
UNSTABLE: An inner MCP notification tied to an active inner MCP request.
Source code in src/aclientp/schema/mcp.py
params
class-attribute
instance-attribute
¶
Optional inner MCP params.
request_id
instance-attribute
¶
request_id: McpRequestId
The identifier of the active inner MCP request.
server_id
instance-attribute
¶
server_id: McpServerAcpId
The declared ACP MCP server handling the associated request.
MessageMcpRequest
¶
Bases: Request
UNSTABLE: An inner MCP request sent to an acp MCP server via mcp/message.
Either side may send it, to the side that declared the server.
Source code in src/aclientp/schema/mcp.py
params
class-attribute
instance-attribute
¶
Optional inner MCP params.
request_id
instance-attribute
¶
request_id: McpRequestId
The caller-generated identifier for the inner MCP request.
server_id
instance-attribute
¶
server_id: McpServerAcpId
The declared ACP MCP server receiving this request.
MessageMcpResponse
¶
Bases: Response
UNSTABLE: Response to mcp/message: exactly one inner MCP outcome.
Either an opaque result (which may be JSON null) or an error.
Receivers prefer result if both are present.
Source code in src/aclientp/schema/mcp.py
MultiSelectPropertySchema
¶
Bases: AnnotatedObject
Schema for multi-select (array) properties in an elicitation form.
Source code in src/aclientp/schema/elicitation.py
default
class-attribute
instance-attribute
¶
Default selected values.
description
class-attribute
instance-attribute
¶
Human-readable description.
max_items
class-attribute
instance-attribute
¶
Maximum number of items to select.
min_items
class-attribute
instance-attribute
¶
Minimum number of items to select.
title
class-attribute
instance-attribute
¶
Optional title for the property.
NewSessionRequest
¶
Bases: SessionSetupRequest
Request parameters for creating a new session.
See protocol docs: Creating a Session
Source code in src/aclientp/schema/client_requests.py
NewSessionResponse
¶
Bases: Response
Response from creating a new session.
See protocol docs: Creating a Session
Source code in src/aclientp/schema/agent_responses.py
config_options
class-attribute
instance-attribute
¶
config_options: Sequence[SessionConfigOption] | None = None
**Configuration options for this session.
modes
class-attribute
instance-attribute
¶
modes: SessionModeState | None = None
Initial mode state if supported by the Agent
See protocol docs: Session Modes
session_id
instance-attribute
¶
Unique identifier for the created session.
Used in all subsequent requests for this conversation.
NoOpClient
¶
Bases: Client
Minimal client that returns default responses for all operations.
This client is useful for bridging scenarios where you need a Client implementation but don't actually need to handle client-side operations. All methods return minimal valid responses.
Source code in src/aclientp/client/implementations/noop_client.py
create_terminal
async
¶
create_terminal(params: CreateTerminalRequest) -> CreateTerminalResponse
Return dummy terminal ID.
Source code in src/aclientp/client/implementations/noop_client.py
elicitation
async
¶
elicitation(params: ElicitationRequest) -> ElicitationResponse
Decline elicitation by default.
elicitation_complete
async
¶
elicitation_complete(params: ElicitationCompleteNotification) -> None
ext_method
async
¶
ext_notification
async
¶
kill_terminal
async
¶
kill_terminal(params: KillTerminalRequest) -> KillTerminalResponse | None
Return empty kill response.
read_text_file
async
¶
read_text_file(params: ReadTextFileRequest) -> ReadTextFileResponse
Return empty file content.
release_terminal
async
¶
release_terminal(params: ReleaseTerminalRequest) -> ReleaseTerminalResponse | None
Return empty release response.
Source code in src/aclientp/client/implementations/noop_client.py
request_permission
async
¶
request_permission(params: RequestPermissionRequest) -> RequestPermissionResponse
Grant permission using first available option.
Source code in src/aclientp/client/implementations/noop_client.py
session_update
async
¶
session_update(params: SessionNotification) -> None
terminal_output
async
¶
terminal_output(params: TerminalOutputRequest) -> TerminalOutputResponse
Return empty terminal output.
Source code in src/aclientp/client/implementations/noop_client.py
wait_for_terminal_exit
async
¶
wait_for_terminal_exit(params: WaitForTerminalExitRequest) -> WaitForTerminalExitResponse
Return immediate exit with code 0.
Source code in src/aclientp/client/implementations/noop_client.py
write_text_file
async
¶
write_text_file(params: WriteTextFileRequest) -> WriteTextFileResponse
Return empty write response.
NumberPropertySchema
¶
Bases: AnnotatedObject
Schema for number (floating-point) properties in an elicitation form.
Source code in src/aclientp/schema/elicitation.py
PermissionOption
¶
Bases: AnnotatedObject
An option presented to the user when requesting permission.
Source code in src/aclientp/schema/tool_call.py
PlanEntry
¶
Bases: AnnotatedObject
A single entry in the execution plan.
Represents a task or goal that the assistant intends to accomplish as part of fulfilling the user's request. See protocol docs: Plan Entries
Source code in src/aclientp/schema/agent_plan.py
PromptRequest
¶
Bases: Request
Request parameters for sending a user prompt to the agent.
Contains the user's message and any additional context.
See protocol docs: User Message
Source code in src/aclientp/schema/client_requests.py
prompt
instance-attribute
¶
The blocks of content that compose the user's message.
As a baseline, the Agent MUST support [ContentBlock::Text] and
[ContentBlock::ResourceContentBlock],
while other variants are optionally enabled via [PromptCapabilities].
The Client MUST adapt its interface according to [PromptCapabilities].
The client MAY include referenced pieces of context as either
[ContentBlock::Resource] or [ContentBlock::ResourceContentBlock].
When available, [ContentBlock::Resource] is preferred
as it avoids extra round-trips and allows the message to include
pieces of context from sources the agent may not have access to.
PromptResponse
¶
Bases: Response
Response from processing a user prompt.
See protocol docs: Check for Completion
Source code in src/aclientp/schema/agent_responses.py
ProtocolVersionError
¶
Bases: RequestError
The peer answered initialize with a protocol version this side does not speak.
Raised by clients before the rest of the response is validated, so an agent that only speaks another version (e.g. a v1 agent answering a v2 client) is reported as such instead of as a malformed response.
Source code in src/aclientp/exceptions.py
ReadTextFileRequest
¶
Bases: BaseAgentRequest
Request to read content from a text file.
Only available if the client supports the fs.readTextFile capability.
Source code in src/aclientp/schema/agent_requests.py
ReadTextFileResponse
¶
Bases: Response
Response containing the contents of a text file.
Source code in src/aclientp/schema/client_responses.py
ReleaseTerminalRequest
¶
Bases: BaseAgentRequest
Request to release a terminal and free its resources.
Source code in src/aclientp/schema/agent_requests.py
ReleaseTerminalResponse
¶
RequestError
¶
Bases: Exception
Raised when a JSON-RPC request fails.
Source code in src/aclientp/exceptions.py
from_error_obj
classmethod
¶
Build an error from a peer's JSON-RPC error object.
Peers are not trusted to send a well-formed object: data is optional per
JSON-RPC 2.0 and code / message may be missing or have the wrong type.
Source code in src/aclientp/exceptions.py
session_not_found
classmethod
¶
-32002 for a request naming a session that does not exist or is not active.
unsupported_protocol_version
classmethod
¶
-32022: no supported protocol version is at or below the requested one.
Source code in src/aclientp/exceptions.py
RequestPermissionRequest
¶
Bases: BaseAgentRequest
Request for user permission to execute a tool call.
Sent when the agent needs authorization before performing a sensitive operation.
See protocol docs: Requesting Permission
Source code in src/aclientp/schema/agent_requests.py
options
instance-attribute
¶
options: Sequence[PermissionOption]
Available permission options for the user to choose from.
tool_call
instance-attribute
¶
tool_call: ToolCallUpdate
Details about the tool call requiring permission.
RequestPermissionResponse
¶
Bases: Response
Response to a permission request.
Source code in src/aclientp/schema/client_responses.py
outcome
instance-attribute
¶
outcome: RequestPermissionOutcome
The user's decision on the permission request.
allowed
classmethod
¶
Create a response indicating that the permission request was allowed.
Source code in src/aclientp/schema/client_responses.py
denied
classmethod
¶
Create a response indicating that the permission request was denied.
ResumeSessionRequest
¶
Bases: SessionSetupRequest
Request parameters for resuming an existing session.
Resumes an existing session without returning previous messages (unlike session/load).
mcp_servers is the complete client-provided set.
Only available if the Agent supports the session.resume capability.
Source code in src/aclientp/schema/client_requests.py
ResumeSessionResponse
¶
Bases: Response
Response from resuming an existing session.
Source code in src/aclientp/schema/agent_responses.py
config_options
class-attribute
instance-attribute
¶
config_options: Sequence[SessionConfigOption] | None = None
The full list of config options with updated values.
modes
class-attribute
instance-attribute
¶
modes: SessionModeState | None = None
Initial mode state if supported by the Agent
See protocol docs: Session Modes
create
classmethod
¶
create(
config_options: Sequence[SessionConfigOption] | None = None,
modes: Sequence[SessionMode] | None = None,
current_mode: str | None = None,
) -> Self
Create a response with the given config options and modes.
Source code in src/aclientp/schema/agent_responses.py
SessionMode
¶
Bases: AnnotatedObject
A mode the agent can operate in.
See protocol docs: Session Modes
Source code in src/aclientp/schema/session_state.py
SessionModeState
¶
Bases: AnnotatedObject
The set of modes and the one currently active.
Source code in src/aclientp/schema/session_state.py
available_modes
instance-attribute
¶
available_modes: Sequence[SessionMode]
The set of modes that the Agent can operate in.
SessionNotification
¶
Bases: AnnotatedObject
Notification containing a session update from the agent.
Used to stream real-time progress and results during prompt processing.
See protocol docs: Agent Reports Output
Source code in src/aclientp/schema/notifications.py
SessionOptionsRequest
¶
Bases: Request
UNSTABLE: Request the modes and config options a session would start with.
Only available if the Agent supports the session.options capability.
Source code in src/aclientp/schema/client_requests.py
additional_directories
class-attribute
instance-attribute
¶
Additional workspace roots to resolve options for. Each path must be absolute.
cwd
instance-attribute
¶
The working directory to resolve options for. Must be an absolute path.
session_id
class-attribute
instance-attribute
¶
The session to resolve options for.
SessionOptionsResponse
¶
Bases: Response
UNSTABLE: The modes and config options a session would start with.
Source code in src/aclientp/schema/agent_responses.py
config_options
class-attribute
instance-attribute
¶
config_options: Sequence[SessionConfigOption] | None = None
The config options the session would start with.
modes
class-attribute
instance-attribute
¶
modes: SessionModeState | None = None
The mode state the session would start with, if the Agent supports modes.
SessionStatusRequest
¶
Bases: Request
UNSTABLE: Request parameters for checking whether the Agent has a session in memory.
Only available if the Agent supports the session.status capability.
Source code in src/aclientp/schema/client_requests.py
SessionStatusResponse
¶
Bases: Response
UNSTABLE: Response to session/status.
Source code in src/aclientp/schema/agent_responses.py
SetSessionConfigOptionRequest
¶
Bases: Request
Request parameters for setting a session configuration option.
Supports both select (string value ID) and boolean config options.
When type is "boolean", value is a bool.
When type is absent or "value_id", value is a string.
See protocol docs: Session Config Options
Source code in src/aclientp/schema/client_requests.py
SetSessionConfigOptionResponse
¶
Bases: Response
Response to session/set_config_option method.
Source code in src/aclientp/schema/agent_responses.py
config_options
class-attribute
instance-attribute
¶
config_options: Sequence[SessionConfigOption] = []
The full list of config options with updated values.
SetSessionModeRequest
¶
Bases: Request
Request parameters for setting a session mode.
Source code in src/aclientp/schema/client_requests.py
SetSessionModeResponse
¶
SetSessionTitleRequest
¶
Bases: Request
UNSTABLE: Request parameters for renaming a session.
Only available if the Agent supports the session.title capability.
Source code in src/aclientp/schema/client_requests.py
SetSessionTitleResponse
¶
Bases: Response
UNSTABLE: Response to session/set_title.
Source code in src/aclientp/schema/agent_responses.py
SseMcpServer
¶
Bases: BaseMcpServer
SSE transport configuration.
Only available when the Agent capabilities indicate mcp_capabilities.sse is true.
Source code in src/aclientp/schema/mcp.py
headers
instance-attribute
¶
headers: Sequence[HttpHeader]
HTTP headers to set when making requests to the MCP server.
type
class-attribute
instance-attribute
¶
SSE transport type.
StdioMcpServer
¶
Bases: BaseMcpServer
Stdio transport configuration.
All Agents MUST support this transport.
Source code in src/aclientp/schema/mcp.py
env
instance-attribute
¶
env: Sequence[EnvVariable]
Environment variables to set when launching the MCP server.
StdioTransport
dataclass
¶
Configuration for stdio transport.
This is the default transport for ACP agents, communicating over stdin/stdout streams.
Source code in src/aclientp/transports.py
StreamTransport
dataclass
¶
Configuration for custom stream transport.
Allows passing pre-created streams for the agent to use.
Attributes:
| Name | Type | Description |
|---|---|---|
reader |
ByteReceiveStream
|
Stream to read incoming messages from. |
writer |
ByteSendStream
|
Stream to write outgoing messages to. |
Source code in src/aclientp/transports.py
StringPropertySchema
¶
Bases: AnnotatedObject
Schema for string properties in an elicitation form.
When enum_values or one_of is set, this represents a single-select enum.
Source code in src/aclientp/schema/elicitation.py
description
class-attribute
instance-attribute
¶
Human-readable description.
enum
class-attribute
instance-attribute
¶
Enum values for untitled single-select enums.
format
class-attribute
instance-attribute
¶
String format.
max_length
class-attribute
instance-attribute
¶
Maximum string length.
min_length
class-attribute
instance-attribute
¶
Minimum string length.
one_of
class-attribute
instance-attribute
¶
one_of: Sequence[EnumOption] | None = None
Titled enum options for titled single-select enums.
pattern
class-attribute
instance-attribute
¶
Pattern the string must match.
title
class-attribute
instance-attribute
¶
Optional title for the property.
SystemPrompt
¶
Bases: AnnotatedObject
Client-provided system-level instructions for a session.
Only allowed if the Agent advertises session_capabilities.system_prompt.
Source code in src/aclientp/schema/client_requests.py
mode
instance-attribute
¶
mode: SystemPromptMode
How the Agent combines content with its own instructions.
TerminalHandle
¶
Handle for a terminal session.
Source code in src/aclientp/terminal_handle.py
TerminalOutputRequest
¶
Bases: BaseAgentRequest
Request to get the current output and status of a terminal.
Source code in src/aclientp/schema/agent_requests.py
TerminalOutputResponse
¶
Bases: Response
Response containing the terminal output and exit status.
Source code in src/aclientp/schema/client_responses.py
exit_status
class-attribute
instance-attribute
¶
exit_status: TerminalExitStatus | None = None
Exit status if the command has completed.
TextContentBlock
¶
Bases: BaseContentBlock
Text content.
May be plain text or formatted with Markdown.
All agents MUST support text content blocks in prompts. Clients SHOULD render this text as Markdown.
Source code in src/aclientp/schema/content_blocks.py
TitledMultiSelectItems
¶
Bases: AnnotatedObject
Items definition for titled multi-select enum properties.
Source code in src/aclientp/schema/elicitation.py
ToolCallLocation
¶
Bases: AnnotatedObject
A file location being accessed or modified by a tool.
Enables clients to implement "follow-along" features that track which files the agent is working with in real-time. See protocol docs: Following the Agent
Source code in src/aclientp/schema/tool_call.py
line
class-attribute
instance-attribute
¶
Optional 1-based line number within the file.
Defaults to 0 (unspecified) rather than None: some clients only render clickable paths when the field is present.
ToolCallState
¶
Tracks tool call state and sends delta updates.
Instead of accumulating all state and sending everything on each update, this class tracks whether we've started and sends only the fields that are explicitly provided in each update call.
The ACP protocol spec states: "All fields except toolCallId are optional in updates. Only the fields being changed need to be included."
Example flow
- Tool call starts → state.start() sends initial notification
- Progress event → state.update(title="Running...") sends just title
- More progress → state.update(content=[...]) sends just content
- Tool completes → state.complete(raw_output=result) sends status + output
Source code in src/aclientp/tool_call_state.py
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 92 93 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 | |
__init__
¶
__init__(
notifications: ACPNotifications,
tool_call_id: str,
tool_name: str,
title: str,
kind: ToolCallKind,
raw_input: dict[str, Any],
) -> None
Initialize tool call state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notifications
|
ACPNotifications
|
ACPNotifications instance for sending updates |
required |
tool_call_id
|
str
|
Unique identifier for this tool call |
required |
tool_name
|
str
|
Name of the tool being called |
required |
title
|
str
|
Initial human-readable title |
required |
kind
|
ToolCallKind
|
Category of tool (read, edit, execute, etc.) |
required |
raw_input
|
dict[str, Any]
|
Input parameters passed to the tool |
required |
Source code in src/aclientp/tool_call_state.py
complete
async
¶
complete(
raw_output: Any = None,
*,
content: Sequence[ToolCallContent] | None = None,
title: str | None = None,
) -> None
Mark tool call as completed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_output
|
Any
|
Final output data |
None
|
content
|
Sequence[ToolCallContent] | None
|
Optional final content |
None
|
title
|
str | None
|
Optional final title |
None
|
Source code in src/aclientp/tool_call_state.py
fail
async
¶
Mark tool call as failed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
str | None
|
Error message to display |
None
|
raw_output
|
Any
|
Optional error details |
None
|
Source code in src/aclientp/tool_call_state.py
start
async
¶
Send initial tool_call notification.
This creates the tool call entry in the client UI. Subsequent calls to update() will send tool_call_update notifications with only the changed fields.
Source code in src/aclientp/tool_call_state.py
update
async
¶
update(
*,
title: str | None = None,
status: ToolCallStatus | None = None,
kind: ToolCallKind | None = None,
content: Sequence[ToolCallContent] | None = None,
locations: Sequence[ToolCallLocation | str] | None = None,
raw_output: Any = None,
) -> None
Send an update with only the provided fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str | None
|
Update the human-readable title |
None
|
status
|
ToolCallStatus | None
|
Update execution status |
None
|
kind
|
ToolCallKind | None
|
Update tool kind |
None
|
content
|
Sequence[ToolCallContent] | None
|
Content items (terminals, diffs, text) - replaces previous |
None
|
locations
|
Sequence[ToolCallLocation | str] | None
|
File locations - replaces previous |
None
|
raw_output
|
Any
|
Update raw output data |
None
|
Note
Only fields that are truthy (not None/empty) will be included in the notification. This follows the ACP spec which states that only changed fields need to be sent.
Source code in src/aclientp/tool_call_state.py
ToolCallUpdate
¶
Bases: AnnotatedObject
Details about the tool call requiring permission.
Source code in src/aclientp/schema/tool_call.py
content
class-attribute
instance-attribute
¶
Replace the content collection.
locations
class-attribute
instance-attribute
¶
locations: Sequence[ToolCallLocation] | None = None
Replace the locations collection.
name
class-attribute
instance-attribute
¶
Programmatic name of the tool being invoked.
raw_output
class-attribute
instance-attribute
¶
Update the raw output.
status
class-attribute
instance-attribute
¶
Update the execution status.
title
class-attribute
instance-attribute
¶
Update the human-readable title.
UnarchiveSessionRequest
¶
Bases: Request
UNSTABLE: Request parameters for unarchiving a session.
Only available if the Agent supports the session.archive capability.
Source code in src/aclientp/schema/client_requests.py
UnarchiveSessionResponse
¶
UntitledMultiSelectItems
¶
Bases: AnnotatedObject
Items definition for untitled multi-select enum properties.
Source code in src/aclientp/schema/elicitation.py
UserMessageChunk
¶
WaitForTerminalExitRequest
¶
Bases: BaseAgentRequest
Request to wait for a terminal command to exit.
Source code in src/aclientp/schema/agent_requests.py
WaitForTerminalExitResponse
¶
Bases: Response
Response containing the exit status of a terminal command.
Source code in src/aclientp/schema/client_responses.py
WebSocketTransport
dataclass
¶
Configuration for WebSocket server transport.
Runs an ACP agent as a WebSocket server that accepts client connections. Each client connection gets its own agent instance.
Attributes:
| Name | Type | Description |
|---|---|---|
host |
str
|
Host to bind the WebSocket server to. |
port |
int
|
Port for the WebSocket server. |
Source code in src/aclientp/transports.py
WebSocketTransportError
¶
WriteTextFileRequest
¶
Bases: BaseAgentRequest
Request to write content to a text file.
Only available if the client supports the fs.writeTextFile capability.
Source code in src/aclientp/schema/agent_requests.py
WriteTextFileResponse
¶
connect_http_transport
async
¶
connect_http_transport(
url: str,
*,
headers: Mapping[str, str] | None = None,
client: AsyncClient | None = None,
timeout: float = 30.0,
) -> AsyncGenerator[tuple[ByteReceiveStream, ByteSendStream]]
Connect to an ACP server's Streamable HTTP endpoint.
The streams carry newline-delimited JSON-RPC, like a stdio agent's. The first message
written must be initialize.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The |
required |
headers
|
Mapping[str, str] | None
|
Extra headers for every request (e.g. authentication). |
None
|
client
|
AsyncClient | None
|
HTTP client to use (its cookies and settings apply). By default a client
is created, using HTTP/2 when the |
None
|
timeout
|
float
|
Timeout for connecting and for POSTs (SSE streams have no read timeout). |
30.0
|
Yields:
| Type | Description |
|---|---|
AsyncGenerator[tuple[ByteReceiveStream, ByteSendStream]]
|
(reader, writer) byte streams. |
Source code in src/aclientp/http_transport.py
connect_remote_transport
async
¶
connect_remote_transport(
url: str, *, headers: Mapping[str, str] | None = None
) -> AsyncGenerator[tuple[ByteReceiveStream, ByteSendStream]]
Connect to a remote agent, choosing the transport by URL scheme.
ws:// / wss:// use the WebSocket transport, http:// / https:// the
Streamable HTTP transport. Both yield newline-delimited JSON-RPC byte streams.
Raises:
| Type | Description |
|---|---|
ValueError
|
The URL has another scheme. |
Source code in src/aclientp/ws_transport.py
connect_to_agent
¶
connect_to_agent(
client: Client,
input_stream: ByteSendStream,
output_stream: ByteReceiveStream,
**connection_kwargs: Any,
) -> ClientSideConnection
Create a ClientSideConnection to an ACP agent.
This is the recommended entry point for client-side connections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Client
|
The client implementation. |
required |
input_stream
|
ByteSendStream
|
ByteSendStream for sending to the agent. |
required |
output_stream
|
ByteReceiveStream
|
ByteReceiveStream for receiving from the agent. |
required |
**connection_kwargs
|
Any
|
Additional keyword arguments for ClientSideConnection. |
{}
|
Returns:
| Type | Description |
|---|---|
ClientSideConnection
|
A ClientSideConnection connected to the agent. |
Source code in src/aclientp/stdio.py
connect_websocket_transport
async
¶
connect_websocket_transport(
url: str, *, headers: Mapping[str, str] | None = None, open_timeout: float = 30.0
) -> AsyncGenerator[tuple[ByteReceiveStream, ByteSendStream]]
Connect to an ACP server's WebSocket endpoint (ws:// or wss://).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The |
required |
headers
|
Mapping[str, str] | None
|
Extra headers for the upgrade request (e.g. authentication). |
None
|
open_timeout
|
float
|
Timeout for the opening handshake. |
30.0
|
Yields:
| Type | Description |
|---|---|
AsyncGenerator[tuple[ByteReceiveStream, ByteSendStream]]
|
(reader, writer) byte streams. |
Raises:
| Type | Description |
|---|---|
WebSocketTransportError
|
The server rejected the upgrade or is unreachable. |
Source code in src/aclientp/ws_transport.py
run_agent
async
¶
run_agent(
agent: Agent | Callable[[AgentSideConnection], Agent],
input_stream: ByteSendStream | None = None,
output_stream: ByteReceiveStream | None = None,
**connection_kwargs: Any,
) -> None
Run an ACP agent over stdio or provided streams.
This is the recommended entry point for running agents. It handles stream setup and connection lifecycle automatically, and returns once the client disconnects (or raises when cancelled).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Agent | Callable[[AgentSideConnection], Agent]
|
An Agent implementation or a factory callable that takes an AgentSideConnection and returns an Agent. Using a factory allows the agent to access the connection for client communication. |
required |
input_stream
|
ByteSendStream | None
|
ByteSendStream the agent writes to (defaults to stdout). |
None
|
output_stream
|
ByteReceiveStream | None
|
ByteReceiveStream the agent reads from (defaults to stdin). |
None
|
**connection_kwargs
|
Any
|
Additional keyword arguments for AgentSideConnection. |
{}
|
Example with direct agent
Example with factory
Source code in src/aclientp/stdio.py
serve
async
¶
serve(
agent: V1AgentSource | None = None,
transport: Transport = "stdio",
*,
v2_agent: V2AgentSource | None = None,
shutdown_event: Event | None = None,
debug_file: str | None = None,
observers: list[StreamObserver] | None = None,
) -> None
Run an ACP agent with the specified transport.
This is the main entry point for running ACP agents. It handles transport setup and lifecycle management automatically.
With only agent, every client is served by that v1 agent. With v2_agent,
each client connection is routed on initialize
(:class:~aclientp.router.RoutedAgentConnection): clients asking for v2 or later
get the v2 agent, others the v1 agent (if given).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
V1AgentSource | None
|
The v1 agent, or a factory that takes an AgentSideConnection and returns one. |
None
|
transport
|
Transport
|
Transport configuration. Can be: - "stdio" or StdioTransport(): Use stdin/stdout - "websocket" or WebSocketTransport(...): Run WebSocket server - StreamTransport(...): Use custom streams |
'stdio'
|
v2_agent
|
V2AgentSource | None
|
The v2 agent, or a factory that takes a v2 AgentSideConnection and returns one. |
None
|
shutdown_event
|
Event | None
|
Optional event to signal shutdown. If not provided, runs until cancelled. |
None
|
debug_file
|
str | None
|
Optional file path for debug message logging. |
None
|
observers
|
list[StreamObserver] | None
|
Observers of the raw messages of each connection. |
None
|
Example
# Stdio (default)
await serve(MyAgent())
# WebSocket server
await serve(MyAgent(), WebSocketTransport(host="0.0.0.0", port=9000))
# v1 and v2 clients on one endpoint
await serve(MyAgent(), v2_agent=MyV2Agent)
# With shutdown control
shutdown = asyncio.Event()
task = asyncio.create_task(serve(MyAgent(), shutdown_event=shutdown))
# ... later ...
shutdown.set()
await task
Source code in src/aclientp/transports.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
stdio_streams
async
¶
stdio_streams() -> tuple[StdinStream, StdoutStream]
Create stdio anyio-compatible streams (cross-platform).
Returns (stdin, stdout) as byte stream wrappers compatible with ByteReceiveStream and ByteSendStream interfaces.