Expand description
§sacp-proxy
Framework for building ACP proxy components that extend agent functionality.
§What are proxies?
Proxies are modular components that sit between an editor and an agent, intercepting and transforming messages. They enable composable agent architectures where functionality can be added without modifying the base agent.
Editor → Proxy 1 → Proxy 2 → AgentUse cases:
- Add MCP tools/resources/prompts to any agent
- Inject context or modify prompts before they reach the agent
- Filter or transform agent responses
- Add logging, metrics, or policy enforcement
§Quick Start
The simplest proxy just forwards messages unchanged:
use sacp::JrHandlerChain;
use sacp_proxy::{AcpProxyExt, McpServiceRegistry};
use tokio_util::compat::{TokioAsyncReadCompatExt, TokioAsyncWriteCompatExt};
JrHandlerChain::new()
.name("my-proxy")
.provide_mcp(McpServiceRegistry::default()) // Provide MCP services
.proxy() // Enable proxy mode
.serve(sacp::ByteStreams::new(
tokio::io::stdout().compat_write(),
tokio::io::stdin().compat()
))
.await?;To add MCP tools to the proxy, provide an MCP server:
use sacp::JrHandlerChain;
use sacp_proxy::{AcpProxyExt, McpServiceRegistry};
use tokio_util::compat::{TokioAsyncReadCompatExt, TokioAsyncWriteCompatExt};
JrHandlerChain::new()
.name("my-proxy")
// Add MCP servers to provide tools/resources/prompts
.provide_mcp(
McpServiceRegistry::default()
// .with_rmcp_server("my-server", || MyMcpServer::new())?
)
.proxy()
.serve(sacp::ByteStreams::new(
tokio::io::stdout().compat_write(),
tokio::io::stdin().compat()
))
.await?;See the with_mcp_server.rs example for a complete implementation.
§Key Concepts
Predecessor vs Successor:
- Predecessor - The component closer to the editor (could be editor or another proxy)
- Successor - The component farther from the editor (could be agent or another proxy)
Messages flow: Predecessor → This Proxy → Successor
Extension Traits:
AcpProxyExt- Adds proxy-specific methods toJrConnectionJrCxExt- Adds forwarding methods (send_to_predecessor,send_to_successor)
§Examples
See the examples directory:
minimal.rs- Simplest possible proxy that forwards everything unchangedwith_mcp_server.rs- Proxy that adds MCP tools to any agent
§How Proxies Work
When you call .proxy(), the framework:
- Handles capability negotiation with predecessor and successor
- Sets up message routing between components
- Wraps your handlers to intercept specific message types
- Forwards everything else automatically
You only need to handle the messages you want to intercept or transform.
§Related Crates
- sacp - Core ACP SDK
- sacp-conductor - Binary for orchestrating proxy chains
- sacp-tokio - Tokio utilities for spawning agents
Structs§
- McpConnect
Request - Creates a new MCP connection. This is equivalent to “running the command”.
- McpConnect
Response - Response to an MCP connect request
- McpDisconnect
Notification - Disconnects the MCP connection.
- McpOver
AcpNotification - An MCP notification sent via ACP, either from the MCP client (the ACP agent) or the MCP server (the ACP client).
- McpOver
AcpRequest - An MCP request sent via ACP. This could be an MCP-server-to-MCP-client request (in which case it goes from the ACP client to the ACP agent, note the reversal of roles) or an MCP-client-to-MCP-server request (in which case it goes from the ACP agent to the ACP client).
- McpService
Registry - Manages MCP services offered to successor proxies and agents.
- Message
From Successor Handler - Handler to process a message of type
Rcoming from the successor component. - Notification
From Successor Handler - Handler to process a notification of type
Ncoming from the successor component. - Proxy
Handler - Handler for the “default proxy” behavior.
- Request
From Successor Handler - Handler to process a request of type
Rcoming from the successor component. - Successor
Notification - A notification being sent to the successor component.
- Successor
Request - A request being sent to the successor component.
Constants§
- METHOD_
MCP_ CONNECT_ REQUEST - JSON-RPC method name for MCP connect requests
- METHOD_
MCP_ DISCONNECT_ NOTIFICATION - JSON-RPC method name for MCP disconnect notifications
- METHOD_
MCP_ NOTIFICATION - JSON-RPC method name for MCP notifications over ACP
- METHOD_
MCP_ REQUEST - JSON-RPC method name for MCP requests over ACP
Traits§
- AcpProxy
Ext - Extension trait for JrConnection that adds proxy-specific functionality
- Component
- Re-export component types from sacp A component that can be run as part of a conductor’s chain.
- JrCxExt
- Extension trait for
JrConnectionCxthat adds methods for sending to successor.