syncing-mcp-servers
Skill128 starsChanged 7 months agoMITView on GitHub
Synchronize MCP server configuration between VS Code (.vscode/mcp.json) and Copilot CLI (~/.copilot/mcp-config.json). Use when setting up Copilot CLI for the first time, when MCP servers are added or changed in the repo, or when a user reports missing MCP tools in CLI.
In this repository20 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- committing-codeSkill
- deploying-to-azureSkill
- implementing-chat-streamingSkill
- planning-featuresSkill
- researching-azure-ai-sdkSkill
- reviewing-documentationSkill
- testing-cli-compatibilitySkill
- testing-with-playwrightSkill
- triaging-issuesSkill
- troubleshooting-authenticationSkill
- understanding-architectureSkill
- validating-deploymentsSkill
- validating-local-setupSkill
- validating-ui-featuresSkill
- writing-bicep-templatesSkill
- writing-csharp-codeSkill
- writing-typescript-codeSkill
- writing-unit-tests-csharpSkill
- writing-unit-tests-typescriptSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 3 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 65
Read .vscode/mcp.json from the repo.
- Very specific: line 69
Read ~/.copilot/mcp-config.json.
- Distinctive: line 83
Warn: if an existing CLI server has the same name but different config — ask the user whether to overwrite
- Very specific: line 87
Write the merged config back to ~/.copilot/mcp-config.json.
- Very specific: line 91
Run copilot --prompt "list available MCP tools" --allow-all-tools -p "run /mcp show and exit" or instruct the user to run /mcp show in …
- Distinctive: line 97
Strip comments: when reading VS Code's JSONC file — parse it as JSONC, not strict JSON
- Very specific: line 103
If the user added new MCP servers via CLI (/mcp add) that should also be available in VS Code:
- Very specific: line 105
Read ~/.copilot/mcp-config.json for any servers not in .vscode/mcp.json
- Very specific: line 107
Add to .vscode/mcp.json under "servers" key
- Distinctive: line 118
If any of these converge, update this skill and simplify the sync process.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Syncing MCP Servers
This skill ensures MCP server configurations stay in sync between VS Code (repo-level) and Copilot CLI (user-level).
Why This Exists
VS Code and Copilot CLI use different config files with different JSON formats for MCP servers. Neither reads the other's config. This skill bridges that gap.
| Platform | Config File | Top-Level Key | Scope |
| VS Code | .vscode/mcp.json | "servers" | Per-workspace (repo, checked into git) |
| Copilot CLI | ~/.copilot/mcp-config.json | "mcpServers" | Per-user (global, all repos) |
Format Differences
VS Code format (.vscode/mcp.json)
{
"servers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest", "--viewport-size=1024,768"]
},
"microsoftdocs": {
"type": "http",
"url": "https://learn.microsoft.com/api/mcp"
}
}
}CLI format (~/.copilot/mcp-config.json)
{
"mcpServers": {
"playwright": {
"type": "local",
"command": "npx",
"tools": ["*"],
"args": ["@playwright/mcp@latest", "--viewport-size=1024,768"]
},
"microsoftdocs": {
"type": "http",
"url": "https://learn.microsoft.com/api/mcp"
}
}
}Key differences:
- Top-level key:
"servers"(VS Code) vs"mcpServers"(CLI) - Local servers: CLI requires
"type": "local"— VS Code infers it from"command" - Tool filtering: CLI supports
"tools": ["*"](or specific tool names) — VS Code uses"tools"differently in its config - Comments: VS Code's
mcp.jsonsupports JSON with comments (JSONC) — CLI does not
Workflow
Step 1 — Read the source of truth
Read .vscode/mcp.json from the repo. This is the canonical config, maintained by the team and checked into git.
Step 2 — Read the user's CLI config
Read ~/.copilot/mcp-config.json. This may contain servers from other projects — do not overwrite them.
On Windows: $env:USERPROFILE\.copilot\mcp-config.json
On macOS/Linux: ~/.copilot/mcp-config.json
The location can be overridden by the user via --config-dir flag or XDG_CONFIG_HOME env var. Check if either is set.
Step 3 — Convert and merge
For each server in .vscode/mcp.json:
- Local servers (have
"command"): Add"type": "local"and"tools": ["*"]for CLI format - HTTP servers (have
"type": "http"): Copy as-is — format is identical - Skip any server that already exists in the CLI config with matching
"command"and"args"(or matching"url"for HTTP types) - Warn if an existing CLI server has the same name but different config — ask the user whether to overwrite
Step 4 — Write the updated CLI config
Write the merged config back to ~/.copilot/mcp-config.json. Preserve JSON formatting (2-space indent).
Step 5 — Verify
Run copilot --prompt "list available MCP tools" --allow-all-tools -p "run /mcp show and exit" or instruct the user to run /mcp show in their next CLI session to confirm the servers are available.
Important Rules
- Never delete servers from the CLI config that aren't in the repo's VS Code config — the user may have servers from other projects
- Always back up the CLI config before writing: copy to
mcp-config.json.bak - Strip comments when reading VS Code's JSONC file — parse it as JSONC, not strict JSON
- Preserve user's existing servers — merge, don't replace
- Report what changed — list servers added, updated, or skipped
Reverse Sync (CLI → VS Code)
If the user added new MCP servers via CLI (/mcp add) that should also be available in VS Code:
- Read
~/.copilot/mcp-config.jsonfor any servers not in.vscode/mcp.json - Convert: remove
"type": "local"and"tools"fields (VS Code infers these) - Add to
.vscode/mcp.jsonunder"servers"key - Preserve existing comments in the JSONC file — add new servers at the end of the
"servers"block
Future-Proofing
The CLI and VS Code MCP config formats may converge in the future. Before syncing:
- Check if CLI now reads
.vscode/mcp.json— look for a.vscode/mcp.jsonor.github/copilot/mcp.jsonentry in CLI docs orcopilot helpoutput - Check if the top-level key has changed — CLI may adopt
"servers"or VS Code may adopt"mcpServers" - Check for a unified config path — a
.github/mcp.jsonor similar repo-level config that both platforms read
If any of these converge, update this skill and simplify the sync process.
Reference
- VS Code MCP docs
- CLI MCP docs
- Custom agents config (tools + MCP)
- CLI flag:
--additional-mcp-config @<file-path>— loads extra MCP config for one session without modifying~/.copilot/mcp-config.json
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

