feat: merge MCP config when installing bundled mcp config

This commit is contained in:
2026-07-06 09:57:17 -06:00
parent d4a6a2fb34
commit af91b89cff
3 changed files with 50 additions and 14 deletions
+13 -6
View File
@@ -5175,19 +5175,26 @@ mod tests {
#[test]
#[serial]
fn install_mcp_config_overwrites_existing() {
fn install_mcp_config_merges_existing() {
let _guard = TestConfigDirGuard::new();
Functions::install_mcp_config().unwrap();
let mcp = paths::mcp_config_file();
assert!(mcp.exists(), "install_mcp_config should create mcp.json");
write(&mcp, "USER_MCP_CONFIG").unwrap();
let custom_json =
r#"{"mcpServers":{"my-custom-server":{"type":"stdio","command":"custom-cmd"}}}"#;
write(&mcp, custom_json).unwrap();
Functions::install_mcp_config().unwrap();
assert_ne!(
read_to_string(&mcp).unwrap(),
"USER_MCP_CONFIG",
"install_mcp_config must overwrite the existing mcp.json"
let result = read_to_string(&mcp).unwrap();
assert!(
result.contains("my-custom-server"),
"install_mcp_config must preserve user-added MCP servers"
);
assert!(
result.contains("github"),
"install_mcp_config must add new bundled servers"
);
}
}