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

Function install_mcp_server

src/agents/opencode.rs:205–228  ·  view source on GitHub ↗

Register MCP server in opencode.json. Safety: creates a `.bak` backup before writing and restores it on any error. Uses strict JSON parsing so an existing file with invalid syntax is never silently replaced with an empty object.

(config_path: &Path, tracedecay_bin: &str)

Source from the content-addressed store, hash-verified

203/// error. Uses strict JSON parsing so an existing file with invalid syntax
204/// is never silently replaced with an empty object.
205fn install_mcp_server(config_path: &Path, tracedecay_bin: &str) -> Result<()> {
206 let backup = backup_config_file(config_path)?;
207 let mut config = match load_json_file_strict(config_path) {
208 Ok(v) => v,
209 Err(e) => {
210 if let Some(ref b) = backup {
211 eprintln!(" Backup preserved at: {}", b.display());
212 }
213 return Err(e);
214 }
215 };
216
217 config["mcp"]["tracedecay"] = json!({
218 "type": "local",
219 "command": [tracedecay_bin, "serve"]
220 });
221
222 safe_write_json_file(config_path, &config, backup.as_deref())?;
223 eprintln!(
224 "\x1b[32m✔\x1b[0m Added tracedecay MCP server to {}",
225 config_path.display()
226 );
227 Ok(())
228}
229
230/// Install-or-refresh prompt rules in AGENTS.md.
231fn install_prompt_rules(prompt_path: &Path) -> Result<()> {

Callers 2

installMethod · 0.70
install_localMethod · 0.70

Calls 3

backup_config_fileFunction · 0.85
load_json_file_strictFunction · 0.85
safe_write_json_fileFunction · 0.85

Tested by

no test coverage detected