From 39408d495410d881975240d8f79791a56c51668f Mon Sep 17 00:00:00 2001 From: 963enkidu Date: Thu, 23 Apr 2026 20:41:03 +0200 Subject: [PATCH 1/2] feat(mcp): add enable and disable commands --- crates/forge_domain/src/mcp.rs | 8 ++++++++ crates/forge_main/src/cli.rs | 26 ++++++++++++++++++++++++++ crates/forge_main/src/ui.rs | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) diff --git a/crates/forge_domain/src/mcp.rs b/crates/forge_domain/src/mcp.rs index 53afe53725..f4f254690a 100644 --- a/crates/forge_domain/src/mcp.rs +++ b/crates/forge_domain/src/mcp.rs @@ -56,6 +56,14 @@ impl McpServerConfig { } } + /// Set the disabled state of this server. + pub fn set_disable(&mut self, disabled: bool) { + match self { + McpServerConfig::Stdio(v) => v.disable = disabled, + McpServerConfig::Http(v) => v.disable = disabled, + } + } + /// Returns the type of MCP server as a string ("STDIO" or "HTTP") pub fn server_type(&self) -> &'static str { match self { diff --git a/crates/forge_main/src/cli.rs b/crates/forge_main/src/cli.rs index 1af889ab80..861bb36301 100644 --- a/crates/forge_main/src/cli.rs +++ b/crates/forge_main/src/cli.rs @@ -439,6 +439,12 @@ pub enum McpCommand { /// Remove stored OAuth credentials for an MCP server. Logout(McpLogoutArgs), + + /// Enable a disabled MCP server. + Enable(McpEnableArgs), + + /// Disable an MCP server. + Disable(McpDisableArgs), } #[derive(Parser, Debug, Clone)] @@ -481,6 +487,26 @@ pub struct McpLogoutArgs { pub name: String, } +#[derive(Parser, Debug, Clone)] +pub struct McpEnableArgs { + /// Name of the MCP server to enable. + pub name: String, + + /// Configuration scope. + #[arg(short = 's', long = "scope", default_value = "local")] + pub scope: Scope, +} + +#[derive(Parser, Debug, Clone)] +pub struct McpDisableArgs { + /// Name of the MCP server to disable. + pub name: String, + + /// Configuration scope. + #[arg(short = 's', long = "scope", default_value = "local")] + pub scope: Scope, +} + /// Configuration scope for settings. #[derive(Copy, Clone, Debug, ValueEnum, Default)] pub enum Scope { diff --git a/crates/forge_main/src/ui.rs b/crates/forge_main/src/ui.rs index 6605f56813..d5015d362b 100644 --- a/crates/forge_main/src/ui.rs +++ b/crates/forge_main/src/ui.rs @@ -567,6 +567,40 @@ impl A + Send + Sync> UI McpCommand::Logout(args) => { self.handle_mcp_logout(&args.name).await?; } + McpCommand::Enable(args) => { + let name = forge_api::ServerName::from(args.name.clone()); + let scope: forge_domain::Scope = args.scope.into(); + + // Read scope-specific config + let mut scope_config = self.api.read_mcp_config(Some(&scope)).await?; + + // Find and enable the server + if let Some(server) = scope_config.mcp_servers.get_mut(&name) { + server.set_disable(false); + self.api.write_mcp_config(&scope, &scope_config).await?; + self.api.reload_mcp().await?; + self.writeln_title(TitleFormat::info(format!("Enabled MCP server: {}", args.name)))?; + } else { + self.writeln_title(TitleFormat::error(format!("Server '{}' not found", args.name)))?; + } + } + McpCommand::Disable(args) => { + let name = forge_api::ServerName::from(args.name.clone()); + let scope: forge_domain::Scope = args.scope.into(); + + // Read scope-specific config + let mut scope_config = self.api.read_mcp_config(Some(&scope)).await?; + + // Find and disable the server + if let Some(server) = scope_config.mcp_servers.get_mut(&name) { + server.set_disable(true); + self.api.write_mcp_config(&scope, &scope_config).await?; + self.api.reload_mcp().await?; + self.writeln_title(TitleFormat::info(format!("Disabled MCP server: {}", args.name)))?; + } else { + self.writeln_title(TitleFormat::error(format!("Server '{}' not found", args.name)))?; + } + } }, TopLevelCommand::Info { porcelain, conversation_id } => { // Only initialize state (agent/provider/model resolution). From 351db81887a0793b6028991458527108bb8d2b19 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 07:25:39 +0000 Subject: [PATCH 2/2] [autofix.ci] apply automated fixes --- crates/forge_main/src/ui.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/crates/forge_main/src/ui.rs b/crates/forge_main/src/ui.rs index d5015d362b..f477585a43 100644 --- a/crates/forge_main/src/ui.rs +++ b/crates/forge_main/src/ui.rs @@ -579,9 +579,15 @@ impl A + Send + Sync> UI server.set_disable(false); self.api.write_mcp_config(&scope, &scope_config).await?; self.api.reload_mcp().await?; - self.writeln_title(TitleFormat::info(format!("Enabled MCP server: {}", args.name)))?; + self.writeln_title(TitleFormat::info(format!( + "Enabled MCP server: {}", + args.name + )))?; } else { - self.writeln_title(TitleFormat::error(format!("Server '{}' not found", args.name)))?; + self.writeln_title(TitleFormat::error(format!( + "Server '{}' not found", + args.name + )))?; } } McpCommand::Disable(args) => { @@ -596,9 +602,15 @@ impl A + Send + Sync> UI server.set_disable(true); self.api.write_mcp_config(&scope, &scope_config).await?; self.api.reload_mcp().await?; - self.writeln_title(TitleFormat::info(format!("Disabled MCP server: {}", args.name)))?; + self.writeln_title(TitleFormat::info(format!( + "Disabled MCP server: {}", + args.name + )))?; } else { - self.writeln_title(TitleFormat::error(format!("Server '{}' not found", args.name)))?; + self.writeln_title(TitleFormat::error(format!( + "Server '{}' not found", + args.name + )))?; } } },