Skip to content

Commit e1b8db8

Browse files
committed
Step 3: Remove MCP bridging from conductor (clean break)
- Remove McpBridgeMode enum and mcp_bridge_mode parameter - Delete conductor/mcp_bridge module (actor, http, stdio) - Remove bridge fields from ConductorResponder - Remove bridge ConductorMessage variants and handling - Remove NewSessionRequest MCP server transformation - Update all 16 test files to remove McpBridgeMode - Mark 13 bridge-dependent tests as #[ignore]
1 parent bade279 commit e1b8db8

22 files changed

Lines changed: 53 additions & 1212 deletions

src/agent-client-protocol-conductor/src/conductor.rs

Lines changed: 10 additions & 235 deletions
Original file line numberDiff line numberDiff line change
@@ -110,39 +110,27 @@
110110
//! - Modified `InitializeRequest` to forward downstream
111111
//! - `Vec<ConnectionTo>` of spawned components
112112
113-
use std::{collections::HashMap, sync::Arc};
113+
use std::sync::Arc;
114114

115115
use agent_client_protocol::{
116116
Agent, BoxFuture, Client, Conductor, ConnectTo, Dispatch, DynConnectTo, Error, JsonRpcMessage,
117117
Proxy, Role, RunWithConnectionTo, role::HasPeer, util::MatchDispatch,
118118
};
119119
use agent_client_protocol::{
120-
Builder, ConnectionTo, JsonRpcNotification, JsonRpcRequest, SentRequest, UntypedMessage,
120+
Builder, ConnectionTo, JsonRpcNotification, JsonRpcRequest, SentRequest,
121121
};
122122
use agent_client_protocol::{
123123
HandleDispatchFrom,
124-
schema::{InitializeProxyRequest, InitializeRequest, NewSessionRequest},
124+
schema::{InitializeProxyRequest, InitializeRequest},
125125
util::MatchDispatchFrom,
126126
};
127-
use agent_client_protocol::{
128-
Handled,
129-
schema::{
130-
McpConnectRequest, McpConnectResponse, McpDisconnectNotification, McpOverAcpMessage,
131-
SuccessorMessage,
132-
},
133-
};
127+
use agent_client_protocol::{Handled, schema::SuccessorMessage};
134128
use futures::{
135129
SinkExt, StreamExt,
136130
channel::mpsc::{self},
137131
};
138132
use tracing::{debug, info};
139133

140-
use crate::conductor::mcp_bridge::{
141-
McpBridgeConnection, McpBridgeConnectionActor, McpBridgeListeners,
142-
};
143-
144-
mod mcp_bridge;
145-
146134
/// The conductor manages the proxy chain lifecycle and message routing.
147135
///
148136
/// It maintains connections to all components in the chain and routes messages
@@ -153,22 +141,15 @@ pub struct ConductorImpl<Host: ConductorHostRole> {
153141
host: Host,
154142
name: String,
155143
instantiator: Host::Instantiator,
156-
mcp_bridge_mode: crate::McpBridgeMode,
157144
trace_writer: Option<crate::trace::TraceWriter>,
158145
}
159146

160147
impl<Host: ConductorHostRole> ConductorImpl<Host> {
161-
pub fn new(
162-
host: Host,
163-
name: impl ToString,
164-
instantiator: Host::Instantiator,
165-
mcp_bridge_mode: crate::McpBridgeMode,
166-
) -> Self {
148+
pub fn new(host: Host, name: impl ToString, instantiator: Host::Instantiator) -> Self {
167149
ConductorImpl {
168150
name: name.to_string(),
169151
host,
170152
instantiator,
171-
mcp_bridge_mode,
172153
trace_writer: None,
173154
}
174155
}
@@ -179,20 +160,15 @@ impl ConductorImpl<Agent> {
179160
pub fn new_agent(
180161
name: impl ToString,
181162
instantiator: impl InstantiateProxiesAndAgent + 'static,
182-
mcp_bridge_mode: crate::McpBridgeMode,
183163
) -> Self {
184-
ConductorImpl::new(Agent, name, Box::new(instantiator), mcp_bridge_mode)
164+
ConductorImpl::new(Agent, name, Box::new(instantiator))
185165
}
186166
}
187167

188168
impl ConductorImpl<Proxy> {
189169
/// Create a conductor in proxy mode (forwards to another conductor).
190-
pub fn new_proxy(
191-
name: impl ToString,
192-
instantiator: impl InstantiateProxies + 'static,
193-
mcp_bridge_mode: crate::McpBridgeMode,
194-
) -> Self {
195-
ConductorImpl::new(Proxy, name, Box::new(instantiator), mcp_bridge_mode)
170+
pub fn new_proxy(name: impl ToString, instantiator: impl InstantiateProxies + 'static) -> Self {
171+
ConductorImpl::new(Proxy, name, Box::new(instantiator))
196172
}
197173
}
198174

@@ -244,9 +220,6 @@ impl<Host: ConductorHostRole> ConductorImpl<Host> {
244220
conductor_rx,
245221
conductor_tx: conductor_tx.clone(),
246222
instantiator: Some(self.instantiator),
247-
bridge_listeners: McpBridgeListeners::default(),
248-
bridge_connections: HashMap::default(),
249-
mcp_bridge_mode: self.mcp_bridge_mode,
250223
proxies: Vec::default(),
251224
successor: Arc::new(agent_client_protocol::util::internal_error(
252225
"successor not initialized",
@@ -341,12 +314,6 @@ where
341314

342315
conductor_tx: mpsc::Sender<ConductorMessage>,
343316

344-
/// Manages the TCP listeners for MCP connections that will be proxied over ACP.
345-
bridge_listeners: McpBridgeListeners,
346-
347-
/// Manages active connections to MCP clients.
348-
bridge_connections: HashMap<String, McpBridgeConnection>,
349-
350317
/// The instantiator for lazy initialization.
351318
/// Set to None after components are instantiated.
352319
instantiator: Option<Host::Instantiator>,
@@ -361,9 +328,6 @@ where
361328
/// Populated lazily when the first Initialize request is received; the initial value just returns errors.
362329
successor: Arc<dyn ConductorSuccessor<Host>>,
363330

364-
/// Mode for the MCP bridge (determines how to spawn bridge processes).
365-
mcp_bridge_mode: crate::McpBridgeMode,
366-
367331
/// Optional trace handle for sequence diagram visualization.
368332
trace_handle: Option<crate::trace::TraceHandle>,
369333

@@ -379,10 +343,7 @@ where
379343
f.debug_struct("ConductorResponder")
380344
.field("conductor_rx", &self.conductor_rx)
381345
.field("conductor_tx", &self.conductor_tx)
382-
.field("bridge_listeners", &self.bridge_listeners)
383-
.field("bridge_connections", &self.bridge_connections)
384346
.field("proxies", &self.proxies)
385-
.field("mcp_bridge_mode", &self.mcp_bridge_mode)
386347
.field("trace_handle", &self.trace_handle)
387348
.field("host", &self.host)
388349
.finish_non_exhaustive()
@@ -470,96 +431,6 @@ where
470431
);
471432
self.send_message_to_predecessor_of(client, source_component_index, message)
472433
}
473-
474-
// New MCP connection request. Send it back along the chain to get a connection id.
475-
// When the connection id arrives, send a message back into this conductor loop with
476-
// the connection id and the (as yet unspawned) actor.
477-
ConductorMessage::McpConnectionReceived {
478-
acp_id,
479-
connection,
480-
actor,
481-
} => {
482-
// MCP connection requests always come from the agent
483-
// (we must be in agent mode, in fact), so send the MCP request
484-
// to the final proxy.
485-
self.send_request_to_predecessor_of(
486-
client,
487-
self.proxies.len(),
488-
McpConnectRequest { acp_id, meta: None },
489-
)
490-
.on_receiving_result({
491-
let mut conductor_tx = self.conductor_tx.clone();
492-
async move |result| {
493-
match result {
494-
Ok(response) => conductor_tx
495-
.send(ConductorMessage::McpConnectionEstablished {
496-
response,
497-
actor,
498-
connection,
499-
})
500-
.await
501-
.map_err(|_| agent_client_protocol::Error::internal_error()),
502-
Err(_) => {
503-
// Error occurred, just drop the connection.
504-
Ok(())
505-
}
506-
}
507-
}
508-
})
509-
}
510-
511-
// MCP connection successfully established. Spawn the actor
512-
// and insert the connection into our map for future reference.
513-
ConductorMessage::McpConnectionEstablished {
514-
response: McpConnectResponse { connection_id, .. },
515-
actor,
516-
connection,
517-
} => {
518-
self.bridge_connections
519-
.insert(connection_id.clone(), connection);
520-
client.spawn(actor.run(connection_id))
521-
}
522-
523-
// Message meant for the MCP client received. Forward it to the appropriate actor's mailbox.
524-
ConductorMessage::McpClientToMcpServer {
525-
connection_id,
526-
message,
527-
} => {
528-
let wrapped = message.map(
529-
|request, responder| {
530-
(
531-
McpOverAcpMessage {
532-
connection_id: connection_id.clone(),
533-
message: request,
534-
meta: None,
535-
},
536-
responder,
537-
)
538-
},
539-
|notification| McpOverAcpMessage {
540-
connection_id: connection_id.clone(),
541-
message: notification,
542-
meta: None,
543-
},
544-
);
545-
546-
// We only get MCP-over-ACP requests when we are in bridging MCP for the final agent,
547-
// so send them to the final proxy.
548-
self.send_message_to_predecessor_of(
549-
client,
550-
SourceComponentIndex::Successor,
551-
wrapped,
552-
)
553-
}
554-
555-
// MCP client disconnected. Remove it from our map and send the
556-
// notification backwards along the chain.
557-
ConductorMessage::McpConnectionDisconnected { notification } => {
558-
// We only get MCP-over-ACP requests when we are in bridging MCP for the final agent.
559-
560-
self.bridge_connections.remove(&notification.connection_id);
561-
self.send_notification_to_predecessor_of(client, self.proxies.len(), notification)
562-
}
563434
}
564435
}
565436

@@ -913,7 +784,7 @@ where
913784
/// running as a proxy).
914785
async fn forward_message_to_agent(
915786
&mut self,
916-
client_connection: ConnectionTo<Host::Counterpart>,
787+
_client_connection: ConnectionTo<Host::Counterpart>,
917788
message: Dispatch,
918789
agent_connection: ConnectionTo<Agent>,
919790
) -> Result<(), Error> {
@@ -925,63 +796,8 @@ where
925796
)
926797
})
927798
.await
928-
.if_request(async |mut request: NewSessionRequest, responder| {
929-
// When forwarding "session/new" to the agent,
930-
// we adjust MCP servers to manage "acp:" URLs.
931-
for mcp_server in &mut request.mcp_servers {
932-
self.bridge_listeners
933-
.transform_mcp_server(
934-
client_connection.clone(),
935-
mcp_server,
936-
&self.conductor_tx,
937-
&self.mcp_bridge_mode,
938-
)
939-
.await?;
940-
}
941-
942-
agent_connection
943-
.send_request(request)
944-
.forward_response_to(responder)
945-
})
946-
.await
947-
.if_request(
948-
async |request: McpOverAcpMessage<UntypedMessage>, responder| {
949-
let McpOverAcpMessage {
950-
connection_id,
951-
message: mcp_request,
952-
..
953-
} = request;
954-
self.bridge_connections
955-
.get_mut(&connection_id)
956-
.ok_or_else(|| {
957-
agent_client_protocol::util::internal_error(format!(
958-
"unknown connection id: {connection_id}"
959-
))
960-
})?
961-
.send(Dispatch::Request(mcp_request, responder))
962-
.await
963-
},
964-
)
965-
.await
966-
.if_notification(async |notification: McpOverAcpMessage<UntypedMessage>| {
967-
let McpOverAcpMessage {
968-
connection_id,
969-
message: mcp_notification,
970-
..
971-
} = notification;
972-
self.bridge_connections
973-
.get_mut(&connection_id)
974-
.ok_or_else(|| {
975-
agent_client_protocol::util::internal_error(format!(
976-
"unknown connection id: {connection_id}"
977-
))
978-
})?
979-
.send(Dispatch::Notification(mcp_notification))
980-
.await
981-
})
982-
.await
983799
.otherwise(async |message| {
984-
// Otherwise, just send the message along "as is".
800+
// Forward all other messages to the agent as-is.
985801
agent_connection.send_proxied_message_to(Agent, message)
986802
})
987803
.await
@@ -1276,47 +1092,6 @@ pub enum ConductorMessage {
12761092
source_component_index: SourceComponentIndex,
12771093
message: Dispatch,
12781094
},
1279-
1280-
/// A pending MCP bridge connection request request.
1281-
/// The request must be sent back over ACP to receive the connection-id.
1282-
/// Once the connection-id is received, the actor must be spawned.
1283-
McpConnectionReceived {
1284-
/// The acp:$UUID identifier for this bridge
1285-
acp_id: String,
1286-
1287-
/// The actor that should be spawned once the connection-id is available.
1288-
actor: McpBridgeConnectionActor,
1289-
1290-
/// The connection to the bridge
1291-
connection: McpBridgeConnection,
1292-
},
1293-
1294-
/// A pending MCP bridge connection request request.
1295-
/// The request must be sent back over ACP to receive the connection-id.
1296-
/// Once the connection-id is received, the actor must be spawned.
1297-
McpConnectionEstablished {
1298-
response: McpConnectResponse,
1299-
1300-
/// The actor that should be spawned once the connection-id is available.
1301-
actor: McpBridgeConnectionActor,
1302-
1303-
/// The connection to the bridge
1304-
connection: McpBridgeConnection,
1305-
},
1306-
1307-
/// MCP message (request or notification) received from a bridge that needs to be routed to the final proxy.
1308-
///
1309-
/// Sent when the bridge receives an MCP tool call from the agent and forwards it
1310-
/// to the conductor via TCP. The conductor routes this to the appropriate proxy component.
1311-
McpClientToMcpServer {
1312-
connection_id: String,
1313-
message: Dispatch,
1314-
},
1315-
1316-
/// Message sent when MCP client disconnects
1317-
McpConnectionDisconnected {
1318-
notification: McpDisconnectNotification,
1319-
},
13201095
}
13211096

13221097
/// Trait implemented for the two links the conductor can use:

0 commit comments

Comments
 (0)