feat(mcp): import Codex MCP from ~/.codex/config.toml

- Support both TOML schemas: [mcp.servers.<id>] and [mcp_servers.<id>]
- Non-destructive merge of imported servers (enabled=true only)
- Preserve existing TOML schema when syncing (prefer mcp_servers)
- Remove both mcp and mcp_servers when no enabled items

feat(ui): auto-import Codex MCP on panel init (app=codex)

chore(tauri): add import_mcp_from_codex command and register

chore(types): expose window.api.importMcpFromCodex and typings

fix(ui): remove unused variable for typecheck
This commit is contained in:
Jason
2025-10-10 14:59:02 +08:00
parent 428369cae0
commit 6cf7dacd0e
9 changed files with 214 additions and 27 deletions

View File

@@ -859,6 +859,21 @@ pub async fn import_mcp_from_claude(state: State<'_, AppState>) -> Result<usize,
Ok(changed)
}
/// 从 ~/.codex/config.toml 导入 MCP 定义到 config.jsonCodex 作用域),返回变更数量
#[tauri::command]
pub async fn import_mcp_from_codex(state: State<'_, AppState>) -> Result<usize, String> {
let mut cfg = state
.config
.lock()
.map_err(|e| format!("获取锁失败: {}", e))?;
let changed = crate::mcp::import_from_codex(&mut cfg)?;
drop(cfg);
if changed > 0 {
state.save()?;
}
Ok(changed)
}
/// 获取设置
#[tauri::command]
pub async fn get_settings() -> Result<crate::settings::AppSettings, String> {