Skip to content

Commit 2deebdd

Browse files
authored
feat(acp): Add v2 session MCP attachment (#303)
1 parent f0f52f9 commit 2deebdd

16 files changed

Lines changed: 1677 additions & 124 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ This repository is the official **Rust SDK** for ACP. It provides crates for bui
2222
Native MCP-over-ACP support is currently opt-in through the core crate's
2323
`unstable_mcp_over_acp` feature. Standalone MCP servers need no ACP transport
2424
feature; the rmcp integration exposes a matching passthrough feature when those
25-
servers are attached to ACP. MCP attachment and proxy-session helpers currently
26-
use stable protocol v1.
25+
servers are attached to ACP. Stable protocol v1 supports per-session and global
26+
proxy attachment. Per-session attachment through the draft `V2SessionBuilder`
27+
is also available when both `unstable_protocol_v2` and
28+
`unstable_mcp_over_acp` are enabled. Successful v2 attachments remain active
29+
for the connection lifetime; global proxy attachment and proxy-session helpers
30+
remain v1-only.
2731

2832
**Proxy orchestration**
2933

md/protocol-v2.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,19 @@ them in order. If a handler forwards updates to another task, the application
207207
is responsible for any additional projection-drained barrier it needs before
208208
treating replay as locally applied.
209209

210-
Dropping command handles has no network or inbound-routing side effect. If an
211-
application wants stream ergonomics, it can fan typed updates out from the
212-
connection handler with an explicit buffering and subscriber policy. MCP
213-
attachment and proxy-session helpers are still v1-only.
210+
Dropping command handles has no network or inbound-routing side effect. For a
211+
session created with `V2SessionBuilder::with_mcp_server`, the SDK installs the
212+
MCP routes and initially polls their runner tasks before publishing
213+
`session/new`, so the agent can connect to those servers during session setup.
214+
Runners may continue asynchronous initialization; custom connectors must be
215+
able to queue connections and messages once constructed. A successful setup
216+
promotes the attachment to the connection lifetime; any setup failure cleans it
217+
up. This attachment requires both `unstable_protocol_v2` and
218+
`unstable_mcp_over_acp`. Global proxy attachment and proxy-session helpers
219+
remain v1-only.
220+
221+
If an application wants stream ergonomics, it can fan typed updates out from
222+
the connection handler with an explicit buffering and subscriber policy.
214223

215224
## Conductor and proxy initialization
216225

@@ -346,17 +355,19 @@ agent:
346355

347356
## Draft schema changes in schema 1.5 and 1.6
348357

349-
The `unstable_protocol_v2` API follows the moving draft schema. Schema 1.5 adds
350-
semantic newtypes for paths, media types, IDs, and cursors; renames
351-
`DiffPatch.diff` to `DiffPatch.text`; adds terminal state and output update
352-
types; and makes v1/v2 conversions fallible and generic. These are draft API
353-
changes rather than stable v1 wire changes. See [Migrating to
358+
The `unstable_protocol_v2` API follows the moving draft schema. Schema 1.5 added
359+
semantic newtypes for paths, media types, IDs, and cursors; renamed
360+
`DiffPatch.diff` to `DiffPatch.text`; and added terminal state and output update
361+
types. The next schema dependency update removes the former schema-wide v1/v2
362+
conversion API: versioned implementations should remain separate, with
363+
purpose-specific adapters at runtime boundaries where the required state and
364+
policy are available. These are draft API changes rather than stable v1 wire
365+
changes. See [Migrating to
354366
v2.0](./migration_v2.0.md#draft-v2-schema-updates) for concrete source changes.
355367

356368
Schema 1.6 adds `Cancelled` tool-call and plan-entry statuses to draft v2.
357369
Programmatic tool-call names are available in both protocol versions through
358370
the separate `unstable_tool_call_name` feature. Draft v2 users must enable both
359371
`unstable_protocol_v2` and `unstable_tool_call_name`. In v2, an omitted name
360372
leaves the existing value unchanged, `null` clears it, and a string replaces
361-
it. V1 cannot clear an existing name, so converting a v2 `null` name to v1
362-
fails.
373+
it. V1 cannot express the explicit v2 `null` clear operation.

src/agent-client-protocol/CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@
1414
cancellation. `Client.v2()` and `Agent.v2()` callbacks receive a
1515
`V2ConnectionTo` whose unversioned `build_session*` and `resume_session*`
1616
methods expose only the v2 lifecycle. Session updates and interactive
17-
requests remain on typed connection handlers; MCP attachment and
18-
proxy-session helpers remain v1-only.
17+
requests remain on typed connection handlers. With
18+
`unstable_mcp_over_acp`, `V2SessionBuilder::with_mcp_server` adds native
19+
per-session MCP attachment while preserving independent response
20+
consumption. MCP routes are installed and runners begin executing before
21+
`session/new` is published; successful attachments remain active for the
22+
connection lifetime. Global proxy attachment and proxy-session helpers
23+
remain v1-only.
1924
- *(unstable-v2)* Expose protocol-neutral dynamic handler registration on
2025
`V2ConnectionTo`.
2126
- *(unstable-v2)* Add `ConnectionTo::spawn_connection_with_context` for raw

src/agent-client-protocol/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ Draft protocol v2 is opt-in through `unstable_protocol_v2`. `Client.v2()` and
4545
high-level, command-only session helpers because prompt acceptance and inbound
4646
traffic are independent. Session updates and interactive requests use typed
4747
connection handlers. See [Protocol V2](https://agentclientprotocol.github.io/rust-sdk/protocol-v2.html#high-level-v2-sessions).
48-
MCP attachment and proxy-session helpers remain v1-only.
48+
Per-session MCP attachment through `V2SessionBuilder` is available with both
49+
`unstable_protocol_v2` and `unstable_mcp_over_acp`. Global proxy attachment and
50+
proxy-session helpers remain v1-only.
4951

5052
## MCP Server Attachment
5153

@@ -55,7 +57,10 @@ the `with_mcp_server` builder methods requires `unstable_mcp_over_acp`.
5557
Attached servers are advertised with native `McpServer::Acp` declarations and
5658
communicate through `mcp/connect`, `mcp/message`, and `mcp/disconnect`. Use
5759
`agent-client-protocol-polyfill` immediately before an HTTP-capable agent.
58-
These ACP attachment and proxy paths currently use stable protocol v1.
60+
Stable protocol v1 supports per-session and global proxy attachment. Draft
61+
protocol v2 supports per-session `session/new` attachment when both unstable
62+
features are enabled; successful attachments remain active for the connection
63+
lifetime, and its global proxy path remains v1-only.
5964

6065
## Learning More
6166

src/agent-client-protocol/src/concepts/sessions.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@
8585
//! tools to the agent:
8686
//!
8787
//! MCP attachment requires the `unstable_mcp_over_acp` feature. Standalone MCP
88-
//! servers remain available without it.
88+
//! servers remain available without it. Draft protocol v2 per-session
89+
//! attachment uses `V2SessionBuilder::with_mcp_server` and additionally
90+
//! requires `unstable_protocol_v2`; successful v2 attachments remain active
91+
//! for the connection lifetime.
8992
//!
9093
//! ```ignore
9194
//! # use agent_client_protocol::{Client, Agent, ConnectTo};

0 commit comments

Comments
 (0)