protocol
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| AgentNotification aclientp.schema.v2.protocol A notification the agent sends to the client. |
||
| AgentRequest aclientp.schema.v2.protocol A request the agent sends to the client (a :data:`ClientMethod`). |
||
| CancelRequestNotification aclientp.schema.v2.protocol Parameters of ``$/cancel_request``: cancel an ongoing request. |
||
| ClientNotification aclientp.schema.v2.protocol A notification the client sends to the agent. |
||
| ClientRequest aclientp.schema.v2.protocol A request the client sends to the agent (an :data:`AgentMethod`). |
||
| ErrorResponse aclientp.schema.v2.protocol A failed JSON-RPC response. |
||
| InitializeProxyRequest aclientp.schema.v2.protocol **UNSTABLE**: Parameters of ``proxy/initialize``, sent instead of ``initialize``. |
||
| InitializeProxyResponse aclientp.schema.v2.protocol **UNSTABLE**: Response to ``proxy/initialize``; the same as an ``initialize`` response. |
||
| ProxyNotification aclientp.schema.v2.protocol **UNSTABLE**: A notification to a proxy in a proxy chain. |
||
| ProxyRequest aclientp.schema.v2.protocol **UNSTABLE**: A request to a proxy in a proxy chain (a :data:`ProxyMethod`). |
||
| ProxySuccessorNotification aclientp.schema.v2.protocol **UNSTABLE**: Parameters of a ``proxy/successor`` notification: a wrapped notification. |
||
| ProxySuccessorRequest aclientp.schema.v2.protocol **UNSTABLE**: Parameters of a ``proxy/successor`` request: a wrapped request. |
||
| RequestTypes aclientp.schema.v2.protocol Validators of a request method's parameters and result. |
||
| ResultResponse aclientp.schema.v2.protocol A successful JSON-RPC response. |
🛈 DocStrings¶
v2 JSON-RPC layer: methods, message envelopes, cancellation and proxies.
Envelopes keep params / result untyped: the method selects their type, and many
parameter types share fields (e.g. sessionId), so they cannot be told apart by
shape. Parse them by method with the *_REQUESTS / *_NOTIFICATIONS tables, e.g.
AGENT_REQUESTS[request.method].params.validate_python(request.params).
v2 does not use JSON-RPC batches: each transport message is a single request,
notification or response, and receivers reject an array with -32600.
AGENT_NOTIFICATIONS
module-attribute
¶
AGENT_NOTIFICATIONS: dict[str, TypeAdapter[Any]] = {
"session/cancel": TypeAdapter(CancelSessionNotification),
"mcp/message": TypeAdapter(MessageMcpNotification),
}
Notifications the agent handles.
AGENT_REQUESTS
module-attribute
¶
AGENT_REQUESTS: dict[str, RequestTypes] = {
"initialize": RequestTypes.of(InitializeRequest, InitializeResponse),
"auth/login": RequestTypes.of(LoginAuthRequest, LoginAuthResponse),
"auth/logout": RequestTypes.of(LogoutAuthRequest, LogoutAuthResponse),
"auth/status": RequestTypes.of(AuthStatusRequest, AuthStatusResponse),
"providers/list": RequestTypes.of(ListProvidersRequest, ListProvidersResponse),
"providers/set": RequestTypes.of(SetProviderRequest, SetProviderResponse),
"providers/disable": RequestTypes.of(DisableProviderRequest, DisableProviderResponse),
"session/new": RequestTypes.of(NewSessionRequest, NewSessionResponse),
"session/resume": RequestTypes.of(ResumeSessionRequest, ResumeSessionResponse),
"session/fork": RequestTypes.of(ForkSessionRequest, ForkSessionResponse),
"session/close": RequestTypes.of(CloseSessionRequest, CloseSessionResponse),
"session/list": RequestTypes.of(ListSessionsRequest, ListSessionsResponse),
"session/delete": RequestTypes.of(DeleteSessionRequest, DeleteSessionResponse),
"session/archive": RequestTypes.of(ArchiveSessionRequest, ArchiveSessionResponse),
"session/unarchive": RequestTypes.of(UnarchiveSessionRequest, UnarchiveSessionResponse),
"session/status": RequestTypes.of(SessionStatusRequest, SessionStatusResponse),
"session/options": RequestTypes.of(SessionOptionsRequest, SessionOptionsResponse),
"session/set_title": RequestTypes.of(SetSessionTitleRequest, SetSessionTitleResponse),
"session/set_config_option": RequestTypes.of(
SetSessionConfigOptionRequest, SetSessionConfigOptionResponse
),
"session/prompt": RequestTypes.of(PromptRequest, PromptResponse),
"tool_call/cancel": RequestTypes.of(CancelToolCallRequest, CancelToolCallResponse),
"terminal/cancel": RequestTypes.of(CancelTerminalRequest, CancelTerminalResponse),
"mcp/message": RequestTypes.of(MessageMcpRequest, MessageMcpResponse),
}
Requests the agent handles.
AgentMethod
module-attribute
¶
AgentMethod = Literal[
"auth/login",
"auth/logout",
"auth/status",
"initialize",
"mcp/message",
"providers/disable",
"providers/list",
"providers/set",
"session/archive",
"session/cancel",
"session/close",
"session/delete",
"session/fork",
"session/list",
"session/new",
"session/options",
"session/prompt",
"session/resume",
"session/set_config_option",
"session/set_title",
"session/status",
"session/unarchive",
"terminal/cancel",
"tool_call/cancel",
]
Methods handled by the agent (session/cancel is a notification).
AgentResponse
module-attribute
¶
AgentResponse = ResultResponse | ErrorResponse
A response the agent sends to a client request.
CLIENT_NOTIFICATIONS
module-attribute
¶
CLIENT_NOTIFICATIONS: dict[str, TypeAdapter[Any]] = {
"session/update": TypeAdapter(UpdateSessionNotification),
"elicitation/complete": TypeAdapter(CompleteElicitationNotification),
"auth/status_update": TypeAdapter(AuthStatusUpdateNotification),
"mcp/message": TypeAdapter(MessageMcpNotification),
}
Notifications the client handles.
CLIENT_REQUESTS
module-attribute
¶
CLIENT_REQUESTS: dict[str, RequestTypes] = {
"session/request_permission": RequestTypes.of(
RequestPermissionRequest, RequestPermissionResponse
),
"elicitation/create": RequestTypes.of(CreateElicitationRequest, CreateElicitationResponse),
"mcp/message": RequestTypes.of(MessageMcpRequest, MessageMcpResponse),
}
Requests the client handles.
ClientMethod
module-attribute
¶
ClientMethod = Literal[
"auth/status_update",
"elicitation/complete",
"elicitation/create",
"mcp/message",
"session/request_permission",
"session/update",
]
Methods handled by the client.
ClientResponse
module-attribute
¶
ClientResponse = ResultResponse | ErrorResponse
A response the client sends to an agent request.
PROTOCOL_NOTIFICATIONS
module-attribute
¶
PROTOCOL_NOTIFICATIONS: dict[str, TypeAdapter[Any]] = {
"$/cancel_request": TypeAdapter(CancelRequestNotification)
}
Notifications either side handles.
PROXY_NOTIFICATIONS
module-attribute
¶
PROXY_NOTIFICATIONS: dict[str, TypeAdapter[Any]] = {
"proxy/successor": TypeAdapter(ProxySuccessorNotification)
}
UNSTABLE: Notifications a proxy handles.
PROXY_REQUESTS
module-attribute
¶
PROXY_REQUESTS: dict[str, RequestTypes] = {
"proxy/initialize": RequestTypes.of(InitializeProxyRequest, InitializeProxyResponse),
"proxy/successor": RequestTypes.of(ProxySuccessorRequest, ProxySuccessorResponse),
}
UNSTABLE: Requests a proxy handles.
ProtocolMethod
module-attribute
¶
Methods either side may send.
ProxyMethod
module-attribute
¶
UNSTABLE: Methods handled by proxies in a proxy chain.
ProxyResponse
module-attribute
¶
ProxyResponse = ResultResponse | ErrorResponse
UNSTABLE: A response of a proxy.
ProxySuccessorResponse
module-attribute
¶
UNSTABLE: Result of proxy/successor: the wrapped request's result, unchanged.
AgentNotification
¶
AgentRequest
¶
CancelRequestNotification
¶
Bases: AnnotatedObject
Parameters of $/cancel_request: cancel an ongoing request.
The request must be one the sender of the notification issued.
Source code in src/aclientp/schema/v2/protocol.py
ClientNotification
¶
ClientRequest
¶
ErrorResponse
¶
Bases: _Message
A failed JSON-RPC response.
Source code in src/aclientp/schema/v2/protocol.py
InitializeProxyRequest
¶
Bases: InitializeRequest
UNSTABLE: Parameters of proxy/initialize, sent instead of initialize.
A conductor sends it to every component that has a successor.
Source code in src/aclientp/schema/v2/protocol.py
InitializeProxyResponse
¶
Bases: InitializeResponse
UNSTABLE: Response to proxy/initialize; the same as an initialize response.
Source code in src/aclientp/schema/v2/protocol.py
ProxyNotification
¶
ProxyRequest
¶
ProxySuccessorNotification
¶
Bases: AnnotatedObject
UNSTABLE: Parameters of a proxy/successor notification: a wrapped notification.
Source code in src/aclientp/schema/v2/protocol.py
ProxySuccessorRequest
¶
Bases: AnnotatedObject
UNSTABLE: Parameters of a proxy/successor request: a wrapped request.
Source code in src/aclientp/schema/v2/protocol.py
RequestTypes
dataclass
¶
Validators of a request method's parameters and result.
Source code in src/aclientp/schema/v2/protocol.py
params
instance-attribute
¶
Parses and validates the params of the request.
result
instance-attribute
¶
Parses and validates the result of the response.
of
classmethod
¶
of(params: Any, result: Any) -> RequestTypes
ResultResponse
¶
Bases: _Message
A successful JSON-RPC response.