diff --git a/src/cortex-tui/src/modal/mcp_manager/handlers.rs b/src/cortex-tui/src/modal/mcp_manager/handlers.rs index 81683d924..f69b17b0f 100644 --- a/src/cortex-tui/src/modal/mcp_manager/handlers.rs +++ b/src/cortex-tui/src/modal/mcp_manager/handlers.rs @@ -141,6 +141,7 @@ impl McpManagerModal { command: String::new(), args: String::new(), focus: AddStdioServerFocus::Name, + error: None, }; } else { // HTTP transport @@ -171,6 +172,7 @@ impl McpManagerModal { ref mut command, ref mut args, ref mut focus, + ref mut error, } = self.mode { match key.code { @@ -180,6 +182,7 @@ impl McpManagerModal { AddStdioServerFocus::Command => AddStdioServerFocus::Args, AddStdioServerFocus::Args => AddStdioServerFocus::Name, }; + *error = None; // Clear error on field switch ModalResult::Continue } KeyCode::BackTab => { @@ -200,6 +203,15 @@ impl McpManagerModal { args: args_vec, }); } + // Set error message for empty required fields + let err_msg = if name.is_empty() && command.is_empty() { + "Error: Name and Command are required" + } else if name.is_empty() { + "Error: Server name is required" + } else { + "Error: Command is required" + }; + *error = Some(err_msg.to_string()); ModalResult::Continue } KeyCode::Esc => { @@ -211,6 +223,7 @@ impl McpManagerModal { ModalResult::Continue } KeyCode::Char(c) => { + *error = None; // Clear error when user starts typing match focus { AddStdioServerFocus::Name => name.push(c), AddStdioServerFocus::Command => command.push(c), diff --git a/src/cortex-tui/src/modal/mcp_manager/mod.rs b/src/cortex-tui/src/modal/mcp_manager/mod.rs index f95ab7e56..f8dfcf01f 100644 --- a/src/cortex-tui/src/modal/mcp_manager/mod.rs +++ b/src/cortex-tui/src/modal/mcp_manager/mod.rs @@ -34,6 +34,7 @@ impl Modal for McpManagerModal { command, args, focus, + error: _, } => { match focus { AddStdioServerFocus::Name => name.push_str(text), diff --git a/src/cortex-tui/src/modal/mcp_manager/rendering.rs b/src/cortex-tui/src/modal/mcp_manager/rendering.rs index 8ed345b30..0fba94cab 100644 --- a/src/cortex-tui/src/modal/mcp_manager/rendering.rs +++ b/src/cortex-tui/src/modal/mcp_manager/rendering.rs @@ -302,12 +302,13 @@ impl McpManagerModal { ref command, ref args, focus, + ref error, } = self.mode { Clear.render(area, buf); let block = Block::default() - .title(" Add MCP Server ") + .title(" Add MCP Server - Stdio ") .borders(Borders::ALL) .border_style(Style::default().fg(CYAN_PRIMARY)) .style(Style::default().bg(SURFACE_1)); @@ -408,6 +409,12 @@ impl McpManagerModal { .hint("Enter", "save") .hint("Esc", "back"); form_bar.render(chunks[4], buf); + + // Render submission error message if present + if let Some(ref err_msg) = error { + let error_style = Style::default().fg(ERROR); + buf.set_string(chunks[4].x, chunks[4].y.saturating_sub(1), err_msg, error_style); + } } } diff --git a/src/cortex-tui/src/modal/mcp_manager/types.rs b/src/cortex-tui/src/modal/mcp_manager/types.rs index f7ec63c60..a2c1f02f0 100644 --- a/src/cortex-tui/src/modal/mcp_manager/types.rs +++ b/src/cortex-tui/src/modal/mcp_manager/types.rs @@ -112,6 +112,8 @@ pub enum McpMode { command: String, args: String, focus: AddStdioServerFocus, + /// Submission error message (e.g., when required fields are empty) + error: Option, }, /// Step 3b: Adding an HTTP server AddHttpServer {