Claude桌面配置管理工具

用于管理多个Claude Desktop MCP服务器配置的工具,支持通过启用/禁用标志控制服务器配置生成。

  • by damianoneill
  • Go
  • 本地部署
  • 更新于
在 GitHub 查看 damianoneill/claude-desktop-config

使用说明

claude桌面配置

使用每台服务器的启用/禁用标志管理多个Claude Desktop MCP服务器配置。

克劳德桌面 claude_desktop_config.json 是纯JSON——你不能把东西注释掉。此工具可让您维护 源文件 您可以随意添加多个服务器条目,每个条目都有一个 "_enabled" 标志,并从中生成真正的配置。

安装

go install github.com/damianoneill/claude-desktop-config@latest

或者从以下网址下载二进制文件 发布页面.

macOS注意事项: 从发布页面下载的二进制文件没有经过代码签名或公证。macOS Gatekeeper将在首次运行时阻止二进制文件。要删除隔离属性,请执行以下操作:

xattr -d com.apple.quarantine ./claude-desktop-config

快速开始

# 1. Create source file from the committed example
claude-desktop-config init

# 2. Edit it — add your real credentials and set _enabled flags as needed
$EDITOR claude_desktop_config.source.json

# 3. Launch the interactive TUI — toggle servers, then press 'a' to apply
claude-desktop-config

# Or skip the TUI and apply directly:
claude-desktop-config apply

# 4. Restart Claude Desktop

用法

无参数运行以启动交互式TUI:

claude-desktop-config

或者直接使用子命令:

claude-desktop-config [--source PATH] [--keep-backups N] <command>
命令 描述
tui 启动交互式TUI(未给出命令时的默认设置)
init 从创建源文件 .example (如果已存在,则跳过)
apply 从源文件生成并写入Claude Desktop配置
dry-run 预览生成的配置,无需写入磁盘
version 打印版本

全球旗帜:

--source PATH       Path to source JSON file (default: ./claude_desktop_config.source.json)
--keep-backups N    Number of backup files to retain (default: 3)

交互式TUI

跑步 claude-desktop-config (或 claude-desktop-config tui)打开全屏终端UI:

Claude Desktop MCP Servers  3 enabled / 15 total

────────────────────────────────────────────────────────────────────────
       NAME                                       URL
  ●  local-server-a                               http://localhost:8080/mcp/server-a
  ○  local-server-b                               http://localhost:8080/mcp/server-b
  ○  prod-server-a                                https://api.example.com/mcp/server-a
  ●~ staging-server-a                             https://staging.example.com/mcp/server-a
────────────────────────────────────────────────────────────────────────
↑↓/jk navigate  space toggle  s save  a apply  d dry-run  q quit
符号 含义
● 已启用
○ 残疾人
●~ 已分段启用(未保存)
○~ 已分段禁用(未保存)

变化是 分阶段的 直到明确承诺:

  • space --切换所选服务器(已暂存,尚未写入)
  • s --将阶段性更改保存到源文件
  • a --保存阶段性更改并应用于Claude Desktop配置
  • d --当前启用的服务器的模拟运行预览(显示在状态栏中)
  • q --退出(丢弃任何未保存的阶段性更改)

源文件格式

claude_desktop_config.source.json 反映了真实的Claude Desktop配置结构, 每个服务器条目有两个额外字段:

  • "_enabled" — true 包括, false 从生成的配置中排除
  • "_comment" --可选的自由形式描述,显示在TUI中并从输出中删除

前缀为的字段 _ 仅限于meta——它们仅存在于源文件中,并且是 从未复制到生成的Claude Desktop配置。

{
  "mcpServers": {
    "local-server-a": {
      "_enabled": true,
      "_comment": "Local dev instance — enabled for day-to-day testing",
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://localhost:8080/mcp/server-a",
        "--header",
        "Authorization:Bearer YOUR_API_TOKEN"
      ],
      "env": {
        "NODE_OPTIONS": "--use-system-ca",
        "NODE_TLS_REJECT_UNAUTHORIZED": "0"
      }
    },
    "prod-server-a": {
      "_enabled": false,
      "_comment": "Production — keep disabled unless explicitly testing prod",
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://api.example.com/mcp/server-a",
        "--header",
        "Authorization:Bearer YOUR_PROD_API_TOKEN"
      ],
      "env": {
        "NODE_OPTIONS": "--use-system-ca"
      }
    }
  }
}

claude_desktop_config.source.json 是 被忽视 --它永远不应该被承诺,因为它 包含真实的API令牌。承诺 .example 文件使用占位符值,可以安全共享。

配置文件位置

操作系统会自动检测正确的路径:

操作系统 路径
macOS ~/Library/Application Support/Claude/claude_desktop_config.json
Linux ~/.config/Claude/claude_desktop_config.json
窗户 %APPDATA%/Claude/claude_desktop_config.json

应用程序如何工作

  1. 读取源文件
  2. 仅筛选到 "_enabled": true 服务器(不存在 _enabled 被视为已启用)
  3. 全部脱衣 _ 前缀字段(_enabled, _comment)从输出
  4. 使用时间戳后缀备份现有的Claude Desktop配置(.YYYYMMDD-HHMMSS.bak)
  5. 修剪旧备份,保留最新的N(默认值3,可通过配置 --keep-backups)
  6. 合并新 mcpServers 将块插入到现有配置中,保留Claude Desktop可能编写的任何其他顶级密钥
  7. 写入结果

发展

make setup          # install pre-commit hooks
make build          # build ./claude-desktop-config binary
make test           # run all tests
make lint           # run golangci-lint
make fmt            # format source code
make release-dry    # local goreleaser snapshot