(config_path: &Path, tracedecay_bin: &str)
| 95 | // --------------------------------------------------------------------------- |
| 96 | |
| 97 | fn install_mcp_server(config_path: &Path, tracedecay_bin: &str) -> Result<()> { |
| 98 | if let Some(parent) = config_path.parent() { |
| 99 | std::fs::create_dir_all(parent).ok(); |
| 100 | } |
| 101 | |
| 102 | let backup = backup_config_file(config_path)?; |
| 103 | let mut settings = match load_jsonc_file_strict(config_path) { |
| 104 | Ok(v) => v, |
| 105 | Err(e) => { |
| 106 | if let Some(ref b) = backup { |
| 107 | eprintln!(" Backup preserved at: {}", b.display()); |
| 108 | } |
| 109 | return Err(e); |
| 110 | } |
| 111 | }; |
| 112 | |
| 113 | settings["mcp"]["tracedecay"] = json!({ |
| 114 | "type": "local", |
| 115 | "command": [tracedecay_bin, "serve"], |
| 116 | "enabled": true |
| 117 | }); |
| 118 | |
| 119 | safe_write_json_file(config_path, &settings, backup.as_deref())?; |
| 120 | eprintln!( |
| 121 | "\x1b[32m✔\x1b[0m Added tracedecay MCP server to {}", |
| 122 | config_path.display() |
| 123 | ); |
| 124 | Ok(()) |
| 125 | } |
| 126 | |
| 127 | fn uninstall_mcp_server(config_path: &Path) { |
| 128 | if !config_path.exists() { |
no test coverage detected