Skip to main content

Crate agent_client_protocol_schema

Crate agent_client_protocol_schema 

Source
Expand description

Agent Client Protocol

§Agent Client Protocol Schema

Strongly-typed Rust definitions of the Agent Client Protocol (ACP) wire format. ACP is a JSON-RPC based protocol that standardizes communication between code editors (IDEs, text-editors, etc.) and coding agents (programs that use generative AI to autonomously modify code).

This crate is only the schema: the request, response, and notification types, plus serde plumbing and optional JSON Schema generation. For the runtime pieces (transport, connection setup, the Agent / Client traits, etc.) use the higher-level agent-client-protocol crate, which builds on top of these types.

§What’s in this crate

§Parsing aggregate enums

Do not deserialize an aggregate routing enum directly from a wire payload. Its untagged Deserialize implementation selects by payload shape, not the JSON-RPC method, and can silently select an unrelated variant. Use the enum’s from_method_and_params or from_method_and_result method instead. Individual payload structs can be deserialized directly once the method is known.

These helpers only select and deserialize payloads. Use the SDK for connections, request tracking, and JSON-RPC error handling.

use agent_client_protocol_schema::v1::ClientRequest;
use serde_json::json;

let params = json!({"cwd": "/work", "mcpServers": []});
let request = ClientRequest::from_method_and_params("session/new", &params)?;
assert!(matches!(request, ClientRequest::NewSessionRequest(_)));

§Cargo features

The schemars feature implements schemars::JsonSchema for the protocol types. It is enabled by default to preserve the existing default API. Consumers that only need serialization can disable default features to omit the dependency and those trait implementations.

The uuid feature adds IdempotencyKey::generate to the v2 module, which creates a key from a random UUID. It is off by default.

§Versioning

Stable protocol types are exposed through explicit version modules. For example, use agent_client_protocol_schema::v1::SessionId for ACP protocol version 1 types.

For the complete protocol specification and documentation, visit https://agentclientprotocol.com.

Modules§

rpc
JSON-RPC envelope types shared by ACP clients and agents.
v1
Agent Client Protocol version 1 types.
v2unstable_protocol_v2
Agent Client Protocol version 2 types.

Structs§

ProtocolVersion
Protocol version identifier.

Enums§

MaybeUndefined
Similar to Option, but it has three states, undefined, null and x.
MethodDispatchError
A failure to select or deserialize a method’s payload.

Traits§

IntoMaybeUndefined
Utility trait for builder methods for optional values. This allows the caller to either pass in the value itself without wrapping it in Some, or to just pass in an Option if that is what they have, or set it back to undefined.
IntoOption
Utility trait for builder methods for optional values. This allows the caller to either pass in the value itself without wrapping it in Some, or to just pass in an Option if that is what they have.