Remove MCP server from ~/.codex/config.toml.
(config_path: &Path)
| 1178 | |
| 1179 | /// Remove MCP server from ~/.codex/config.toml. |
| 1180 | fn uninstall_mcp_server(config_path: &Path) -> Result<()> { |
| 1181 | if !config_path.exists() { |
| 1182 | return Ok(()); |
| 1183 | } |
| 1184 | let mut config = load_toml_file(config_path)?; |
| 1185 | let Some(table) = config.as_table_mut() else { |
| 1186 | return Ok(()); |
| 1187 | }; |
| 1188 | let Some(servers) = table.get_mut("mcp_servers").and_then(|v| v.as_table_mut()) else { |
| 1189 | return Ok(()); |
| 1190 | }; |
| 1191 | let removed = servers.remove("tracedecay").is_some(); |
| 1192 | if !removed { |
| 1193 | eprintln!( |
| 1194 | " No tracedecay MCP server in {}, skipping", |
| 1195 | config_path.display() |
| 1196 | ); |
| 1197 | return Ok(()); |
| 1198 | } |
| 1199 | if servers.is_empty() { |
| 1200 | table.remove("mcp_servers"); |
| 1201 | } |
| 1202 | if table.is_empty() { |
| 1203 | let _ = super::backup_file(config_path); |
| 1204 | std::fs::remove_file(config_path).ok(); |
| 1205 | eprintln!( |
| 1206 | "\x1b[32m✔\x1b[0m Removed {} (was empty)", |
| 1207 | config_path.display() |
| 1208 | ); |
| 1209 | } else { |
| 1210 | write_toml_file(config_path, &config)?; |
| 1211 | eprintln!( |
| 1212 | "\x1b[32m✔\x1b[0m Removed tracedecay MCP server from {}", |
| 1213 | config_path.display() |
| 1214 | ); |
| 1215 | } |
| 1216 | Ok(()) |
| 1217 | } |
| 1218 | |
| 1219 | /// Remove tracedecay rules from AGENTS.md. |
| 1220 | fn uninstall_prompt_rules(agents_md: &Path) { |
no test coverage detected