同步mcp
一键式MCP配置同步工具。 中文
1.概述
sync-mcp是一个基于Node.js的命令行工具,旨在解决在多个IDE、代码编辑器和CLI工具之间手动同步通用mcp配置的痛点。用户可以使用简单的命令将一个工具(源)的配置文件安全地同步到另一个工具的配置文件(目标),从而实现统一和自动化的配置管理。
2.技术规格
- 环境:Node.js 18+(需要ESM支持和现代API)。
- 分发:通过npm分发,支持使用npx sync mcp直接执行或使用npm i-g sync mcp全局安装。
- 运行时依赖性:仅依赖于跨平台文件系统和CLI交互库;不需要本机编译环境。
- 支持的平台:在Linux、Windows和macOS上稳定运行。
3.使用方法
3.1.直接同步
通过为源和目标工具提供关键字直接执行同步。
npx -y sync-mcp 3.2.交互式同步
当命令在没有任何参数的情况下执行时,它将进入交互模式。
npx -y sync-mcp操作流程:
- 选择来源:
? Select the configuration source file: (Use arrow keys)
> 1. VS Code (~/.vscode/mcp.json)
2. Cursor (~/.cursor/mcp.json)
3. GitHub Copilot CLI (~/.copilot/mcp-config.json)
4. Customize- 选择目标:
? Select the configuration target file: (Use arrow keys)
> 1. VS Code (~/.vscode/mcp.json)
2. Cursor (~/.cursor/mcp.json)
3. GitHub Copilot CLI (~/.copilot/mcp-config.json)
4. Customize (Select a target tool or create a new configuration)4.刀具匹配关键字
| 工具名称 | 支持的关键字 | \ |
|---|---|---|
| 食品法典委员会 | codex, openai, codex cli | \ |
| 克劳德代码 | claude, claude-code, claude code, anthropic | \ |
| 光标 | cursor, cursor ide | \ |
| Gemini CLI | gemini, gemini cli, google, gcloud | \ |
| GitHub Copilot命令行界面 | copilot, copilot cli, github, gh | \ |
| Visual Studio代码 | vscode, vs code, vs-code, code | |
| OpenCode | opencode, open code, anomaly |
5.支持的工具和配置路径
| 工具名称 | Linux/macOS路径 | Windows路径 | 文档URL | \ |
|---|---|---|---|---|
| 食品法典委员会 | ~/.codex/config.toml | %USERPROFILE%\.codex\config.toml | Codex配置 | |
| 克劳德代码 | ~/.claude.json | %USERPROFILE%\.claude.json | 克劳德代码MCP指南 | |
| 光标 | ~/.cursor/mcp.json | %APPDATA%\Cursor\mcp.json | 光标MCP指南 | |
| Gemini CLI(gcloud) | ~/.gemini/settings.json | %APPDATA%\.gemini\settings.json | Gemini CLI MCP服务器 | |
| GitHub Copilot命令行界面 | ~/.copilot/mcp-config.json | %USERPROFILE%\.copilot\mcp-config.json | Copilot CLI MCP使用情况 | |
| Visual Studio代码 | ~/.vscode/mcp.json | %APPDATA%\Roaming\Code\User\mcp.json | VS代码MCP服务器 | |
| OpenCode | ~/.opencode/opencode.json | %USERPROFILE%\.opencode\opencode.json | OpenCode MCP指南 |
5.1.法典
默认配置文件: ~/.codex/config.toml
[mcp_servers.context7]
command = "npx"
args = [
"-y",
"@upstash/context7-mcp",
"--api-key",
"YOUR_API_KEY"
]
env = {}
startup_timeout_ms = 60_000备选方案-远程HTTP服务器:
[mcp_servers.context7]
url = "https://mcp.context7.com/mcp"
bearer_token_env_var = "CONTEXT7_API_KEY"
startup_timeout_ms = 60_0005.2.克劳德代码
默认配置文件: ~/.claude.json
{
"mcpServers": {
"context7": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@upstash/context7-mcp",
"--api-key",
"YOUR_API_KEY"
],
"env": {}
}
}
}5.3.光标
默认配置文件: ~/.cursor/mcp.json
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}5.4.Gemini CLI(gcloud)
默认配置文件:~/.ggemini/settings.json
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}5.5.GitHub Copilot命令行界面
默认配置文件: ~/.copilot/mcp-config.json
{
"mcpServers": {
"docs": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}5.6.Visual Studio Code
默认配置文件: ~/.vscode/mcp.json
{
"servers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}5.7.OpenCode
默认配置文件: ~/.opencode/opencode.json
本地MCP服务器(stdio类型-推荐):
{
"mcpServers": {
"context7": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"],
"env": {}
}
}
}远程MCP服务器(sse类型):
{
"mcpServers": {
"context7": {
"type": "sse",
"url": "https://mcp.context7.com/mcp",
"timeout": 5000
}
}
}6.核心特征
- 双模式操作:支持快速、直接的单行命令同步和引导式交互模式。
- 模糊参数匹配:用户不需要记住确切的工具名称;该工具自动匹配常用关键字。
- 跨平台兼容性:完美支持Linux、Windows和macOS环境,自动处理不同的操作系统路径格式。
- 自动路径检测:内置主流开发工具的默认配置路径,自动发现本地现有的配置文件。
- 安全备份机制:在执行任何覆盖操作之前,自动备份目标配置文件,确保操作可逆,防止意外数据丢失。
- 定制和扩展:支持手动指定配置文件路径,如果目标文件不存在,可以自动创建目标文件。
7.文件备份机制
安全是该工具的核心原则之一。在执行任何同步操作(即覆盖目标文件)之前,请执行以下备份过程 必须 执行:
- 安全原则:在任何操作写入目标文件之前,必须完成备份以确保操作可逆。
- 默认位置:创建
~/.sync-mcp/backup/用户主目录中的目录。如果它不存在,它会自动创建。 - 备份内容:完整的副本 当前目标文件.
- 备份路径:
- 根目录: ~/.sync-mcp/backup/ - 子目录结构: /// - `:执行同步操作时的Unix时间戳(以毫秒为单位)。, 1677619200000`
- 示例:
- 操作: npx sync-mcp vscode cursor - 时间: 2025-10-24 18:00:00 (假设时间戳 1761319200000) - 目标文件: ~/.cursor/mcp.json 在Linux上 - 行动:程序复制 ~/.cursor/mcp.json 到 ~/.sync-mcp/backup/1761319200000/.cursor/mcp.json - 这可以防止备份文件被覆盖,并保留原始文件的路径结构,使其易于查找和还原。
8.平台兼容性
- 操作系统:必须在主流Linux发行版(Ubuntu、CentOS等)以及Windows 10/11和macOS上稳定运行。
- 路径处理:内部逻辑必须使用Node.js
path模块功能如下path.join()和path.resolve()以处理文件路径。硬编码/或\被禁止。
