AgentSideConnection
🛈 DocStrings¶
UNSTABLE: Connection of a v2 agent to a client.
Enforces the v2 rules: requests before initialize get -32600 and
notifications are ignored, initialize may only be repeated before other
requests, request IDs must be strings or integers, and batches get -32600.
Source code in src/aclientp/v2/agent.py
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 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 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | |
PROTOCOL_VERSION
class-attribute
instance-attribute
¶
PROTOCOL_VERSION = PROTOCOL_VERSION
The protocol version this connection speaks.
__init__
¶
__init__(
to_agent: Callable[[AgentSideConnection], Agent] | Agent,
input_stream: ByteSendStream,
output_stream: ByteReceiveStream,
observers: list[StreamObserver] | None = None,
) -> None
Start the connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_agent
|
Callable[[AgentSideConnection], Agent] | Agent
|
The agent, or a factory receiving this connection. |
required |
input_stream
|
ByteSendStream
|
Stream to the client. |
required |
output_stream
|
ByteReceiveStream
|
Stream from the client. |
required |
observers
|
list[StreamObserver] | None
|
Observers of the raw messages. |
None
|
Source code in src/aclientp/v2/agent.py
auth_status_update
async
¶
auth_status_update(params: AuthStatusUpdateNotification) -> None
Report a change of the authentication status (auth/status_update).
close
async
¶
complete_elicitation
async
¶
complete_elicitation(params: CompleteElicitationNotification) -> None
Report that a URL elicitation is complete (elicitation/complete).
create_elicitation
async
¶
create_elicitation(params: CreateElicitationRequest) -> CreateElicitationResponse
Ask the user for structured input (elicitation/create).
Source code in src/aclientp/v2/agent.py
ext_method
async
¶
handle
async
¶
Handle one incoming message (the connection's handler).
Source code in src/aclientp/v2/agent.py
mcp_message
async
¶
mcp_message(params: MessageMcpRequest) -> MessageMcpResponse
Send an mcp/message request to the client.
mcp_notification
async
¶
mcp_notification(params: MessageMcpNotification) -> None
on_connection
classmethod
¶
on_connection(
connection: Connection, to_agent: Callable[[AgentSideConnection], Agent] | Agent
) -> AgentSideConnection
Serve v2 on an existing connection whose handler delegates to :meth:handle.
Used by the version router, which owns the connection until initialize.
Source code in src/aclientp/v2/agent.py
request_permission
async
¶
request_permission(params: RequestPermissionRequest) -> RequestPermissionResponse
Ask the user for permission (session/request_permission).
Source code in src/aclientp/v2/agent.py
session_update
async
¶
session_update(params: UpdateSessionNotification) -> None