MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / uninstall_mcp_server

Function uninstall_mcp_server

src/agents/roo_code.rs:121–170  ·  view source on GitHub ↗

Remove MCP server entry from Roo Code's `cline_mcp_settings.json`.

(settings_path: &Path)

Source from the content-addressed store, hash-verified

119
120/// Remove MCP server entry from Roo Code's `cline_mcp_settings.json`.
121fn uninstall_mcp_server(settings_path: &Path) {
122 if !settings_path.exists() {
123 eprintln!(" {} not found, skipping", settings_path.display());
124 return;
125 }
126
127 let Ok(contents) = std::fs::read_to_string(settings_path) else {
128 return;
129 };
130 let Ok(mut settings) = serde_json::from_str::<serde_json::Value>(&contents) else {
131 return;
132 };
133
134 let Some(servers) = settings
135 .get_mut("mcpServers")
136 .and_then(|v| v.as_object_mut())
137 else {
138 eprintln!(
139 " No tracedecay MCP server in {}, skipping",
140 settings_path.display()
141 );
142 return;
143 };
144
145 if servers.remove("tracedecay").is_none() {
146 eprintln!(
147 " No tracedecay MCP server in {}, skipping",
148 settings_path.display()
149 );
150 return;
151 }
152
153 let is_empty = settings.as_object().is_some_and(|o| {
154 o.iter()
155 .all(|(k, v)| k == "mcpServers" && v.as_object().is_some_and(serde_json::Map::is_empty))
156 });
157
158 if is_empty {
159 std::fs::remove_file(settings_path).ok();
160 eprintln!(
161 "\x1b[32m✔\x1b[0m Removed {} (was empty)",
162 settings_path.display()
163 );
164 } else if backup_and_write_json(settings_path, &settings) {
165 eprintln!(
166 "\x1b[32m✔\x1b[0m Removed tracedecay MCP server from {}",
167 settings_path.display()
168 );
169 }
170}
171
172// ---------------------------------------------------------------------------
173// Healthcheck helpers

Callers 1

uninstallMethod · 0.70

Calls 2

backup_and_write_jsonFunction · 0.85
existsMethod · 0.80

Tested by

no test coverage detected