You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(mcp): read and move MCP servers from agents' own config files - #48632
People set up MCP servers inside each coding agent's own settings (Claude Code, Codex, Gemini and others). Orca is about to get one MCP server list of its own. This adds the pieces that find those agent-side servers, take them out of an agent's settings file safely when the user moves them into Orca, and read a pasted server config. Nothing calls these pieces yet.
Files
Added
Deleted
Net
Test
4
$\color{#1a7f37}{\Huge{\mathbf{+}}}$420
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$420
Prod
13
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1784
$\color{#cf222e}{\Huge{\mathbf{−}}}$17
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1767
What Changed
Three modules for the "MCP servers in Orca" feature. None is wired to a screen or RPC in this PR.
Readers for each agent's own MCP config:
Claude Code: user scope and per-project local scope in ~/.claude.json, plus the repo .mcp.json.
Codex: config.toml, from a CODEX_HOME the user set, else ~/.codex.
Gemini, OpenCode (1.x mcp.<name> and 2.x mcp.servers.<name>), Cursor, Copilot, Grok, Droid, Pi and Amp.
Entries are read into Orca's server shape. Rows merge across agents when the name and the whole definition match (URL or command line, headers, env). Orca's own bridge entries (orca mcp connect/exec), which a later PR writes into Grok, Cursor and Droid, are recognised and never listed.
Move and Copy service.
Move adds the server to Orca's list first, through an injected add. It then removes the matching entries from every agent file, and from Orca's managed Claude account profiles where the copy is identical.
Edits are text splices: the JSON parse tree for JSON, a line splice for TOML. Comments, key order and CRLF stay as they were.
Each splice is checked against the parsed file, and must equal the old config minus exactly those entries.
The edited file is published only if it still holds the bytes the edit was made from. A rolling .bak keeps the previous contents.
Claude's files are edited under the same lock Claude Code takes.
Claude local-scope servers stay limited to their repo or folder workspace in Orca. An agent copy that was switched off stays off for that agent.
parseMcpServersPaste in src/shared/bot-tool-paste.ts. It reads the Custom server field: a URL, a start command, an mcpServers JSON block (JSONC, a single entry, or a copied "name": {…} fragment), and claude mcp add, claude mcp add-json and codex mcp add lines. The bots parser parseBotToolPaste is unchanged.
An entry Orca can't run exactly as its agent does is left in the agent and never moved. That covers:
SSE servers;
values the agent fills in itself: ${VAR}, {env:VAR}, {file:…}, Gemini's $VAR, Pi's !cmd, and Codex's bearer_token_env_var;
an entry's own OAuth client;
tool allow and deny lists, in the entry or file-wide like Grok's disabled_mcp_tools;
a working folder of its own.
Why
The approved design lists servers found in agents under "In your agents", with Move to Orca and Copy to Orca. The Custom server field also has to accept pasted configs. These modules land on main first, so the wiring PR stacked on the host-list PR stays small.
Moving from Codex edits only Codex's own home. Orca's managed CODEX_HOME mirror already drops servers it mirrored before, so the change reaches managed homes on the next launch. Claude's managed account profiles only copy servers forward from ~/.claude.json and never remove one, which is why Move cleans those copies directly.
Linked Issue
N/A: part of the MCP servers fleet (task 2 of 10). There is no issue.
Visual Proof
N/A: no UI. The screens come in the desktop and mobile UI PRs.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
The tests cover the paste parser (JSON, CLI-line and refusal cases) and the TOML and JSON splices (dotted keys, inline entries, CRLF, the last table in a file). A fixture home with all ten agents' files checks discovery per agent. It also moves servers and checks the exact file bytes afterwards, the .bak contents, Claude profile copies (removed when identical, kept when the headers differ), local-scope workspaces, and refusal when an entry changed after it was listed. pnpm check:changed passes.
Gate-off equals main: nothing in production imports these modules yet. The only shared-file changes are the new parseMcpServersPaste export next to an untouched parseBotToolPaste, and the Claude config lock moved into claude-global-config-lock.ts with the same options and queue. The follow-up wiring calls the modules only from mcpServers.discover/move/copy, which refuse with mcp_servers_off while ORCA_MCP_SERVERS is unset.
Performance
None, because nothing calls this code yet. Once wired, it runs only when the MCP servers settings page asks for discovery, or when the user moves or copies a server. It reads about ten small files with non-blocking I/O.
Risk
The risky part is Move editing a user's agent config. Several guards stand between Move and a lost setting:
the parse-equality check;
the compare-and-swap write;
the .bak file;
Claude's own lock;
refusing entries Orca can't carry faithfully.
A plain revert backs it out. Nothing here persists state of its own.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Cross-platform: paths go through node:path; Windows quoted executable paths in a paste stay commands; CRLF is kept in TOML edits; the Windows read-only .bak handling matches the existing hooks writer. Remote hosts: these run on the execution host once wired, so each host reads its own agents' files.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
No actionable comments were generated in the recent review.
Walkthrough
The change adds discovery and parsing for MCP servers in multiple agent configuration formats. It adds operations to list, copy, move, and remove discovered servers, with checks for changed files and config locks. It also adds parsing for pasted JSONC configurations and Claude or Codex MCP add commands.
Merge Risk: Moderate · up to e2d19
The new MCP config import code is not yet wired into production. Several correctness edge cases remain open: a Move can overwrite a concurrent config save, can miss a stale entry, and can miss a disabled-state change, and some valid pasted configs are rejected. Address or explicitly accept these before merge.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Description check
The description follows the template sections: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, Review, Notes, and Checklist. It explains the three modules and why they…
Add a Linked Issue, or confirm the author is a maintainer who may skip it. Mark whether manual testing was done, or explain why it was not. Confirm that pnpm lint, typecheck, test, and build pass, or note that CI will cover them. The AI Dis…
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title "feat(mcp): read and move MCP servers from agents' own config files" matches the main change. The PR adds readers for agent MCP configs and a move service that removes entries from agent fil…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "feat(mcp): read and move MCP servers from agents' own config files" matches the main change. The PR adds readers for agent MCP configs and a move service that removes entries from agent files. It does not mention the paste parser, and the changes are not yet wired into production. The title is specific and accurate.
Full details: Description check
Explanation
The description follows the template sections: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, Review, Notes, and Checklist. It explains the three modules and why they land first. The Linked Issue section says there is no issue, which the template requires for outside contributors. The AI Disclosure section is empty. The Testing checkboxes for manual testing are unchecked, and the lint, typecheck, test, and build checklist item is unchecked. The Risk level is set to Low.
Resolution
Add a Linked Issue, or confirm the author is a maintainer who may skip it. Mark whether manual testing was done, or explain why it was not. Confirm that pnpm lint, typecheck, test, and build pass, or note that CI will cover them. The AI Disclosure section is blank. Fill it in, or state that it does not apply.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Check raw entry presence before treating an entry as deleted.
If a listed server gains an unsupported cwd field before removal, agentMcpConfigServersIn excludes it from current. Both listed and present are then empty. Line 94 returns without a stale-entry error, and moveAgentMcpServer reports success with the older imported definition.
Check the original key paths in the parsed config. In refuse mode, reject an existing entry that no longer normalizes. Continue to skip entries that are actually absent.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Data Integrity & Integration · Quick win
The removal guard ignores a disabled-state change made after listing.
moveAgentMcpServer adds the server with the scope captured at listing, then removes the agent entries by merge key. agentMcpServerMergeKey does not include disabled. If the user disables or enables the entry in the agent file while add is pending, removalFrom still matches it and removes it. The Orca server keeps the state captured at listing, so the user's change is lost without a refusal.
Require the removal guard to compare each matched entry's disabled state with the state captured in sources when the server was listed. On a mismatch, removeAgentMcpServerEntries should refuse the move when differing is 'refuse', and skip that entry when differing is 'skip'. Keep the merge-key comparison unchanged for other edits.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Honor escapes when detecting variable expansion.
On Darwin, claude mcp add demo -- node server.js --label \$HOME contains a literal $HOME argument. The tokenizer correctly consumes the escape, but this scan still reports an expansion and rejects the command.
Track escapes and both quote types consistently with the tokenizer. Keep unescaped $HOME rejected.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Recognize JSONC after leading comments.
A paste that starts with // copied configuration followed by {"command":"npx","args":["server"]} enters the command path. The object line then fails in parseBotToolPaste, although the input is a supported JSONC configuration.
Detect the configuration after leading JSONC comments. Keep quoted executable paths on the command path.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Keep newlines inside quoted arguments.
A claude mcp add-json command can contain a single-quoted, formatted JSON argument. This split separates that argument into commands. The first fragment then fails with an unclosed quote.
Split command lines only outside quoted arguments. Preserve support for several complete commands in one paste.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
…'s agent folders
v1.4.279 reads and moves MCP servers in agents' own config files
(upstream stablyai#48632). In an app profile, Codex and the gemini settings live
in the profile's agent folders, so the fallback paths go through
agentHomeDirIn like the other agent paths. The home path scan also
allows v1.4.279's new Antigravity paths in ~/.gemini: agy has no folder
variable.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
People set up MCP servers inside each coding agent's own settings (Claude Code, Codex, Gemini and others). Orca is about to get one MCP server list of its own. This adds the pieces that find those agent-side servers, take them out of an agent's settings file safely when the user moves them into Orca, and read a pasted server config. Nothing calls these pieces yet.
What Changed
Three modules for the "MCP servers in Orca" feature. None is wired to a screen or RPC in this PR.
Readers for each agent's own MCP config:
~/.claude.json, plus the repo.mcp.json.config.toml, from aCODEX_HOMEthe user set, else~/.codex.mcp.<name>and 2.xmcp.servers.<name>), Cursor, Copilot, Grok, Droid, Pi and Amp.Entries are read into Orca's server shape. Rows merge across agents when the name and the whole definition match (URL or command line, headers, env). Orca's own bridge entries (
orca mcp connect/exec), which a later PR writes into Grok, Cursor and Droid, are recognised and never listed.Move and Copy service.
add. It then removes the matching entries from every agent file, and from Orca's managed Claude account profiles where the copy is identical..bakkeeps the previous contents.parseMcpServersPasteinsrc/shared/bot-tool-paste.ts. It reads the Custom server field: a URL, a start command, anmcpServersJSON block (JSONC, a single entry, or a copied"name": {…}fragment), andclaude mcp add,claude mcp add-jsonandcodex mcp addlines. The bots parserparseBotToolPasteis unchanged.An entry Orca can't run exactly as its agent does is left in the agent and never moved. That covers:
${VAR},{env:VAR},{file:…}, Gemini's$VAR, Pi's!cmd, and Codex'sbearer_token_env_var;disabled_mcp_tools;Why
The approved design lists servers found in agents under "In your agents", with Move to Orca and Copy to Orca. The Custom server field also has to accept pasted configs. These modules land on main first, so the wiring PR stacked on the host-list PR stays small.
Moving from Codex edits only Codex's own home. Orca's managed
CODEX_HOMEmirror already drops servers it mirrored before, so the change reaches managed homes on the next launch. Claude's managed account profiles only copy servers forward from~/.claude.jsonand never remove one, which is why Move cleans those copies directly.Linked Issue
N/A: part of the MCP servers fleet (task 2 of 10). There is no issue.
Visual Proof
N/A: no UI. The screens come in the desktop and mobile UI PRs.
Testing
The tests cover the paste parser (JSON, CLI-line and refusal cases) and the TOML and JSON splices (dotted keys, inline entries, CRLF, the last table in a file). A fixture home with all ten agents' files checks discovery per agent. It also moves servers and checks the exact file bytes afterwards, the
.bakcontents, Claude profile copies (removed when identical, kept when the headers differ), local-scope workspaces, and refusal when an entry changed after it was listed.pnpm check:changedpasses.Gate-off equals main: nothing in production imports these modules yet. The only shared-file changes are the new
parseMcpServersPasteexport next to an untouchedparseBotToolPaste, and the Claude config lock moved intoclaude-global-config-lock.tswith the same options and queue. The follow-up wiring calls the modules only frommcpServers.discover/move/copy, which refuse withmcp_servers_offwhileORCA_MCP_SERVERSis unset.Performance
None, because nothing calls this code yet. Once wired, it runs only when the MCP servers settings page asks for discovery, or when the user moves or copies a server. It reads about ten small files with non-blocking I/O.
Risk
The risky part is Move editing a user's agent config. Several guards stand between Move and a lost setting:
.bakfile;A plain revert backs it out. Nothing here persists state of its own.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Notes
Cross-platform: paths go through
node:path; Windows quoted executable paths in a paste stay commands; CRLF is kept in TOML edits; the Windows read-only.bakhandling matches the existing hooks writer. Remote hosts: these run on the execution host once wired, so each host reads its own agents' files.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)