From 1c6b4712a3f53c924c2f4d51fe288e629a309e48 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Wed, 25 Jun 2025 11:48:38 +0200 Subject: [PATCH] agent: Fix issue where unconfigured MCP extensions would not start server (#33365) Release Notes: - agent: Fix an issue where MCP servers that were provided by extensions would sometimes not start up --- .../agent_configuration/configure_context_server_modal.rs | 5 +---- crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs | 5 ++++- crates/project/src/context_server_store.rs | 5 +---- crates/project/src/project_settings.rs | 7 +++++++ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs b/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs index 6a0bd765c7969b910b321826c0ca44dc92fd82a9..30fad51cfcbc100bdf469278c0210a220c7e2833 100644 --- a/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs +++ b/crates/agent_ui/src/agent_configuration/configure_context_server_modal.rs @@ -295,10 +295,7 @@ impl ConfigureContextServerModal { ContextServerDescriptorRegistry::default_global(cx) .read(cx) .context_server_descriptor(&server_id.0) - .map(|_| ContextServerSettings::Extension { - enabled: true, - settings: serde_json::json!({}), - }) + .map(|_| ContextServerSettings::default_extension()) }) else { return Task::ready(Err(anyhow::anyhow!("Context server not found"))); diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs index a85e48226b7aacd9c29df89691c4bf620c86e7cf..f8f9ae1977687296790a562711c286e2fce026e4 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs @@ -945,7 +945,10 @@ impl ExtensionImports for WasmState { .get(key.as_str()) }) .cloned() - .context("Failed to get context server configuration")?; + .unwrap_or_else(|| { + project::project_settings::ContextServerSettings::default_extension( + ) + }); match settings { project::project_settings::ContextServerSettings::Custom { diff --git a/crates/project/src/context_server_store.rs b/crates/project/src/context_server_store.rs index 36213f96c4aefe946aafa92024c55d0092eeda4c..3bde9d6b36b42fe30aaf0f0fce903c3c0e373f3f 100644 --- a/crates/project/src/context_server_store.rs +++ b/crates/project/src/context_server_store.rs @@ -505,10 +505,7 @@ impl ContextServerStore { { configured_servers .entry(id) - .or_insert(ContextServerSettings::Extension { - enabled: true, - settings: serde_json::json!({}), - }); + .or_insert(ContextServerSettings::default_extension()); } let (enabled_servers, disabled_servers): (HashMap<_, _>, HashMap<_, _>) = diff --git a/crates/project/src/project_settings.rs b/crates/project/src/project_settings.rs index 3f584f969783ca5ac107f592a02c824de5147539..19029cdb1d1c6b567a1d651a9aadfb8c7f8808c7 100644 --- a/crates/project/src/project_settings.rs +++ b/crates/project/src/project_settings.rs @@ -111,6 +111,13 @@ pub enum ContextServerSettings { } impl ContextServerSettings { + pub fn default_extension() -> Self { + Self::Extension { + enabled: true, + settings: serde_json::json!({}), + } + } + pub fn enabled(&self) -> bool { match self { ContextServerSettings::Custom { enabled, .. } => *enabled,