Skip to content

Commit e7e336e

Browse files
committed
fix(tui): add mcp list and remove slash entries
1 parent 7954d02 commit e7e336e

4 files changed

Lines changed: 38 additions & 10 deletions

File tree

src/cortex-tui/src/commands/executor/dispatch.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ impl CommandExecutor {
9797
// All MCP commands redirect to the interactive panel
9898
"mcp" => self.cmd_mcp(cmd),
9999
"mcp-tools" | "tools" | "lt" => CommandResult::OpenModal(ModalType::McpManager),
100+
"mcp-list" | "mcp-ls" => CommandResult::OpenModal(ModalType::McpManager),
100101
"mcp-auth" | "auth" => CommandResult::OpenModal(ModalType::McpManager),
102+
"mcp-remove" | "mcp-rm" => CommandResult::OpenModal(ModalType::McpManager),
101103
"mcp-reload" => CommandResult::OpenModal(ModalType::McpManager),
102104
"mcp-logs" => CommandResult::OpenModal(ModalType::McpManager),
103105

src/cortex-tui/src/commands/executor/tests.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,14 @@ fn test_mcp_subcommands() {
316316
CommandResult::OpenModal(ModalType::McpManager)
317317
));
318318

319+
for command in &["/mcp-list", "/mcp-ls", "/mcp-remove", "/mcp-rm"] {
320+
let result = executor.execute_str(command);
321+
assert!(matches!(
322+
result,
323+
CommandResult::OpenModal(ModalType::McpManager)
324+
));
325+
}
326+
319327
// All mcp subcommands now redirect to the interactive panel
320328
let result = executor.execute_str("/mcp status");
321329
assert!(matches!(

src/cortex-tui/src/commands/registry/builtin.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,15 @@ pub fn register_builtin_commands(registry: &mut CommandRegistry) {
581581
false,
582582
));
583583

584+
registry.register(CommandDef::new(
585+
"mcp-list",
586+
&["mcp-ls"],
587+
"List configured MCP servers",
588+
"/mcp-list",
589+
CommandCategory::Mcp,
590+
false,
591+
));
592+
584593
registry.register(CommandDef::new(
585594
"mcp-auth",
586595
&["auth"],
@@ -590,6 +599,15 @@ pub fn register_builtin_commands(registry: &mut CommandRegistry) {
590599
false,
591600
));
592601

602+
registry.register(CommandDef::new(
603+
"mcp-remove",
604+
&["mcp-rm"],
605+
"Remove an MCP server",
606+
"/mcp-remove",
607+
CommandCategory::Mcp,
608+
true,
609+
));
610+
593611
registry.register(CommandDef::new(
594612
"mcp-reload",
595613
&[],

src/cortex-tui/src/commands/registry/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,15 @@ mod tests {
7878

7979
let general = registry.get_by_category(CommandCategory::General);
8080
assert!(!general.is_empty());
81-
assert!(
82-
general
83-
.iter()
84-
.all(|cmd| cmd.category == CommandCategory::General)
85-
);
81+
assert!(general
82+
.iter()
83+
.all(|cmd| cmd.category == CommandCategory::General));
8684

8785
let session = registry.get_by_category(CommandCategory::Session);
8886
assert!(!session.is_empty());
89-
assert!(
90-
session
91-
.iter()
92-
.all(|cmd| cmd.category == CommandCategory::Session)
93-
);
87+
assert!(session
88+
.iter()
89+
.all(|cmd| cmd.category == CommandCategory::Session));
9490
}
9591

9692
#[test]
@@ -194,7 +190,11 @@ mod tests {
194190
// MCP
195191
assert!(registry.exists("mcp"));
196192
assert!(registry.exists("mcp-tools"));
193+
assert!(registry.exists("mcp-list"));
194+
assert!(registry.exists("mcp-ls"));
197195
assert!(registry.exists("mcp-auth"));
196+
assert!(registry.exists("mcp-remove"));
197+
assert!(registry.exists("mcp-rm"));
198198
assert!(registry.exists("mcp-reload"));
199199

200200
// Auth

0 commit comments

Comments
 (0)