Shared MCP servers
On this page
Use ccam mcp to add an MCP server once for all your accounts, and ccam mcp import to share a server you added inside one session with the others. Claude Code keeps user MCP servers in .claude.json, the same file that holds the account's login, so that file cannot be shared between accounts. ccam keeps shared servers in a group file, mcp.json, instead and hands it to every account of the group at launch.
Usage
ccam mcp list changes nothing and accepts --dry-run; add, add-json, remove and import refuse it and change nothing. -h or --help after any of them shows its help.
Adding a server
ccam mcp add fs -- npx -y @modelcontextprotocol/server-filesystem ~/code
ccam mcp add db -e PGHOST=localhost -- pg-mcpccam mcp add <name> -- <command> adds a local (stdio) server: Claude Code runs the command after --, with its arguments. -e or --env KEY=VALUE gives that command an environment variable and can be repeated.
ccam mcp add ctx --url https://mcp.context7.com/mcp --header 'Authorization: Bearer …'
ccam mcp add docs --url https://example.com/sse --transport sse--url adds a remote server that Claude Code reaches over the network. --transport sets how: http, the default, or sse. --header 'Name: value' sends an HTTP header with each request, such as a token, and can be repeated. add needs either a command after -- or --url, and fails otherwise with a command to run (after --) or --url is required. --header applies only to --url servers, and --env only to command servers.
A change applies from the next launch of each account; running sessions keep the servers they started with:
$ ccam mcp add fs -- npx -y @modelcontextprotocol/server-filesystem ~/code
✓ fs added in group default — applies from the next launchAdding a name the group already has replaces its definition and prints updated instead of added. Servers reach an account only if it is in that group and the group shares MCP (ccam group set <group> --add mcp); when the group does not, add says so.
Adding a server from JSON
ccam mcp add-json gh '{"type":"http","url":"https://api.githubcopilot.com/mcp/"}'ccam mcp add-json takes the same JSON as claude mcp add-json. The definition must be an object with a command or a url.
Choosing the group
ccam mcp add tools -g team -- tools-mcp-g or --group puts the server in another group. Without it, add, add-json and remove use the only group that some account shares MCP through, otherwise default. import always uses the group the account shares MCP through, and list shows every group, so -g does not change them.
Listing and removing servers
ccam mcp list
ccam mcp remove ctxccam mcp list shows the servers of every group:
$ ccam mcp list
group default (work, side)
ctx http https://mcp.context7.com/mcp
fs stdio npx -y @modelcontextprotocol/server-filesystem /home/me/code
only in account work: pg
only in account side, for /home/me/code/app only: notesBelow the groups, it names every server that does not reach the other accounts:
only in account work: pgfor a server an account added for itself;only in account side, for /home/me/code/app only: notesfor one added for one folder (plainclaude mcp add, see below);account work has its own …, used in its sessions in place of the group'swhen an account's own server has a group server's name;- this folder's
.mcp.json, with the accounts whose approval it iswaiting for approval in; - servers that are
in no account, only in ~/.claude.json (plain claude's), with theccam migrate --mcpcommand that copies them.
ccam mcp remove ctx removes the server from the group, and from the copies that Remote Control launches made in the accounts' .claude.json.
Sharing an account's own servers
ccam mcp import work
ccam mcp import work gh --forceccam mcp import work moves the servers that only work has, including those it has for one folder only, into the group it shares MCP through, and removes them from its .claude.json after a backup. A server whose name the group already uses for a different definition is skipped. --force replaces the group's definition instead, after saving the old mcp.json, and --keep-local leaves the entries in the account's .claude.json (how).
How it works
The files involved:
~/.local/share/ccam/groups/<group>/mcp.json: the shared servers,{"mcpServers": {…}}, the format--mcp-configreads. It is written through a temporary file and a rename, with mode0600, because server entries often carry API keys, and only under the lock<group>/.mcp.json.lock, so twoccam mcp addcommands run at the same time both keep their servers.~/.local/share/ccam/profiles/<name>/.claude.json: Claude Code's own file with the account's servers. ccam reads only itsmcpServersvalue, scanning for that one key, and never parses the whole file on the launch path.~/.local/state/ccam/mcp/<name>/: theseenfile, thesync-stamp(with a hash of each copy ccam wrote, so it can tell a copy nobody changed from one you edited),sync-checked(what the sync strategy saw last),kept(the servers the account kept when it left MCP sharing) and.claude.jsonbackups.
There are two strategies, set by mcp_strategy in ~/.config/ccam/config.toml. The default is the flag strategy:
- ccam finds the account's MCP group and checks with one
statthat the group'smcp.jsonexists, without parsing it. - ccam puts
--mcp-config=<path>right afterclaude, before your own arguments, so your own--mcp-configor--strict-mcp-configstill apply on top. - ccam checks whether the account's
.claude.jsonchanged since the last launch, and only then parses its servers. - ccam replaces itself with Claude Code (
exec).
The argument goes right after claude, before yours:
The path is passed as one argument, --mcp-config=<path>, not as two. Claude Code's --mcp-config takes several values, so claude --mcp-config a.json "prompt" would read the prompt as a second config file and fail with MCP config file not found. The one-argument form avoids this, so a prompt or subcommand after it works. ccam reads Claude Code's subcommand from the arguments the way Claude Code does, skipping options together with their values, and leaves the flag out where Claude Code refuses it: for remote-control or rc (below), for a background-session command given first (attach, logs, stop, kill, respawn, rm) and for ccam work mcp list, get and remove. For those three, ccam names the group's servers on standard error instead:
ccam: `claude mcp list` sees only account work's own MCP servers; its sessions also load group default's: ctx, fs
See all of them with `ccam mcp list`; change the group's with `ccam mcp add|remove`.Every other subcommand and every session keeps the flag. Claude Code loads --mcp-config servers in addition to the account's own; on a name clash the entry in .claude.json wins. The flag strategy writes .claude.json only for Remote Control, when an account leaves MCP sharing or joins it again (below), and for ccam mcp import.
claude remote-control (rc) takes no --mcp-config, and its sessions read servers only from .claude.json. For ccam work rc, ccam leaves the flag out and, on a terminal, asks whether to copy the group's servers into .claude.json, with a backup, as the sync strategy does. It asks until a copy exists, then again only after the group's mcp.json changes or a copied server is gone (Remote Control). Because such a copy wins over --mcp-config on a name clash, ccam mcp add, add-json, remove and import update the copies that other accounts of the group hold:
$ ccam mcp add ctx --url https://mcp.context7.com/mcp
✓ ctx added in group default — applies from the next launch
✓ Updated the copy in account side's .claude.json (made for Remote Control)The ✓ Updated line appears only when a copy changed. A copy that an older version of ccam created is brought up to date the same way, and so is one after ccam migrate.
A server added inside a session with claude mcp add lands in that account's .claude.json only. Plain claude mcp add uses the local scope: the server loads for that one account in that one folder (-s user makes it available to the account in every folder). ccam cannot see this when it happens, because Claude Code has already replaced the ccam process, so it checks at the next launch. The seen file holds the modification time of .claude.json and the server names already reported. When the time differs, ccam compares the names with the group and prints a hint for each new server once, without waiting for input, with both strategies:
ccam: MCP servers that only account work has: pg
To share them with other accounts: ccam mcp import work pg
ccam: MCP servers that account work has for one folder only (claude mcp add without -s user): notes (/home/me/code/app)
To share them with other accounts, in every folder: ccam mcp import work notesThe hint also names an account's own server that has a group server's name, since the account's wins in its sessions.
With mcp_strategy = "sync", the servers appear in claude mcp list and /mcp as ordinary user servers, and ccam writes them into each account's .claude.json before launch:
- ccam compares the modification time of the group's
mcp.jsonwithsync-stamp, and the account's.claude.jsonwith what it saw last. If neither changed, nothing else happens. Otherwise it also checks that every group server is still in.claude.json, and puts back a copy that is gone (put back group default's MCP servers that were gone from account work's .claude.json: ctx). - It takes Claude Code's own lock, the folder
.claude.json.locknext to the file, created withmkdir. It waits up to 2 seconds and treats a lock older than 10 seconds as stale, as Claude Code's lock library does. - It saves the current
.claude.jsontobackups/in the state folder and keeps the newest 5. - It sets every group server in
mcpServers, removes servers it wrote before that the group no longer has, and writes the file atomically with its original mode, only when something changed. It changes or removes only the copies it wrote that nobody changed since. If the account has its own server with the same name as a group server, ccam keeps the account's server and says so once:account work has its own MCP servers fs, so group default's servers with those names are not copied there. - It records the new stamp with a hash of each copy, and Claude Code starts without
--mcp-config.
Sync is skipped, with ccam: account work is already running, skipping MCP sync, when a session of the account is running, however Claude Code was started, because Claude Code rewrites .claude.json while it runs. A failed sync prints ccam: MCP sync failed (launching anyway): … and launches anyway.
Leaving and joining
An account that stops sharing MCP (ccam group leave, ccam group set --remove mcp, ccam group remove --leave) keeps the group's servers: the plan copies them into its .claude.json, with a backup, and its own servers of the same names stay. With --fresh it gets none, and the plan lists the servers that stop loading. When it joins a group that has those servers again, the kept copies that nobody changed are removed, so the group's later edits reach it.
ccam mcp import moves an account's own servers into its group:
ccam reads the account's servers, its own and those it has for one folder only, and compares each one with the group's server of the same name, ignoring key order and spacing. A folder server becomes a group server for every folder (notes loaded for one folder of account work only; from the group, every account in it gets them in every folder); one name with two different folder definitions is refused. Plugin servers are not offered, since the plugin brings them. A server the group lacks or has with the same definition is copied. A different one is skipped, because the group's definition is what every other account uses:
Skipped gh: group default already has a different gh (`ccam mcp import work gh --force` replaces it)
✓ Copied to group default: pg
✓ Removed account work's own entries (.claude.json backed up)With --force the group's server is replaced, and the previous mcp.json is first saved to .ccam-backup/<time>/mcp.json inside the group folder. Then ccam removes the copied entries from the account's .claude.json, its own and the folder's in one write, under the same lock and after a backup in the state folder. ccam keeps the group's mcp.json locked from when it reads the file until those entries are removed, so nobody removes the server from the group in between. This is needed because the account's entry would win over the group's on a name clash. With --keep-local, the entries stay in the account's .claude.json.
Safety and edge cases
- Sign-ins. Servers that sign in with OAuth keep their tokens in each account's
.credentials.json(mcpOAuth), not in the server list, so sharing a server does not share its sign-in. Sign in once per account with/mcp. ccam never copies sign-ins, and neither doesccam migrate: a copied refresh token logs out every other holder.ccam extandccam doctorname the servers an account is not signed in to while another account is, andccam next --continuesays which ones the new account lacks. The group never receives a login file. - Running accounts.
importcopies to the group but leaves a running account's own entries and says so; run it again after the session ends. Sync skips running accounts. Both also detect Claude Code sessions started without ccam. - Copies for Remote Control. A running account's copy is not touched:
Note: account side is running, so the copy in its .claude.json stays as it was until its next Remote Control launch.Withmcp_strategy = "sync"nothing needs updating, because every launch syncs. - Broken files. If
.claude.jsonis not valid JSON, sync leaves it untouched and reports the error. If the lock cannot be taken in 2 seconds, ccam reportscould not lock … (Claude Code is writing the file). - Accounts that do not share MCP.
importrefuses and tells you to put the account in a group that shares MCP first (ccam group join <group> side). - Group names.
-gtakes a group name only; it becomes a folder undergroups/, so names such as../xare refused.