1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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
//! # agent-client-protocol -- the Agent Client Protocol (ACP) SDK
//!
//! **agent-client-protocol** is a Rust SDK for building [Agent-Client Protocol (ACP)][acp] applications.
//! ACP is a protocol for communication between AI agents and their clients (IDEs, CLIs, etc.),
//! enabling features like tool use, permission requests, and streaming responses.
//!
//! [acp]: https://agentclientprotocol.com/
//!
//! ## What can you build with agent-client-protocol?
//!
//! - **Clients** that talk to ACP agents (like building your own Claude Code interface)
//! - **Proxies** that add capabilities to existing agents (like adding custom tools via MCP)
//! - **Agents** that respond to prompts with AI-powered responses
//!
//! ## Quick Start: Connecting to an Agent
//!
//! The most common use case is connecting to an existing ACP agent as a client.
//! This example uses stable ACP protocol v1. The draft protocol v2 feature
//! provides a command-only `V2Session` API and receives updates and interactive
//! requests through typed connection handlers because prompt acceptance and
//! inbound traffic are independent. With both v2 and MCP-over-ACP features,
//! `Proxy.v2()` supports global MCP attachment, while `V2SessionBuilder` and
//! `V2ResumeSessionBuilder` support per-session attachment plus non-blocking
//! proxy setup. With `unstable_session_fork`, `V2ForkSessionBuilder` provides
//! the same shape for forked sessions and uses the response's new session ID.
//! Per-session MCP routes and runners are ready before a setup request is
//! published, as is proxy session routing for resume replay; successful
//! attachments remain active for the connection lifetime.
//!
//! Here's a minimal example that initializes a v1 connection, creates a
//! session, and sends a prompt:
//!
//! ```no_run
//! use agent_client_protocol::Client;
//! use agent_client_protocol::schema::{ProtocolVersion, v1::InitializeRequest};
//!
//! # async fn run(transport: impl agent_client_protocol::ConnectTo<agent_client_protocol::Client>) -> agent_client_protocol::Result<()> {
//! Client.builder()
//! .name("my-client")
//! .connect_with(transport, async |cx| {
//! // Step 1: Initialize the connection
//! cx.send_request(InitializeRequest::new(ProtocolVersion::V1))
//! .block_task().await?;
//!
//! // Step 2: Create a session and send a prompt
//! cx.build_session_cwd()?
//! .block_task()
//! .run_until(async |mut session| {
//! session.send_prompt("What is 2 + 2?")?;
//! let response = session.read_to_string().await?;
//! println!("{}", response);
//! Ok(())
//! })
//! .await
//! })
//! .await
//! # }
//! ```
//!
//! For a complete working example, see [`yolo_one_shot_client.rs`][yolo].
//!
//! [yolo]: https://github.com/agentclientprotocol/rust-sdk/blob/main/src/agent-client-protocol/examples/yolo_one_shot_client.rs
//!
//! ## Cookbook
//!
//! The [`agent_client_protocol_cookbook`] crate contains practical guides and examples:
//!
//! - Connecting as a client
//! - Global MCP server
//! - Per-session MCP server with workspace context
//! - Building agents and reusable components
//! - Running proxies with the conductor
//!
//! [`agent_client_protocol_cookbook`]: https://docs.rs/agent-client-protocol-cookbook
//!
//! ## WASI
//!
//! The runtime-neutral protocol engine and transport abstractions compile for
//! `wasm32-wasip1` and `wasm32-wasip2`. This crate does not provide a WASI
//! executor or host I/O adapter. The native `AcpAgent` and `Stdio`
//! implementations depend on process spawning and blocking-thread facilities,
//! so they and `LineDirection` are not exported on these targets.
//!
//! Embedders provide their own runtime and transport. They can exchange
//! `TransportFrame` values through `Channel`, newline-delimited JSON through
//! `Lines`, or use `ByteStreams` with `futures::io::AsyncRead` and
//! `AsyncWrite`. The embedding runtime must drive the resulting connection
//! future.
//!
//! ## Core Concepts
//!
//! The [`concepts`] module provides detailed explanations of how agent-client-protocol works,
//! including connections, sessions, callbacks, ordering guarantees, and more.
//!
//! ## Related Crates
//!
//! - [`agent-client-protocol-conductor`] - Binary for running proxy chains
//!
//! [`agent-client-protocol-conductor`]: https://crates.io/crates/agent-client-protocol-conductor
/// Capability management for the `_meta.symposium` object
/// Component abstraction for agents and proxies
/// Core concepts for understanding and using agent-client-protocol
/// JSON-RPC connection and handler infrastructure
/// Runtime-agnostic MCP server support, including optional attachment to ACP sessions.
/// Role types for ACP connections
/// ACP protocol schema types - all message types, requests, responses, and supporting types
/// Utility functions and types
pub use *;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// Implementation details used by the derive macros.
// Re-export BoxFuture for implementing SDK traits that return boxed futures.
pub use BoxFuture;
// Re-export commonly used infrastructure types for convenience
pub use ;
// Re-export derive macros for custom JSON-RPC types
pub use ;
pub use *;
pub use ;
pub use Stdio;
/// This is a hack that must be given as the final argument of
/// the MCP server builder's `tool_fn_mut` method when defining tools.
///
/// The `agent-client-protocol-rmcp` crate provides the builder this macro is
/// typically used with.
/// Look away, lest ye be blinded by its vileness!
///
/// Fine, if you MUST know, it's a horrific workaround for not having
/// [return-type notation](https://github.com/rust-lang/rust/issues/109417)
/// and for [this !@$#!%! bug](https://github.com/rust-lang/rust/issues/110338).
/// Trust me, the need for it hurts me more than it hurts you. --nikomatsakis
/// This is a hack that must be given as the final argument of
/// the MCP server builder's `tool_fn` method when defining stateless concurrent tools.
///
/// The `agent-client-protocol-rmcp` crate provides the builder this macro is
/// typically used with.
/// See [`tool_fn_mut!`] for the gory details.
/// This macro is used for the value of the `to_future_hack` parameter of
/// [`Builder::on_receive_request`] and [`Builder::on_receive_request_from`].
///
/// It expands to `|f, req, responder, cx| Box::pin(f(req, responder, cx))`.
///
/// This is needed until [return-type notation](https://github.com/rust-lang/rust/issues/109417)
/// is stabilized.
/// This macro is used for the value of the `to_future_hack` parameter of
/// [`Builder::on_receive_notification`] and [`Builder::on_receive_notification_from`].
///
/// It expands to `|f, notif, cx| Box::pin(f(notif, cx))`.
///
/// This is needed until [return-type notation](https://github.com/rust-lang/rust/issues/109417)
/// is stabilized.
/// This macro is used for the value of the `to_future_hack` parameter of
/// [`Builder::on_receive_dispatch`] and [`Builder::on_receive_dispatch_from`].
///
/// It expands to `|f, dispatch, cx| Box::pin(f(dispatch, cx))`.
///
/// This is needed until [return-type notation](https://github.com/rust-lang/rust/issues/109417)
/// is stabilized.