Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Conrad Irwin
013ae11677 mcp over acp 2025-07-20 16:51:56 -06:00
6 changed files with 56 additions and 8 deletions

4
Cargo.lock generated
View file

@ -279,9 +279,9 @@ dependencies = [
[[package]] [[package]]
name = "agentic-coding-protocol" name = "agentic-coding-protocol"
version = "0.0.9" version = "0.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e276b798eddd02562a339340a96919d90bbfcf78de118fdddc932524646fac7" checksum = "48322590276f36cf49197898cde1c54645991c96c0c83722ef321da7f2b0ae42"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",

View file

@ -410,7 +410,7 @@ zlog_settings = { path = "crates/zlog_settings" }
# External crates # External crates
# #
agentic-coding-protocol = "0.0.9" agentic-coding-protocol = "0.0.11"
aho-corasick = "1.1" aho-corasick = "1.1"
alacritty_terminal = { git = "https://github.com/zed-industries/alacritty.git", branch = "add-hush-login-flag" } alacritty_terminal = { git = "https://github.com/zed-industries/alacritty.git", branch = "add-hush-login-flag" }
any_vec = "0.14" any_vec = "0.14"

View file

@ -869,9 +869,34 @@ impl AcpThread {
false false
} }
pub fn initialize(&self) -> impl use<> + Future<Output = Result<acp::InitializeResponse>> { pub fn initialize(
&self,
cx: &mut Context<Self>,
) -> impl use<> + Future<Output = Result<acp::InitializeResponse>> {
let context_server_store = self.project.read(cx).context_server_store().read(cx);
let mut context_servers = HashMap::new();
for id in context_server_store.all_server_ids() {
let Some(configuration) = context_server_store.configuration_for_server(&id) else {
continue;
};
let command = configuration.command();
context_servers.insert(
id.0.to_string(),
acp::ContextServer::Stdio {
command: command.path.clone(),
args: command.args.clone(),
env: command
.env
.iter()
.flatten()
.map(|(k, v)| (k.clone(), v.clone()))
.collect(),
},
);
}
self.request(acp::InitializeParams { self.request(acp::InitializeParams {
protocol_version: ProtocolVersion::latest(), protocol_version: ProtocolVersion::latest(),
context_servers,
}) })
} }
@ -1187,6 +1212,13 @@ impl acp::Client for AcpClientDelegate {
Ok(()) Ok(())
} }
async fn update_plan(
&self,
_request: agentic_coding_protocol::UpdatePlanParams,
) -> Result<(), acp::Error> {
Ok(())
}
async fn request_tool_call_confirmation( async fn request_tool_call_confirmation(
&self, &self,
request: acp::RequestToolCallConfirmationParams, request: acp::RequestToolCallConfirmationParams,

View file

@ -65,6 +65,22 @@ impl AgentServer for ClaudeCode {
let project = project.clone(); let project = project.clone();
let root_dir = root_dir.to_path_buf(); let root_dir = root_dir.to_path_buf();
let title = self.name().into(); let title = self.name().into();
let context_server_store = project.read(cx).context_server_store().read(cx);
let mut mcp_servers = HashMap::default();
for id in context_server_store.all_server_ids() {
let Some(configuration) = context_server_store.configuration_for_server(&id) else {
continue;
};
let command = configuration.command();
mcp_servers.insert(
id.0.to_string(),
McpServerConfig {
command: command.path.clone(),
args: command.args.clone(),
env: command.env.clone(),
},
);
}
cx.spawn(async move |cx| { cx.spawn(async move |cx| {
let (mut delegate_tx, delegate_rx) = watch::channel(None); let (mut delegate_tx, delegate_rx) = watch::channel(None);
let tool_id_map = Rc::new(RefCell::new(HashMap::default())); let tool_id_map = Rc::new(RefCell::new(HashMap::default()));
@ -72,11 +88,11 @@ impl AgentServer for ClaudeCode {
let permission_mcp_server = let permission_mcp_server =
ClaudeMcpServer::new(delegate_rx, tool_id_map.clone(), cx).await?; ClaudeMcpServer::new(delegate_rx, tool_id_map.clone(), cx).await?;
let mut mcp_servers = HashMap::default();
mcp_servers.insert( mcp_servers.insert(
mcp_server::SERVER_NAME.to_string(), mcp_server::SERVER_NAME.to_string(),
permission_mcp_server.server_config()?, permission_mcp_server.server_config()?,
); );
dbg!(&mcp_servers);
let mcp_config = McpConfig { mcp_servers }; let mcp_config = McpConfig { mcp_servers };
let mcp_config_file = tempfile::NamedTempFile::new()?; let mcp_config_file = tempfile::NamedTempFile::new()?;
@ -567,7 +583,7 @@ struct McpConfig {
mcp_servers: HashMap<String, McpServerConfig>, mcp_servers: HashMap<String, McpServerConfig>,
} }
#[derive(Serialize)] #[derive(Serialize, Debug)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
struct McpServerConfig { struct McpServerConfig {
command: String, command: String,

View file

@ -375,7 +375,7 @@ pub async fn new_test_thread(
.unwrap(); .unwrap();
thread thread
.update(cx, |thread, _| thread.initialize()) .update(cx, |thread, cx| thread.initialize(cx))
.await .await
.unwrap(); .unwrap();
thread thread

View file

@ -216,7 +216,7 @@ impl AcpThreadView {
let init_response = async { let init_response = async {
let resp = thread let resp = thread
.read_with(cx, |thread, _cx| thread.initialize())? .update(cx, |thread, cx| thread.initialize(cx))?
.await?; .await?;
anyhow::Ok(resp) anyhow::Ok(resp)
}; };