MCPcopy Index your code
hub / github.com/2ue/ccman

github.com/2ue/ccman @v3.3.31

Chat with this repo
repository ↗ · DeepWiki ↗ · release v3.3.31 ↗ · + Follow
751 symbols 2,380 edges 193 files 72 documented · 10%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ccman

一个用于 Codex / Claude Code / Gemini CLI / OpenCode 的 API 服务商配置管理工具,支持 CLI + Desktop,并提供 MCP 服务器管理与 WebDAV 同步。

✨ 功能概览

  • 一键切换服务商:Codex / Claude Code / Gemini CLI / OpenCode
  • 内置预设模板:提供常用模板(Desktop 支持自定义预设)
  • 安全写入:关键配置覆盖前自动备份(.bak,权限 600
  • MCP 管理:集中管理 MCP 服务器(可在 Desktop 选择同步到 Claude/Gemini,Codex 暂不支持)
  • WebDAV 同步:Codex / Claude / Gemini 配置备份、下载、合并
  • 导入/导出:仅支持 Codex / Claude 配置
  • Claude 历史清理:分析并清理 ~/.claude.json

✅ 支持的工具与配置路径

工具 主要配置文件 说明
Codex ~/.codex/config.toml + ~/.codex/auth.json auth.json 使用 OPENAI_API_KEY
Claude Code ~/.claude/settings.json 另有历史文件 ~/.claude.json
Gemini CLI ~/.gemini/settings.json + ~/.gemini/.env .env 使用 GOOGLE_GEMINI_BASE_URL / GEMINI_API_KEY / GOOGLE_API_KEY / GEMINI_MODEL
OpenCode ~/.config/opencode/opencode.json 写入 provider 配置与模型变体
ccman ~/.ccman/{codex,claude,gemini,opencode,mcp}.json + ~/.ccman/config.json 保存服务商与 MCP 配置,WebDAV 同步配置存放在 config.json

📦 内置预设

Claude Code

  • Anthropic Officialhttps://api.anthropic.com
  • GMNhttps://ai.gmncode.com
  • GMN1https://gmncode.cn

Codex

  • OpenAI Officialhttps://api.openai.com/v1
  • GMNhttps://ai.gmncode.com
  • GMN1https://gmncode.cn

Gemini CLI

  • Google Gemini (API Key):官方默认(无需设置 baseUrl)
  • GMNhttps://ai.gmncode.com
  • GMN1https://gmncode.cn

OpenCode

  • GMNhttps://ai.gmncode.com(npm: @ai-sdk/openai
  • GMN1https://gmncode.cn(npm: @ai-sdk/openai

🧭 CLI 使用速览

交互式入口

ccman

执行效果(主菜单):

$ ccman

? 请选择操作:
  ❯ 🔷 Claude 管理
    🔶 Codex 管理
    💎 Gemini 管理
    🧩 OpenCode 管理
    🔄 WebDAV 同步
    📦 预置服务商管理
    ❌ 退出

Codex / Claude / Gemini / OpenCode 服务商管理

ccman cx add|list|use|current|edit|remove|clone
ccman cc add|list|use|current|edit|remove|clone|clean:analyze|clean
ccman gm add|list|use|current|edit|remove|clone
ccman oc add|list|use|current|edit|remove|clone

常用命令支持参数模式,适合非交互执行:

ccman cx add --name work --base-url https://api.example.com --api-key sk-xxx --switch
ccman cc add --preset GMN --api-key sk-xxx --switch
ccman gm edit default --new-name personal --base-url '' --api-key ''
ccman oc remove old-provider --yes

交互式工具菜单(以 Codex 为例):

$ ccman cx

? 🔶 Codex 操作:
  ❯ ➕ 添加服务商
    🔄 切换服务商
    📋 列出所有服务商
    👁️  查看当前服务商
    ✏️  编辑服务商
    🔁 克隆服务商
    🗑️  删除服务商
    ⬅️  返回上级

下面补充每个命令的执行效果示例(交互式流程与输出与源码一致)。

Codex 命令执行效果

add

$ ccman cx add

📝 添加 Codex 服务商

? 选择配置来源:
  ❯ 📦 使用预置服务商
    ✏️  自定义配置

? 选择预置服务商:
  OpenAI Official - OpenAI 官方 API
  GMN - GMN 服务 (OpenAI/Codex 兼容)

使用预设: GMN - GMN 服务 (OpenAI/Codex 兼容)

? 服务商名称: GMN
? 描述(可选):
? API 地址: https://ai.gmncode.com
? API 密钥: ********

✅ 添加成功

  GMN [Codex]
  https://ai.gmncode.com

? 是否立即切换到此服务商? (Y(y) / N(n))
✅ 已切换到新服务商

配置已更新:
  - ~/.codex/config.toml
  - ~/.codex/auth.json

list

$ ccman cx list

📋 Codex 服务商 (2 个)

  ●  OpenAI Official [当前]
     https://api.openai.com/v1
     OpenAI 官方 API

  ○  GMN
     https://ai.gmncode.com
     GMN 服务 (OpenAI/Codex 兼容)

use

$ ccman cx use

? 选择要切换的服务商:
  OpenAI Official - https://api.openai.com/v1
  GMN - https://ai.gmncode.com

✅ 切换成功

  GMN [Codex]
  URL: https://ai.gmncode.com

配置已更新:
  - ~/.codex/config.toml
  - ~/.codex/auth.json

current

$ ccman cx current

📍 当前 Codex 服务商

  OpenAI Official
  ID: codex-1768916063885-openai1
  URL: https://api.openai.com/v1
  最后使用: 2026/1/20 21:34:24

edit

$ ccman cx edit

? 选择要编辑的服务商:
  OpenAI Official - https://api.openai.com/v1
  GMN - https://ai.gmncode.com

✏️  编辑服务商

提示: 留空则保持原值

? 服务商名称: GMN
? API 地址: https://ai.gmncode.com
? API 密钥 (留空保持不变): ********

✅ 编辑成功

  GMN [Codex]
  ID: codex-1768916065885-gmn001
  URL: https://ai.gmncode.com

clone

$ ccman cx clone

? 选择要克隆的服务商:
  OpenAI Official - https://api.openai.com/v1
  GMN - https://ai.gmncode.com

克隆自: OpenAI Official

? 服务商名称: OpenAI Official(副本)
? 描述(可选):
? API 地址: https://api.openai.com/v1
? API 密钥: ********

✅ 克隆成功

  OpenAI Official(副本) [Codex]
  ID: codex-1768916069999-copy01
  URL: https://api.openai.com/v1

remove

$ ccman cx remove

? 选择要删除的服务商:
  OpenAI Official - https://api.openai.com/v1
  GMN - https://ai.gmncode.com

? 确定删除 "GMN"? (Y(y) / N(n))

✅ 已删除: GMN

Claude Code 命令执行效果

add

$ ccman cc add

📝 添加 Claude Code 服务商

? 选择配置来源:
  ❯ 📦 使用预置服务商
    ✏️  自定义配置

? 选择预置服务商:
  Anthropic Official - Anthropic 官方 API

使用预设: Anthropic Official - Anthropic 官方 API

? 服务商名称: Anthropic Official
? 描述(可选):
? API 地址: https://api.anthropic.com
? API 密钥: ********

✅ 添加成功

  Anthropic Official [Claude Code]
  https://api.anthropic.com

? 是否立即切换到此服务商? (Y(y) / N(n))
✅ 已切换到新服务商

配置已更新:
  - ~/.claude/settings.json

list

$ ccman cc list

📋 Claude Code 服务商 (1 个)

  ●  Anthropic Official [当前]
     https://api.anthropic.com
     Anthropic 官方 API

use

$ ccman cc use

? 选择要切换的服务商:
  Anthropic Official - https://api.anthropic.com

✅ 切换成功

  Anthropic Official [Claude Code]
  URL: https://api.anthropic.com

配置已更新:
  - ~/.claude/settings.json

current

$ ccman cc current

📍 当前 Claude Code 服务商

  Anthropic Official
  ID: claude-1768916065885-anth01
  URL: https://api.anthropic.com
  最后使用: 2026/1/20 21:34:26

edit

$ ccman cc edit

? 选择要编辑的服务商:
  Anthropic Official - https://api.anthropic.com

✏️  编辑服务商

提示: 留空则保持原值

? 服务商名称: Anthropic Official
? API 地址: https://api.anthropic.com
? API 密钥 (留空保持不变): ********

✅ 编辑成功

  Anthropic Official [Claude Code]
  ID: claude-1768916065885-anth01
  URL: https://api.anthropic.com

clone

$ ccman cc clone

? 选择要克隆的服务商:
  Anthropic Official - https://api.anthropic.com

克隆自: Anthropic Official

? 服务商名称: Anthropic Official(副本)
? 描述(可选):
? API 地址: https://api.anthropic.com
? API 密钥: ********

✅ 克隆成功

  Anthropic Official(副本) [Claude Code]
  ID: claude-1768916072222-copy01
  URL: https://api.anthropic.com

remove

$ ccman cc remove

? 选择要删除的服务商:
  Anthropic Official - https://api.anthropic.com

? 确定删除 "Anthropic Official"? (Y(y) / N(n))

✅ 已删除: Anthropic Official

Gemini CLI 命令执行效果

add

$ ccman gm add

📝 添加 Gemini CLI 服务商

? 选择配置来源:
  ❯ 📦 使用预置服务商
    ✏️  自定义配置

? 选择预置服务商:
  Google Gemini (API Key) - 使用官方 Gemini API(通过 GEMINI_API_KEY 或 GOOGLE_API_KEY 认证)
  GMN - GMN 服务 (Gemini 兼容)

使用预设: GMN - GMN 服务 (Gemini 兼容)

? 服务商名称: GMN
? 描述(可选):
? API 地址: https://ai.gmncode.com
? API 密钥: ********

✅ 添加成功

  GMN [Gemini CLI]
  https://ai.gmncode.com

? 是否立即切换到此服务商? (Y(y) / N(n))
✅ 已切换到新服务商

配置已更新:
  - ~/.gemini/settings.json
  - ~/.gemini/.env

list

$ ccman gm list

📋 Gemini CLI 服务商 (2 个)

  ●  Google Gemini (API Key) [当前]

     官方 Gemini API

  ○  GMN
     https://ai.gmncode.com
     GMN 服务 (Gemini 兼容)

use

$ ccman gm use

? 选择要切换的服务商:
  Google Gemini (API Key) - (默认端点)
  GMN - https://ai.gmncode.com

✅ 切换成功

  GMN [Gemini CLI]
  URL: https://ai.gmncode.com

配置已更新:
  - ~/.gemini/settings.json
  - ~/.gemini/.env

current

$ ccman gm current

🎯 当前 Gemini CLI 服务商

  名称: Google Gemini (API Key)
  地址: (默认端点)

edit

$ ccman gm edit

? 选择要编辑的服务商:
  Google Gemini (API Key) - (默认端点)
  GMN - https://ai.gmncode.com

? 服务商名称: GMN
? 描述(可选):
? API 地址: https://ai.gmncode.com
? API 密钥: ********

✅ 编辑成功

clone

$ ccman gm clone

? 选择要克隆的服务商:
  Google Gemini (API Key) - (默认端点)
  GMN - https://ai.gmncode.com

? 输入新服务商名称:

✅ 克隆成功

  GMN(副本) [Gemini CLI]
  https://ai.gmncode.com

remove

$ ccman gm remove

? 选择要删除的服务商:
  Google Gemini (API Key) - (默认端点)
  GMN - https://ai.gmncode.com

? 确定要删除服务商 "GMN" 吗? (Y(y) / N(n))

✅ 已删除服务商

OpenCode 命令执行效果

add

$ ccman oc add

📝 添加 OpenCode 服务商

? 选择配置来源:
  ❯ 📦 使用预置服务商
    ✏️  自定义配置

? 选择预置服务商:
  GMN - GMN 服务 (OpenCode 兼容)

使用预设: GMN - GMN 服务 (OpenCode 兼容)

? 服务商名称: GMN
? 描述(可选):
? API 地址: https://ai.gmncode.com
? API 密钥: ********
? 兼容包 (npm): @ai-sdk/openai

✅ 添加成功

  GMN [OpenCode]
  https://ai.gmncode.com

? 是否立即切换到此服务商? (Y(y) / N(n))
✅ 已切换到新服务商

配置已更新:
  - ~/.config/opencode/opencode.json

list

$ ccman oc list

📋 OpenCode 服务商 (1 个)

  ●  GMN [当前]
     https://ai.gmncode.com
     GMN 服务 (OpenCode 兼容)

use

$ ccman oc use

? 选择要切换的服务商:
  GMN - https://ai.gmncode.com

✅ 切换成功

  GMN [OpenCode]
  URL: https://ai.gmncode.com

配置已更新:
  - ~/.config/opencode/opencode.json

current

$ ccman oc current

🎯 当前 OpenCode 服务商

  名称: GMN
  地址: https://ai.gmncode.com

edit

$ ccman oc edit

? 选择要编辑的服务商:
  GMN - https://ai.gmncode.com

? 服务商名称: GMN
? 描述(可选):
? API 地址: https://ai.gmncode.com
? API 密钥: ********
? 兼容包 (npm): @ai-sdk/openai

✅ 编辑成功

clone

$ ccman oc clone

? 选择要克隆的服务商:
  GMN - https://ai.gmncode.com

克隆自: GMN

? 服务商名称: GMN(副本)
? 描述(可选):
? API 地址: https://ai.gmncode.com
? API 密钥: ********
? 兼容包 (npm): @ai-sdk/openai

✅ 克隆成功

  GMN(副本) [OpenCode]
  ID: opencode-1768916088888-copy01
  URL: https://ai.gmncode.com

remove

$ ccman oc remove

? 选择要删除的服务商:
  GMN - https://ai.gmncode.com

? 确定删除 "GMN"? (Y(y) / N(n))

✅ 已删除: GMN

MCP 管理

ccman mcp add|list|edit|remove

MCP 会同步到 Claude / Gemini(Codex 暂不支持)。

执行效果示例:

add

$ ccman mcp add

📝 添加 MCP 服务器

? 选择配置来源:
  ❯ 📦 使用预置 MCP 服务器
    ✏️  自定义配置

? 选择预置 MCP 服务器:
  filesystem - 文件系统访问
  github - GitHub 集成
  postgres - PostgreSQL 数据库
  brave-search - Brave 搜索
  google-maps - Google Maps
  puppeteer - 浏览器自动化
  sqlite - SQLite 数据库
  sequential-thinking - 序列思考增强

使用预设: filesystem - 文件系统访问

⚠️  需要修改第3个参数为允许访问的目录路径

? MCP 服务器名称: filesystem
? 启动命令: npx
? 命令参数 (空格分隔): -y @modelcontextprotocol/server-filesystem /path/to/allowed/files
? 环境变量 (JSON 格式, 如 {"API_KEY": "xxx"}, 可留空):

✅ MCP 服务器添加成功

  filesystem [MCP]
  npx -y @modelcontextprotocol/server-filesystem /path/to/allowed/files

✅ 配置已自动同步到 ~/.claude/settings.json

配置文件:
  - ~/.claude/settings.json

list

$ ccman mcp list

📋 MCP 服务器 (2 个)

  ○ filesystem
    npx -y @modelcontextprotocol/server-filesystem /path/to/allowed/files

  ○ github
    npx -y @modelcontextprotocol/server-github
    环境变量: GITHUB_PERSONAL_ACCESS_TOKEN

提示: 所有配置的 MCP 服务器会自动同步到 ~/.claude/settings.json(可在 Desktop 选择同步到 Gemini CLI)

edit

$ ccman mcp edit

? 选择要编辑的 MCP 服务器:
  filesystem - npx -y @modelcontextprotocol/server-filesystem /path/to/allowed/files
  github - npx -y @modelcontextprotocol/server-github

✏️  编辑 MCP 服务器

提示: 留空则保持原值

? MCP 服务器名称: github
? 启动命令: npx
? 命令参数 (空格分隔, 留空保持不变): -y @modelcontextprotocol/server-github
? 环境变量 (JSON 格式, 留空保持不变): {"GITHUB_PERSONAL_ACCESS_TOKEN":"******"}

✅ 编辑成功

  github [MCP]
  命令: npx -y @modelcontextprotocol/server-github
  环境变量: GITHUB_PERSONAL_ACCESS_TOKEN

✅ 配置已自动同步到 ~/.claude/settings.json

配置文件:
  - ~/.claude/settings.json

remove

$ ccman mcp remove

? 选择要删除的 MCP 服务器:
  filesystem - npx -y @modelcontextprotocol/server-filesystem /path/to/allowed/files
  github - npx -y @modelcontextprotocol/server-github

? 确定删除 "github"? (Y(y) / N(n))

✅ 已删除: github

✅ 配置已自动同步到 ~/.claude/settings.json

配置文件:
  - ~/.claude/settings.json

WebDAV 同步

ccman sync
ccman sync config
ccman sync test
ccman sync upload
ccman sync download
ccman sync merge
ccman sync status

WebDAV 同步目前覆盖 Codex / Claude / Gemini 配置,OpenCode 与 MCP 暂不参与同步。

非交互模式

ccman sync config \
  --webdav-url https://dav.example.com \
  --username alice \
  --password 'YOUR_WEBDAV_PASSWORD' \
  --remote-dir /ccman \
  --sync-password 'YOUR_SYNC_PASSWORD' \
  --remember-sync-password

ccman sync download --yes
ccman sync upload --yes
ccman sync merge

也可以用环境变量:

export CCMAN_WEBDAV_URL='https://dav.example.com'
export CCMAN_WEBDAV_USERNAME='alice'
export CCMAN_WEBDAV_PASSWORD='YOUR_WEBDAV_PASSWORD'
export CCMAN_WEBDAV_REMOTE_DIR='/ccman'
export CCMAN_SYNC_PASSWORD='YOUR_SYNC_PASSWORD'

ccman sync config
ccman sync download --yes

执行效果示例(WebDAV):

同步菜单

$ ccman sync

? 🔄 同步操作:
  ❯ ⚙️  配置 WebDAV 连接
    🔍 测试连接
    📤 上传到云端
    📥 从云端下载
    🔄 智能合并
    📊 查看同步状态
    ⬅️  返回上一级

config

$ ccman sync config

⚙️  配置 WebDAV 同步

? WebDAV 服务器地址: https://dav.example.com
? 用户名: alice
? WebDAV 密码: ********
? 认证类型: Basic Auth(基础认证)
? 远程同步目录: /ccman
? 同步密码(用于加密 API Key): ********
? 记住同步密码? (Y(y) / N(n))

✅ 配置保存成功

配置文件: ~/.ccman/config.json

? 是否立即测试连接? (Y(y) / N(n))

🔍 测试 WebDAV 连接...

✅ 连接成功

  URL: https://dav.example.com
  用户: alice
  远程目录: /ccman
  认证类型: Basic Auth

test

$ ccman sync test

🔍 测试 WebDAV 连接...

✅ 连接成功

  URL: https://dav.example.com
  用户: alice
  远程目录: /ccman
  认证类型: Basic Auth

upload

$ ccman sync upload

📤 上传配置到云端

配置信息:
  Codex 服务商: 2 个
  Claude 服务商: 1 个

⚠️  云端现有配置将被覆盖

? 确认上传? (Y(y) / N(n))

🔐 加密 API Key...
📤 上传到 WebDAV...

✅ 上传成功

远程文件:
  https://dav.example.com/ccman/.ccman/codex.json
  https://dav.example.com/ccman/.ccman/claude.json

💡 其他设备可通过 'ccman sync download' 获取配置

download

```bash $ ccman sync download

📥 从云

Extension points exported contracts — how you extend this code

ToolConfigMapping (Interface)
* 工具配置映射(数据驱动,零 if-else) * * 扩展性:添加新工具只需在此添加配置项
packages/core/src/tool-manager.ts
Provider (Interface)
(no doc)
packages/types/src/index.ts
ToastProps (Interface)
(no doc)
packages/desktop/src/renderer/components/Toast.tsx
LocalSyncConfig (Interface)
(no doc)
packages/cli/src/utils/sync-config.ts
V2Config (Interface)
* v2.x 配置文件结构(旧版)
packages/core/src/migrate.ts
PresetTemplate (Interface)
(no doc)
packages/types/src/index.ts
SettingsPageProps (Interface)
(no doc)
packages/desktop/src/renderer/components/SettingsPage.tsx
GmnProfile (Interface)
(no doc)
packages/cli/src/utils/gmn-endpoints.ts

Core symbols most depended-on inside this repo

assert
called by 51
scripts/test-gmn-setup.mjs
list
called by 48
packages/core/src/tool-manager.types.ts
getCcmanDir
called by 35
packages/core/src/paths.ts
fileExists
called by 33
packages/core/src/utils/file.ts
get
called by 31
packages/core/src/tool-manager.types.ts
printSuccess
called by 31
packages/cli/src/utils/cli-output.ts
add
called by 30
packages/core/src/tool-manager.types.ts
createCodexManager
called by 29
packages/core/src/tool-manager.ts

Shape

Function 583
Interface 146
Method 16
Class 6

Languages

TypeScript100%

Modules by API surface

packages/core/src/tool-manager.types.ts27 symbols
packages/core/src/tool-manager.ts27 symbols
packages/desktop/src/renderer/App.tsx26 symbols
packages/aicoding/bin/aicoding.js24 symbols
packages/cli/src/commands/gmn.ts23 symbols
packages/core/src/paths.ts19 symbols
packages/core/src/writers/codex.ts18 symbols
packages/cli/src/utils/provider-params.ts17 symbols
packages/cli/src/interactive.ts17 symbols
packages/cli/src/commands/sync/helpers.ts16 symbols
scripts/update-changelog-from-changesets.js15 symbols
packages/types/src/index.ts15 symbols

Datastores touched

mydbDatabase · 1 repos

For agents

$ claude mcp add ccman \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact