fix(mcp): migrate import functions to unified v3.7.0 structure

- Rewrite import_from_claude/codex/gemini to write directly to mcp.servers
- Implement skip-on-error strategy for fault tolerance (single invalid item no longer aborts entire batch)
- Smart merge logic: existing servers only enable corresponding app, preserve other configs
- Remove deprecated markers from service layer
- Export McpApps type for test usage
- Update mcp_commands tests to use unified structure

Fixes runtime import issue where data was written to legacy structure (mcp.claude/codex.servers)
but unified panel reads from new structure (mcp.servers), causing "imported but invisible" bug.
This commit is contained in:
Jason
2025-11-14 23:33:54 +08:00
parent 09f80d82bc
commit ea8f2095e2
4 changed files with 201 additions and 212 deletions

View File

@@ -231,11 +231,7 @@ impl McpService {
Ok(())
}
/// [已废弃] 从 Claude 导入 MCP兼容旧 API
#[deprecated(
since = "3.7.0",
note = "Import will be handled differently in unified structure"
)]
/// 从 Claude 导入 MCPv3.7.0 已更新为统一结构
pub fn import_from_claude(state: &AppState) -> Result<usize, AppError> {
let mut cfg = state.config.write()?;
let count = mcp::import_from_claude(&mut cfg)?;
@@ -244,11 +240,7 @@ impl McpService {
Ok(count)
}
/// [已废弃] 从 Codex 导入 MCP兼容旧 API
#[deprecated(
since = "3.7.0",
note = "Import will be handled differently in unified structure"
)]
/// 从 Codex 导入 MCPv3.7.0 已更新为统一结构
pub fn import_from_codex(state: &AppState) -> Result<usize, AppError> {
let mut cfg = state.config.write()?;
let count = mcp::import_from_codex(&mut cfg)?;
@@ -257,11 +249,7 @@ impl McpService {
Ok(count)
}
/// [已废弃] 从 Gemini 导入 MCP兼容旧 API
#[deprecated(
since = "3.7.0",
note = "Import will be handled differently in unified structure"
)]
/// 从 Gemini 导入 MCPv3.7.0 已更新为统一结构
pub fn import_from_gemini(state: &AppState) -> Result<usize, AppError> {
let mut cfg = state.config.write()?;
let count = mcp::import_from_gemini(&mut cfg)?;