diff --git a/src/config/request_context.rs b/src/config/request_context.rs index 24f48a8..a3a7566 100644 --- a/src/config/request_context.rs +++ b/src/config/request_context.rs @@ -1344,6 +1344,18 @@ impl RequestContext { Ok(()) } + pub fn edit_mcp_config(&self) -> Result<()> { + let mcp_path = paths::mcp_config_file(); + let editor = self.app.config.editor()?; + edit_file(&editor, &mcp_path)?; + println!( + "NOTE: Remember to restart {} for changes to '{}' to take effect", + env!("CARGO_CRATE_NAME"), + mcp_path.display(), + ); + Ok(()) + } + pub fn new_role(&self, app: &AppConfig, name: &str) -> Result<()> { if self.macro_flag { bail!("No role"); diff --git a/src/repl/mod.rs b/src/repl/mod.rs index e47ef9e..35ad815 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -45,7 +45,7 @@ pub const DEFAULT_CONTINUATION_PROMPT: &str = indoc! {" 4. Continue with the next pending item now. Call tools immediately." }; -static REPL_COMMANDS: LazyLock<[ReplCommand; 40]> = LazyLock::new(|| { +static REPL_COMMANDS: LazyLock<[ReplCommand; 41]> = LazyLock::new(|| { [ ReplCommand::new(".help", "Show this help guide", AssertState::pass()), ReplCommand::new(".info", "Show system info", AssertState::pass()), @@ -59,6 +59,11 @@ static REPL_COMMANDS: LazyLock<[ReplCommand; 40]> = LazyLock::new(|| { "Modify configuration file", AssertState::False(StateFlags::AGENT), ), + ReplCommand::new( + ".edit mcp-config", + "Modify the MCP servers configuration file", + AssertState::False(StateFlags::AGENT), + ), ReplCommand::new(".model", "Switch LLM model", AssertState::pass()), ReplCommand::new( ".prompt", @@ -627,8 +632,13 @@ pub async fn run_repl_command( let app = Arc::clone(&ctx.app.config); ctx.edit_agent_config(app.as_ref())?; } + Some("mcp-config") => { + ctx.edit_mcp_config()?; + } _ => { - println!(r#"Usage: .edit "#) + println!( + r#"Usage: .edit "# + ) } } } @@ -1231,8 +1241,8 @@ mod tests { } #[test] - fn repl_commands_has_40_entries() { - assert_eq!(REPL_COMMANDS.len(), 40); + fn repl_commands_has_41_entries() { + assert_eq!(REPL_COMMANDS.len(), 41); } #[test]