feat: merge MCP config when installing bundled mcp config
This commit is contained in:
+4
-3
@@ -445,9 +445,10 @@ fn confirm_asset_overwrite(category: AssetCategory, label: &str, target: &Path)
|
||||
}
|
||||
let body = match category {
|
||||
AssetCategory::McpConfig => format!(
|
||||
"This replaces your MCP server configuration at {} with this \
|
||||
build's bundled template. Your configured MCP servers (and any \
|
||||
custom secret references they contain) will be lost.",
|
||||
"This merges the bundled MCP server template into your configuration \
|
||||
at {}. New servers from the bundled template will be added; any \
|
||||
MCP servers you have already configured (including custom secret \
|
||||
references) are left untouched.",
|
||||
target.display()
|
||||
),
|
||||
_ => format!(
|
||||
|
||||
@@ -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"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user