From 83e5a3033e77347e8c1dd968c0f5c3822f6dc0de Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 30 Sep 2025 15:34:42 -0600 Subject: [PATCH] Don't run MCP servers for remote projects (#39243) Closes #39213 Release Notes: - Fixed a bug where we tried to run MCP servers in the remote project's working directory on the local machine --- crates/project/src/context_server_store.rs | 31 +++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/crates/project/src/context_server_store.rs b/crates/project/src/context_server_store.rs index e4673744da6883a5aa298c2fca3a39f556cb1357..e358ddfbf51a362d95b8b75a9b4831ca4089875d 100644 --- a/crates/project/src/context_server_store.rs +++ b/crates/project/src/context_server_store.rs @@ -472,22 +472,23 @@ impl ContextServerStore { configuration: Arc, cx: &mut Context, ) -> Arc { - let root_path = self - .project - .read_with(cx, |project, cx| project.active_project_directory(cx)) - .ok() - .flatten() - .or_else(|| { - self.worktree_store.read_with(cx, |store, cx| { - store.visible_worktrees(cx).fold(None, |acc, item| { - if acc.is_none() { - item.read(cx).root_dir() - } else { - acc + let project = self.project.upgrade(); + let mut root_path = None; + if let Some(project) = project { + let project = project.read(cx); + if project.is_local() { + if let Some(path) = project.active_project_directory(cx) { + root_path = Some(path); + } else { + for worktree in self.worktree_store.read(cx).visible_worktrees(cx) { + if let Some(path) = worktree.read(cx).root_dir() { + root_path = Some(path); + break; } - }) - }) - }); + } + } + } + }; if let Some(factory) = self.context_server_factory.as_ref() { factory(id, configuration)