mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-29 01:25:33 +08:00
576ff53a75
Add mcp/hermes.rs with bidirectional MCP format conversion: - convert_to_hermes_format: strip type field, infer from command/url - convert_from_hermes_format: infer type, strip Hermes-specific fields - Merge-on-write: existing Hermes fields (tools, sampling, timeout, roots, enabled) preserved when user has customized them - update_mcp_servers_yaml: closure-based read-modify-write under write lock to prevent TOCTOU races in concurrent sync operations - 9 unit tests for format conversion and merge logic Wire up all MCP service dispatch: - Replace Hermes TODO stubs with real sync/remove calls - Remove Hermes from sync_all_enabled skip list - Enable deep link hermes MCP flag (apps.hermes = true) - Add Hermes import to import_mcp_from_apps command
37 lines
1.1 KiB
Rust
37 lines
1.1 KiB
Rust
//! MCP (Model Context Protocol) 服务器管理模块
|
|
//!
|
|
//! 本模块负责 MCP 服务器配置的验证、同步和导入导出。
|
|
//!
|
|
//! ## 模块结构
|
|
//!
|
|
//! - `validation` - 服务器配置验证
|
|
//! - `claude` - Claude MCP 同步和导入
|
|
//! - `codex` - Codex MCP 同步和导入(含 TOML 转换)
|
|
//! - `gemini` - Gemini MCP 同步和导入
|
|
//! - `opencode` - OpenCode MCP 同步和导入(含 local/remote 格式转换)
|
|
//! - `hermes` - Hermes MCP 同步和导入
|
|
|
|
mod claude;
|
|
mod codex;
|
|
mod gemini;
|
|
mod hermes;
|
|
mod opencode;
|
|
mod validation;
|
|
|
|
// 重新导出公共 API
|
|
pub use claude::{
|
|
import_from_claude, remove_server_from_claude, sync_enabled_to_claude,
|
|
sync_single_server_to_claude,
|
|
};
|
|
pub use codex::{
|
|
import_from_codex, remove_server_from_codex, sync_enabled_to_codex, sync_single_server_to_codex,
|
|
};
|
|
pub use gemini::{
|
|
import_from_gemini, remove_server_from_gemini, sync_enabled_to_gemini,
|
|
sync_single_server_to_gemini,
|
|
};
|
|
pub use hermes::{import_from_hermes, remove_server_from_hermes, sync_single_server_to_hermes};
|
|
pub use opencode::{
|
|
import_from_opencode, remove_server_from_opencode, sync_single_server_to_opencode,
|
|
};
|