mcp-sync
Sync canonical MCP configuration to multiple AI coding assistants
mcp-sync reads a single mcp.yaml file and syncs the server definitions to configuration files for:
- Antigravity (VS Code extension)
- Claude Code (CLI)
- Codex (OpenAI CLI)
- OpenCode
- Custom targets (dynamic libraries)
Installation
Quick Start
# One-time sync to all targets
# Watch for changes and re-sync
# Sync only global configs
# Dry run (show what would change)
# Clean up servers not in canonical file
Canonical Format (mcp.yaml)
version: 1
# Optional: plugins for transforming config
plugins:
- name: env-expander
config:
prefix: "${"
suffix: "}"
servers:
# stdio server (local process)
my-server:
command: npx
args:
env:
API_KEY: "${API_KEY}"
cwd: /path/to/workdir
enabled: true # default: true
# http server (remote)
remote-server:
kind: http
url: https://mcp.example.com/v1
headers:
Authorization: "Bearer ${TOKEN}"
CLI Options
| Option | Description |
|---|---|
--canon <PATH or URL> |
Path or URL to canonical mcp.yaml (default: mcp.yaml) |
--scope <SCOPE> |
Sync scope: global, project, or both (default: both) |
--project-root <PATH> |
Project root (default: auto-detect git root) |
--clean |
Remove servers not present in canonical file |
--dry-run |
Print changes without writing files |
--log-level <LEVEL> |
Log level: trace, debug, info, warn, error (default: info) |
--plugin <PATH> |
Load additional plugin library (can be repeated) |
--target <PATH> |
Load custom target library (can be repeated) |
--only-target <NAMES> |
Sync only to specific targets (comma-separated or all) |
Commands
sync (default)
One-time sync to all targets.
watch
Watch mcp.yaml for changes and re-sync automatically.
init
Interactive wizard to create mcp.yaml:
validate
Validate mcp.yaml syntax and schema:
diff
Show differences between canon and current target configs:
completions
Generate shell completions:
# Bash
# Zsh
# Fish
Remote Canon
Load mcp.yaml from a URL:
Examples
Sync with Custom Target
# All built-in targets + custom target
# Multiple custom targets
# Only Claude + custom target
Sync with Custom Plugin
# Built-in env-expander + custom plugin
Watch Mode with Custom Config
# Watch and sync on changes
CI/CD Integration
# Sync global configs, fail on error
Target File Locations
Global (User-level)
| Target | macOS | Linux | Windows |
|---|---|---|---|
| Antigravity | ~/Library/Application Support/Antigravity/User/mcp.json |
~/.config/Antigravity/User/mcp.json |
%APPDATA%\Antigravity\User\mcp.json |
| Claude | ~/.claude.json |
~/.claude.json |
%USERPROFILE%\.claude.json |
| Codex | ~/.codex/config.toml |
~/.codex/config.toml |
%APPDATA%\codex\config.toml |
| OpenCode | ~/.config/opencode/opencode.json |
~/.config/opencode/opencode.json |
%APPDATA%\opencode\opencode.json |
Project-level
| Target | Path |
|---|---|
| Antigravity | .vscode/mcp.json |
| Claude | .mcp.json |
| Codex | .codex/config.toml |
| OpenCode | opencode.json |
Plugin System
Plugins can transform configurations during sync.
Built-in: env-expander
Expands environment variables in config values:
plugins:
- name: env-expander
config:
prefix: "${"
suffix: "}"
Custom Plugins
Create a dynamic library that exports create_plugin:
use ;
use Result;
use Value as JsonValue;
pub extern "C"
Custom Targets
Create custom sync targets for unsupported tools.
Implementation
use ;
use Result;
use ;
;
pub extern "C"
Build
# Cargo.toml
# Output: target/release/libmy_target.dylib
Use
Backups
Before modifying any file, mcp-sync creates a timestamped backup:
config.json → config.json.bak.20260105-230041
License
MIT