使用说明
CC交换机MCP服务器
英语| 简体中文
独立MCP服务器 CC交换机 -为Claude Code、Codex、Gemini CLI、OpenCode和OpenClaw提供提供者管理功能。
主要特点:
- 🚀 使用CC Switch的核心库构建,以实现相同的行为
- 🔄 自动配置文件同步
- 💾 直接访问CC Switch的SQLite数据库
- 🪶 无Tauri依赖-轻量级二进制文件
- 🤝 与CC Switch桌面应用程序配合使用
安装
来自NPM
npm install -g @imvhb/cc-switch-mcp-server
来自源头
git clone https://github.com/VirtualHotBar/cc-switch-mcp.git
cd cc-switch-mcp
cargo build --release --no-default-features
二进制文件将位于 target/release/cc-switch-mcp (Linux/macOS)或 target/release/cc-switch-mcp.exe (Windows)。
用法
使用Claude Desktop进行配置
添加到您的Claude Desktop配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"cc-switch": {
"command": "cc-switch-mcp"
}
}
}
使用OpenCode进行配置
添加到您的OpenCode配置(~/.config/opencode/config.json):
{
"mcp": {
"servers": {
"cc-switch": {
"command": "cc-switch-mcp"
}
}
}
}
使用Gemini CLI进行配置
添加到您的Gemini配置(~/.gemini/settings.json):
{
"mcpServers": {
"cc-switch": {
"command": "cc-switch-mcp"
}
}
}
可用工具
| 工具 | 说明 |
|---|---|
list_providers |
列出CLI工具的所有提供程序及其配置 |
get_current_provider |
获取CLI工具的当前活动提供程序 |
switch_provider |
切换到特定提供程序(自动同步配置文件) |
add_provider |
添加具有指定配置的新提供程序 |
delete_provider |
按ID删除提供者 |
sync_current_to_live |
将当前提供程序设置同步到实时配置文件 |
get_custom_endpoints |
获取提供程序的自定义终结点列表 |
示例用法
列出提供商
{
"tool": "list_providers",
"arguments": {
"app": "claude"
}
}
答复:
{
"app": "claude",
"providers": [
{
"id": "default",
"name": "default",
"isCurrent": false,
"settingsConfig": { ... }
},
{
"id": "my-provider",
"name": "My Provider",
"isCurrent": true,
"settingsConfig": { ... }
}
],
"currentProviderId": "my-provider",
"total": 2
}
交换机提供商
{
"tool": "switch_provider",
"arguments": {
"app": "claude",
"providerId": "my-provider"
}
}
答复:
{
"success": true,
"app": "claude",
"providerId": "my-provider",
"configSynced": true,
"warnings": []
}
添加提供者
{
"tool": "add_provider",
"arguments": {
"app": "claude",
"name": "My API",
"baseUrl": "https://api.example.com",
"apiKey": "sk-xxx",
"model": "claude-3-sonnet"
}
}
支持的应用程序
| 应用程序 | 配置文件 | 说明 |
|---|---|---|
| 克劳德代码 | ~/.claude.json |
Anthropic的CLI工具 |
| 食品法典委员会 | ~/.codex/config.toml |
OpenAI的Codex命令行界面 |
| Gemini CLI | ~/.gemini/settings.json |
谷歌Gemini CLI |
| OpenCode | ~/.config/opencode/config.json |
OpenCode命令行界面 |
| OpenClaw | ~/.openclaw/config.json |
OpenClaw命令行界面 |
建筑
此MCP服务器使用CC Switch的实际核心库(cc_switch_lib)编译时不支持Tauri GUI:
┌─────────────────────┐
│ MCP Protocol │
│ (JSON-RPC 2.0) │
└─────────┬───────────┘
│
┌─────────▼───────────┐
│ cc-switch-mcp │
│ (This Server) │
└─────────┬───────────┘
│
┌─────────▼───────────┐
│ cc_switch_lib │
│ (Core Library) │
│ - ProviderService │
│ - Database │
│ - Config Sync │
└─────────────────────┘
这确保了与CC Switch桌面应用程序的行为相同。
数据库
服务器直接从CC Switch SQLite数据库读取:
- 位置:
~/.cc-switch/cc-switch.db - 兼容:与桌面应用程序完全兼容
- 安全:可与CC Switch桌面一起使用
发展
# Run in development mode with logging
RUST_LOG=debug cargo run --no-default-features
# Build release
cargo build --release --no-default-features
# Run tests
cargo test --no-default-features
许可证
麻省理工学院
