From e351ffa4b625325575e2a49e8b554e45c1c73b88 Mon Sep 17 00:00:00 2001 From: jif Date: Tue, 24 Nov 2026 11:12:02 +0000 Subject: [PATCH] Remove the legacy test-only `/mcp` renderer (#63639) ## Why The TUI renders `/mcp` from app-server `McpServerStatus` responses. The legacy renderer's snapshot still exercises grouping by qualified tool name, a path the command no longer uses. ## What changed Delete the legacy renderer, its hyphenated-server-name snapshot test and fixtures, and the TUI's `codex-mcp` dev-dependency. GitOrigin-RevId: 69f1601f19b34576ea2d9dcebdd2bfb30f414d99 --- codex-rs/Cargo.lock | 1 - codex-rs/tui/Cargo.toml | 1 - codex-rs/tui/src/history_cell/mcp.rs | 174 ------------------ codex-rs/tui/src/history_cell/mod.rs | 6 - ...sts_tools_for_hyphenated_server_names.snap | 16 -- codex-rs/tui/src/history_cell/tests.rs | 92 --------- 6 files changed, 290 deletions(-) delete mode 100644 codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__mcp_tools_output_lists_tools_for_hyphenated_server_names.snap diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lock index 286a6d05bc..9c6036be18 100644 --- a/codex-rs/Cargo.lock +++ b/codex-rs/Cargo.lock @@ -5396,7 +5396,6 @@ dependencies = [ "codex-http-client", "codex-install-context", "codex-login", - "codex-mcp", "codex-mermaid", "codex-message-history", "codex-model-provider", diff --git a/codex-rs/tui/Cargo.toml b/codex-rs/tui/Cargo.toml index 79ae4afa11..7eeee0a149 100644 --- a/codex-rs/tui/Cargo.toml +++ b/codex-rs/tui/Cargo.toml @@ -183,7 +183,6 @@ arboard = { workspace = true } [dev-dependencies] app_test_support = { workspace = true } -codex-mcp = { workspace = true } codex-protocol-test-support = { workspace = true } codex-skills = { workspace = true } core_test_support = { workspace = true } diff --git a/codex-rs/tui/src/history_cell/mcp.rs b/codex-rs/tui/src/history_cell/mcp.rs index 4939d18a0d..3180c5c498 100644 --- a/codex-rs/tui/src/history_cell/mcp.rs +++ b/codex-rs/tui/src/history_cell/mcp.rs @@ -462,180 +462,6 @@ pub(crate) fn empty_mcp_output() -> WebHyperlinkHistoryCell { WebHyperlinkHistoryCell::new_hyperlink_lines(lines) } -#[cfg(test)] -/// Render MCP tools grouped by connection using the fully-qualified tool names. -pub(crate) fn new_mcp_tools_output( - config: &Config, - tools: HashMap, - resources: HashMap>, - resource_templates: HashMap>, - auth_statuses: &HashMap, -) -> PlainHistoryCell { - let mut lines: Vec> = vec![ - "/mcp".magenta().into(), - "".into(), - vec!["🔌 ".into(), "MCP Tools".bold()].into(), - "".into(), - ]; - - if tools.is_empty() { - lines.push(" • No MCP tools available.".italic().into()); - lines.push("".into()); - } - - let effective_servers = config.mcp_servers.get().clone(); - let mut servers: Vec<_> = effective_servers.iter().collect(); - servers.sort_by_key(|(server, _)| *server); - - for (server, cfg) in servers { - let prefix = qualified_mcp_tool_name_prefix(server); - let mut names: Vec = tools - .keys() - .filter(|k| k.starts_with(&prefix)) - .map(|k| k[prefix.len()..].to_string()) - .collect(); - names.sort(); - - let auth_status = auth_statuses - .get(server.as_str()) - .copied() - .unwrap_or(McpAuthStatus::Unsupported); - let mut header: Vec> = vec![" • ".into(), server.clone().into()]; - if !cfg.enabled { - header.push(" ".into()); - header.push("(disabled)".red()); - lines.push(header.into()); - if let Some(reason) = cfg.disabled_reason.as_ref().map(ToString::to_string) { - lines.push(vec![" • Reason: ".into(), reason.dim()].into()); - } - lines.push(Line::from("")); - continue; - } - lines.push(header.into()); - lines.push(vec![" • Status: ".into(), "enabled".green()].into()); - lines.push( - vec![ - " • Auth: ".into(), - mcp_auth_status_label(auth_status).into(), - ] - .into(), - ); - - match &cfg.transport { - McpServerTransportConfig::Stdio { - command, - args, - env, - env_vars, - cwd, - } => { - let args_suffix = if args.is_empty() { - String::new() - } else { - format!(" {}", args.join(" ")) - }; - let cmd_display = format!("{command}{args_suffix}"); - lines.push(vec![" • Command: ".into(), cmd_display.into()].into()); - - if let Some(cwd) = cwd.as_ref() { - lines.push(vec![" • Cwd: ".into(), cwd.to_string().into()].into()); - } - - let env_display = format_env_display(env.as_ref(), env_vars); - if env_display != "-" { - lines.push(vec![" • Env: ".into(), env_display.into()].into()); - } - } - McpServerTransportConfig::StreamableHttp { - url, - http_headers, - env_http_headers, - .. - } => { - lines.push(vec![" • URL: ".into(), url.clone().into()].into()); - if let Some(headers) = http_headers.as_ref() - && !headers.is_empty() - { - let mut pairs: Vec<_> = headers.iter().collect(); - pairs.sort_by_key(|(name, _)| *name); - let display = pairs - .into_iter() - .map(|(name, _)| format!("{name}=*****")) - .collect::>() - .join(", "); - lines.push(vec![" • HTTP headers: ".into(), display.into()].into()); - } - if let Some(headers) = env_http_headers.as_ref() - && !headers.is_empty() - { - let mut pairs: Vec<_> = headers.iter().collect(); - pairs.sort_by_key(|(name, _)| *name); - let display = pairs - .into_iter() - .map(|(name, var)| format!("{name}={var}")) - .collect::>() - .join(", "); - lines.push(vec![" • Env HTTP headers: ".into(), display.into()].into()); - } - } - } - - if names.is_empty() { - lines.push(" • Tools: (none)".into()); - } else { - lines.push(vec![" • Tools: ".into(), names.join(", ").into()].into()); - } - - let server_resources: Vec = - resources.get(server.as_str()).cloned().unwrap_or_default(); - if server_resources.is_empty() { - lines.push(" • Resources: (none)".into()); - } else { - let mut spans: Vec> = vec![" • Resources: ".into()]; - - for (idx, resource) in server_resources.iter().enumerate() { - if idx > 0 { - spans.push(", ".into()); - } - - let label = resource.title.as_ref().unwrap_or(&resource.name); - spans.push(label.clone().into()); - spans.push(" ".into()); - spans.push(format!("({})", resource.uri).dim()); - } - - lines.push(spans.into()); - } - - let server_templates: Vec = resource_templates - .get(server.as_str()) - .cloned() - .unwrap_or_default(); - if server_templates.is_empty() { - lines.push(" • Resource templates: (none)".into()); - } else { - let mut spans: Vec> = vec![" • Resource templates: ".into()]; - - for (idx, template) in server_templates.iter().enumerate() { - if idx > 0 { - spans.push(", ".into()); - } - - let label = template.title.as_ref().unwrap_or(&template.name); - spans.push(label.clone().into()); - spans.push(" ".into()); - spans.push(format!("({})", template.uri_template).dim()); - } - - lines.push(spans.into()); - } - - lines.push(Line::from("")); - } - - PlainHistoryCell { lines } -} - /// Build the `/mcp` history cell from app-server `McpServerStatus` responses. /// /// The server list comes directly from the app-server status response, sorted diff --git a/codex-rs/tui/src/history_cell/mod.rs b/codex-rs/tui/src/history_cell/mod.rs index 4940b27ecf..11e179ffef 100644 --- a/codex-rs/tui/src/history_cell/mod.rs +++ b/codex-rs/tui/src/history_cell/mod.rs @@ -56,10 +56,6 @@ use codex_app_server_protocol::McpServerStatusDetail; use codex_app_server_protocol::ToolRequestUserInputAnswer; use codex_app_server_protocol::ToolRequestUserInputQuestion; use codex_app_server_protocol::WebSearchAction; -#[cfg(test)] -use codex_config::types::McpServerTransportConfig; -#[cfg(test)] -use codex_mcp::qualified_mcp_tool_name_prefix; use codex_otel::RuntimeMetricsSummary; use codex_protocol::account::PlanType; use codex_protocol::approvals::ExecPolicyAmendment; @@ -78,8 +74,6 @@ use codex_protocol::plan_tool::StepStatus; use codex_protocol::plan_tool::UpdatePlanArgs; use codex_protocol::user_input::TextElement; use codex_utils_absolute_path::AbsolutePathBuf; -#[cfg(test)] -use codex_utils_cli::format_env_display; use ratatui::prelude::*; #[cfg(test)] use ratatui::style::Color; diff --git a/codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__mcp_tools_output_lists_tools_for_hyphenated_server_names.snap b/codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__mcp_tools_output_lists_tools_for_hyphenated_server_names.snap deleted file mode 100644 index bb30096b68..0000000000 --- a/codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__mcp_tools_output_lists_tools_for_hyphenated_server_names.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: tui/src/history_cell.rs -assertion_line: 3310 -expression: rendered ---- -/mcp - -🔌 MCP Tools - - • some-server - • Status: enabled - • Auth: Unsupported - • Command: docs-server --stdio - • Tools: lookup - • Resources: (none) - • Resource templates: (none) diff --git a/codex-rs/tui/src/history_cell/tests.rs b/codex-rs/tui/src/history_cell/tests.rs index 15cfa36139..d173bb9308 100644 --- a/codex-rs/tui/src/history_cell/tests.rs +++ b/codex-rs/tui/src/history_cell/tests.rs @@ -11,8 +11,6 @@ use crate::render::highlight::MAX_HIGHLIGHT_LINE_BYTES; use crate::session_state::ThreadSessionState; use crate::wrapping::word_wrap_lines; use codex_app_server_protocol::AskForApproval; -use codex_app_server_protocol::McpAuthStatus; -use codex_config::types::McpServerConfig; use codex_otel::RuntimeMetricTotals; use codex_otel::RuntimeMetricsSummary; use codex_protocol::ThreadId; @@ -150,56 +148,6 @@ fn streaming_agent_tail_blank_line_uses_one_viewport_row() { assert_eq!(cell.desired_height(/*width*/ 80), 3); } -fn stdio_server_config( - command: &str, - args: Vec<&str>, - env: Option>, - env_vars: Vec<&str>, -) -> McpServerConfig { - let mut table = toml::Table::new(); - table.insert( - "command".to_string(), - toml::Value::String(command.to_string()), - ); - if !args.is_empty() { - table.insert( - "args".to_string(), - toml::Value::Array( - args.into_iter() - .map(|arg| toml::Value::String(arg.to_string())) - .collect(), - ), - ); - } - if let Some(env) = env { - table.insert("env".to_string(), string_map_to_toml_value(env)); - } - if !env_vars.is_empty() { - table.insert( - "env_vars".to_string(), - toml::Value::Array( - env_vars - .into_iter() - .map(|name| toml::Value::String(name.to_string())) - .collect(), - ), - ); - } - - toml::Value::Table(table) - .try_into() - .expect("test stdio MCP config should deserialize") -} - -fn string_map_to_toml_value(entries: HashMap) -> toml::Value { - toml::Value::Table( - entries - .into_iter() - .map(|(key, value)| (key, toml::Value::String(value))) - .collect(), - ) -} - fn render_lines(lines: &[Line<'static>]) -> Vec { lines .iter() @@ -1045,46 +993,6 @@ unset it, then restart Codex" insta::assert_snapshot!(rendered); } -#[tokio::test] -async fn mcp_tools_output_lists_tools_for_hyphenated_server_names() { - let mut config = test_config().await; - let mut servers = config.mcp_servers.get().clone(); - servers.insert( - "some-server".to_string(), - stdio_server_config("docs-server", vec!["--stdio"], /*env*/ None, vec![]), - ); - config - .mcp_servers - .set(servers) - .expect("test mcp servers should accept any configuration"); - - let tools = HashMap::from([( - "mcp__some_server__lookup".to_string(), - Tool { - description: None, - name: "lookup".to_string(), - title: None, - input_schema: serde_json::json!({"type": "object", "properties": {}}), - output_schema: None, - annotations: None, - icons: None, - meta: None, - }, - )]); - - let auth_statuses: HashMap = HashMap::new(); - let cell = new_mcp_tools_output( - &config, - tools, - HashMap::new(), - HashMap::new(), - &auth_statuses, - ); - let rendered = render_lines(&cell.display_lines(/*width*/ 120)).join("\n"); - - insta::assert_snapshot!(rendered); -} - #[test] fn mcp_tools_output_from_statuses_renders_status_only_servers() { let statuses = vec![McpServerStatus {