MCP模式切换器

一个MCP服务器,允许用户直接在Claude Desktop内切换不同的MCP配置配置文件。

  • by JasonBates
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 JasonBates/mcp-mode-switcher

使用说明

MCP模式切换器

一个MCP服务器,允许您直接从Claude Desktop内部在不同的MCP配置文件之间切换。

为什么?

Claude Desktop在启动时从以下位置加载MCP服务器 claude_desktop_config.json.MCP越多=每条消息上使用的令牌越多。此工具允许您:

  • 交换机配置文件 -在“完整”、“最小”、“研究”模式等之间切换。
  • 保存快照 -将当前设置捕获为新配置文件
  • 自动备份 -每个开关都会创建一个带时间戳的备份

与CLI工具不同,这作为MCP服务器运行,因此您只需询问Claude即可切换模式: “切换到最小模式”.

安装

  1. 克隆此仓库:

    git clone https://github.com/YOUR_USERNAME/mcp-mode-switcher.git ~/Projects/mcp-mode-switcher
    cd ~/Projects/mcp-mode-switcher
    
  2. 创建虚拟环境并安装依赖关系:

    python3 -m venv venv
    source venv/bin/activate
    pip install mcp
    
  3. 创建配置目录:

    mkdir -p ~/Library/Application\ Support/Claude/configs
    
  4. 添加到您的 claude_desktop_config.json:

    {
      "mcpServers": {
        "mcp-mode-switcher": {
          "command": "/path/to/mcp-mode-switcher/venv/bin/python",
          "args": ["/path/to/mcp-mode-switcher/server.py"]
        }
      }
    }
    
  5. 重新启动克劳德桌面

工具

工具 说明
list_modes() 显示所有可用的配置文件,包括描述和代币成本
current_mode() 确定当前处于活动状态的配置文件
switch_mode(mode, confirm) 切换到其他配置文件(需要确认)
save_current_as_mode(name, description?, token_cost?) 将当前配置另存为新配置文件
list_backups() 查看带时间戳的备份历史记录

使用示例

在克劳德桌面中:

  • “有哪些可用模式?”
  • “我处于什么模式?”
  • “切换到最小模式”
  • “将我当前的设置保存为“写入”模式”
  • “显示我的备份”

文件结构

~/Library/Application Support/Claude/
├── claude_desktop_config.json      # Active config (Claude reads this)
├── configs/
│   ├── modes.json                  # Mode metadata (descriptions, token costs)
│   ├── full.json                   # Profile: all MCPs
│   ├── minimal.json                # Profile: minimal MCPs
│   └── [your-custom-modes].json    # Your saved profiles
└── backups/
    └── config.YYYY-MM-DD-HHMMSS.json  # Auto-backups before each switch

创建配置文件

选项1:使用工具

问克劳德: “将我当前的设置保存为“研究”模式,并描述为“用于深入研究工作””

选项2:手动

  1. 在中创建配置文件 ~/Library/Application Support/Claude/configs/research.json
  2. 将元数据添加到 modes.json:
    {
      "research": {
        "description": "Research focused - perplexity, zotero, readwise",
        "token_cost": "~25k tokens"
      }
    }
    

运作原理

  1. 配置文件存储为完整 claude_desktop_config.json 文件在 configs/
  2. 切换会将所选配置文件复制到 claude_desktop_config.json
  3. Claude Desktop会自动重新启动以加载新配置
  4. 每次切换前都会创建备份

需求

  • macOS(使用 osascript 和 open -a 重新启动)
  • Python 3.10+
  • 克劳德桌面

许可证

麻省理工学院