Skip to content

feat(mcp): give every native chat the host's MCP servers, with an Orca group in /mcp - #48707

Merged
AmoabaKelvin merged 5 commits into
mainfrom
mcp-chat-delivery
Nov 25, 2026
Merged

AmoabaKelvin merged 5 commits into
mainfrom
mcp-chat-delivery

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

When you add an MCP server once in Orca, every new chat on that computer can use it, unless you turn it off for that agent or that project. The chat's /mcp list shows those servers under "Orca", with a link to where you manage them. All of it is behind the MCP servers switch, which is still off.

Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​243 $\color{#cf222e}{\Huge{\mathbf{−}}}$​32 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​211
Prod 60 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​947 $\color{#cf222e}{\Huge{\mathbf{−}}}$​257 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​690

What Changed

  • Before: only a bot's chats got MCP servers from Orca: its own tools, through Orca's local relay. Other chats got only what each agent's own config set up.
  • After, with ORCA_MCP_SERVERS=1: every Claude, Codex, ACP and Pi chat also gets the host's server list (from feat(mcp): per-host MCP server list with the mcpServers RPC, behind ORCA_MCP_SERVERS #48631) at launch.
    • Filtering: a server is left out when it's off for that agent, or when the chat's workspace (its repo, or a folder workspace) isn't one it's on for.
    • Name clashes: a server is also left out when the agent's own config already has one with that name. The agent's own server runs instead. For Claude that means the launch account's user and folder-local servers plus the folder's .mcp.json. Other agents are checked against their user and project files, read with the readers from feat(mcp): read and move MCP servers from agents' own config files #48632. Codex also checks the account home's config.toml.
    • Relay: servers with saved headers or an Orca sign-in go through the relay. Every non-bot session shares one host token per Orca run, in a new ORCA_MCP_TOKEN; the bot identity variable is unchanged. Relay grants now name an owner (a bot or the host) and the folders the token may reach. Bot tools stay under /bot-tools/… and host-list servers are under /mcp-servers/…. The host's shared token is bound only by the computer-wide call limits, not the per-bot ones.
    • Token exposure: Claude and Pi configs name ${ORCA_MCP_TOKEN}, so only they get the token in env. Codex and ACP carry it in their MCP config, so their shell commands never see it.
  • Bots: a bot takes the host list only when the user opts it in. bots.tools.list answers hostMcpServers, and a new bots.tools.setHostMcpServers sets it. The bot's own tool wins a name clash. Changing the setting bumps the bot's tools epoch, so its running chats relaunch on their next turn.
  • Tray (desktop and phone): Claude and Codex rows for servers a chat got from the host list are tagged orca and grouped first as ORCA. A "Manage MCP servers" link opens the host's settings: pane mcp-servers on desktop, /h/<hostId>/mcp on the phone. It shows only when the host advertises mcp-servers.v1. The desktop list grows from 208 to 320 px so ORCA, PROJECT and CLAUDE.AI fit. The phone list's share of the screen goes from 0.4 to 0.5.
  • Blocked Claude: mcpServers.list gains agentProblems. Claude is marked blocked when its organization's managed settings refuse --mcp-config, which shows up as a cached flag refusal, a CLI exit with that refusal, or a failed tools check. Such a chat starts without the host's servers and gets no "your tools are off" note, since that note is meant for bots.
  • BotLaunchTools is renamed SessionMcpTools. The per-agent emitters are unchanged.

Why

This is PR 3 of the MCP-servers-in-Orca plan: the host list does nothing until sessions get it. The change widens the seam bots already use (resolveSessionToolServers → basis.toolServers()) to every session instead of building a second delivery path. It reuses the relay, the saved-credential store and the emitters.

Linked Issue

N/A, part of the MCP servers fleet (stacked work after #48631 and #48632).

Visual Proof

Before: today's tray has no Orca group or footer link. The mock is next to the built result, using the same fixture data (desktop: component fixture; phone: MobileNativeChatMcpPanel rendered through the web bundle).

Mock Built
Desktop dark mock-desktop-dark.png real-desktop-dark.png
Desktop light mock-desktop-light.png real-desktop-light.png
Phone dark mock-phone-dark.png real-phone-dark.png
Phone light mock-phone-light.png real-phone-light.png

Testing

I ran a hidden serve built from this branch on macOS, on a scratch profile. Claude ran with no spend: the real CLI (2.1.332) against a fake Anthropic API. A fake MCP server only answered when it saw the x-api-key header.

  • Switch on: I added a server with a saved x-api-key header and a command server, then opened a Claude chat in a repo. agentSession.mcp listed probe as connected, 1 tool, source: "orca". The upstream server received x-api-key: s3cret from the relay. Claude's argv carried only "authorization":"Bearer ${ORCA_MCP_TOKEN}", and its env had ORCA_MCP_TOKEN, not the bot token.

  • Turned off: I turned probe off for Claude and the command server off for that repo. The next chat listed neither.

  • Switch off: I restarted the serve without the switch. With the same list still on disk, a new chat's Claude process had no --mcp-config and no ORCA_MCP_TOKEN, and mcpServers.list refused with mcp_servers_off.

  • Automated tests:

    • session-mcp-launch.test.ts:
      • With the switch off, nothing is added, even for an opted-in bot.
      • With it on, servers are filtered by agent and workspace, relayed servers use /mcp-servers/ and ORCA_MCP_TOKEN, and the bot's own server wins a clash.
      • A hostMcpServers key the bot writes into its own tools file grants nothing.
    • bot-tool-relay.test.ts: a token reaches only the folders its grant names, and the host token names no bot.
  • Not run: Windows, Linux, SSH, and live Codex, ACP or Pi chats. Those launch paths pass typecheck and run through the same resolver.

  • 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

Performance

None while the switch is off: the resolver returns before reading anything. With it on, each chat launch reads the host list file once. When the list gives the chat at least one server, the launch also reads the agent's own MCP config files (user and project) to check for name clashes. Nothing runs per turn or per keystroke.

Risk

Level: Medium

  • Switch off: with ORCA_MCP_SERVERS unset, launches are unchanged. Bot launches still grant {bot folder} with ORCA_BOT_TOOLS_TOKEN and /bot-tools/ URLs. Non-bot launches get nothing, the host advertises no mcp-servers.v1, and the tray shows no link.
  • Bot self-grant (found in review, fixed here): the approved design kept the bot opt-in as a key in the bot's own .orca/bot-tools.json. That file sits in the bot's home, which its agent writes every turn. A bot, or a prompt injection reaching it, could have turned it on itself and reached every host server, including the user's Orca sign-ins through the relay. A bot's own tools can't reach those, because its credentials are sealed per folder.
    • The opt-in is now a hostMcpServers field on the bot record.
    • Only bots.tools.setHostMcpServers sets it. That method refuses calls from the bot's own chat and runs, and from Look around.
    • bots.update can't set it (its params are strict and don't list it), and it isn't written to or read back from the bot's bot.json.
    • Launches and Orca's own tool checks read the record, never the tools file.
  • Relay: the relay grant now carries a set of folders instead of one. A bot's health check or sign-in re-grants with its current opt-in, so it doesn't cut off host servers in that bot's running chats.
  • Known gaps (follow-ups):
    • The "Manage MCP servers" link points at the Settings pane and phone route that the desktop-ui and mobile-ui PRs add. The switch stays off until they land.
    • Name clashes coming only from Codex -c overrides in the user's own command settings aren't detected.
    • Host-list changes apply to new sessions. The running-session restart offer comes in the terminal-delivery PR.
  • Back out: a plain revert. Nothing is migrated. With the switch off, no file is written beyond what feat(mcp): per-host MCP server list with the mcpServers RPC, behind ORCA_MCP_SERVERS #48631 already writes.

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

  • Security: the relay checks a token's path scope; non-bot sessions never get the bot identity variable; secrets never go on argv.
  • Cross-platform: paths go through resolve/join. Windows cmd /c shims for stdio servers are unchanged (claudeServerConfig).
  • Remote: launches resolve on the execution host, which reads its own list.
  • Mobile: the phone tray gets the group and link, gated on the routed host's capability.
  • Backwards compatibility: older hosts lack mcp-servers.v1, so the link stays hidden. New fields are optional.

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)

…a group in /mcp

Chats get the host's MCP server list at launch, filtered by agent and
workspace and skipping names the agent's own config already uses. Servers
with saved values go through the relay under one host token in
ORCA_MCP_TOKEN. Bots keep their own tools and take the host list only when
the user opts them in on the bot's record. Behind ORCA_MCP_SERVERS: with
the switch off, launches are unchanged.
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes add host MCP server selection for sessions, including bot opt-in and workspace filtering. Session tool construction supports host and bot relay folders. ACP, Claude, Codex, and Pi launch paths use the selected servers. RPC methods expose bot host-server settings and Claude configuration status. Desktop and mobile MCP trays link to host MCP settings, and Orca servers receive updated labels and grouping.

Merge Risk: Low · up to ad580 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: giving every native chat the host's MCP server list, plus an Orca group in the /mcp tray. The changeset adds host-list delivery for Claude, Codex, ACP and Pi sessions,…
Description check Passed The description follows the template sections: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checkli…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: giving every native chat the host's MCP server list, plus an Orca group in the /mcp tray. The changeset adds host-list delivery for Claude, Codex, ACP and Pi sessions, the Orca tray group, and the bot opt-in. The title is specific and matches the primary change.

Full details: Description check

Explanation

The description follows the template sections: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. It explains the before/after behavior, the mechanism, the risk and back-out plan, and the performance impact. The Linked Issue section says N/A and gives a reason, and the AI Disclosure and Review sections are empty. The template asks for a linked issue for outside contributors. The author appears to be a maintainer, so the empty AI Disclosure section is allowed. Some checklist items remain unchecked, including lint, typecheck, test and build, and the small-PR item. Those are reviewer concerns, not template gaps.

  • 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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d4947e17-537d-4570-8d9d-4147de39b3bd
Commits

Reviewing files that changed from the base of the PR and between 528bca8 and ad580d1.

Files selected for processing: 2

  • src/main/runtime/rpc/methods/bots-tools-host-mcp.test.ts
  • src/main/runtime/rpc/methods/bots-tools-host-mcp.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a71ad01c-36b5-4997-bfb4-577f4f590b0f
Commits

Reviewing files that changed from the base of the PR and between 5ff8397 and d0d2d64.

Files ignored due to path filters: 1

  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
Files selected for processing: 59

  • config/main-blocking-helper-baseline.txt
  • mobile/src/i18n/locales/en.json
  • mobile/src/session/native-chat/agent-session/mobile-structured-agent-session-host-support.ts
  • mobile/src/session/native-chat/mcp/MobileNativeChatMcpPanel.tsx
  • mobile/src/session/native-chat/mcp/MobileNativeChatMcpTray.tsx
  • mobile/src/session/native-chat/mcp/mobile-native-chat-mcp-panel-styles.ts
  • mobile/src/session/native-chat/mcp/mobile-native-chat-mcp-server-copy.ts
  • mobile/src/session/native-chat/mcp/use-mobile-structured-mcp-panel.ts
  • src/main/acp/launch/acp-structured-launch-resolution.ts
  • src/main/bots/bot-launch-tools.ts
  • src/main/bots/bot-structured-session-wiring.ts
  • src/main/bots/bot-tools-acp.ts
  • src/main/bots/bot-tools-claude-check.ts
  • src/main/bots/bot-tools-claude.ts
  • src/main/bots/bot-tools-codex.test.ts
  • src/main/bots/bot-tools-codex.ts
  • src/main/bots/bot-tools-file.test.ts
  • src/main/bots/bot-tools-file.ts
  • src/main/bots/bot-tools-host.ts
  • src/main/bots/bot-tools-pi.ts
  • src/main/bots/tool-relay/bot-tool-relay-admission.ts
  • src/main/bots/tool-relay/bot-tool-relay-grants.ts
  • src/main/bots/tool-relay/bot-tool-relay.test.ts
  • src/main/bots/tool-relay/bot-tool-relay.ts
  • src/main/claude/structured/launch/claude-bot-session-options.ts
  • src/main/claude/structured/launch/claude-structured-launch-resolution.ts
  • src/main/codex/structured/launch/codex-structured-launch-resolution.ts
  • src/main/ipc/pty/host-env/inherited-orca-identity-env.ts
  • src/main/mcp-servers/agent-own-mcp-server-names.ts
  • src/main/mcp-servers/mcp-agent-problems.ts
  • src/main/mcp-servers/mcp-host-list.ts
  • src/main/mcp-servers/session-host-mcp-delivery.ts
  • src/main/mcp-servers/session-mcp-launch.test.ts
  • src/main/mcp-servers/session-mcp-launch.ts
  • src/main/mcp-servers/session-mcp-tools.ts
  • src/main/native-chat/agent-session-wire/host/structured-agent-session-host-types.ts
  • src/main/pi/rpc/launch/rpc-launch-resolution.ts
  • src/main/runtime/agent-session/installation/structured-agent-session-runtime-contract.ts
  • src/main/runtime/agent-session/installation/structured-claude-runtime-adapter.ts
  • src/main/runtime/agent-session/launch/structured-agent-launch-composition.ts
  • src/main/runtime/rpc/methods/bots-tools-host-mcp.ts
  • src/main/runtime/rpc/methods/bots-tools.ts
  • src/main/runtime/rpc/methods/mcp-servers.ts
  • src/main/runtime/rpc/methods/rpc-method-registry.ts
  • src/main/runtime/rpc/methods/structured-sessions/catalog/structured-agent-session-mcp.ts
  • src/main/runtime/rpc/server/runtime-rpc-mobile-bot-methods.ts
  • src/renderer/src/components/native-chat/mcp/NativeChatMcpTray.fixture.tsx
  • src/renderer/src/components/native-chat/mcp/NativeChatMcpTray.tsx
  • src/renderer/src/components/native-chat/mcp/native-chat-mcp-server-text.ts
  • src/renderer/src/components/settings/navigation/open-mcp-servers-settings.ts
  • src/renderer/src/components/settings/navigation/settings-navigation-types.ts
  • src/renderer/src/i18n/locales/en.json
  • src/shared/agent-session/lifecycle/launch/agent-session-caller-env.ts
  • src/shared/agent-session/view/agent-session-mcp-server-presentation.ts
  • src/shared/bot-tools.ts
  • src/shared/bot-types.ts
  • src/shared/mcp-servers/mcp-servers.ts
  • src/shared/rpc-contract/bots-params.ts
  • src/shared/rpc-contract/bots-tools-params.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

const [user, local, project] = await Promise.all([
readClaudeInheritedTools(configDir),
readClaudeMirror(configDir, cwd),
readJson(join(cwd, '.mcp.json'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Include names from .mcp.json files in parent directories when filtering host servers.

claudeOwnServerNames reads only join(cwd, '.mcp.json'). Claude Code also loads project .mcp.json files from parent directories of the working directory. A host server whose name matches an ancestor server passes this filter and is delivered. The filter is meant to omit it.

Collect mcpServers keys from .mcp.json in cwd and in each ancestor directory, then merge them into the returned names. Use the same read helper for each file. The ancestor walk should match Claude Code's discovery rule, which reads parent directories up to the filesystem root.

await basis.toolServers(),
async () => [
...(await readCodexInheritedToolNames(codexHome)),
...(await agentOwnMcpServerNames('codex', environment, launchDirectory))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Read the same Codex home in the host-name lookup that the spawn uses.

The lookup at line 187 receives environment before the selected account home is applied. The spawn at line 239 applies that home as CODEX_HOME. When the selected account home differs from the home the lookup reads, the lookup can read a different config.toml from the one Codex loads. A host server can then be removed because another account defines the same name. A host server can also be kept when the selected account already defines that name, and Codex then merges the two entries.

The lookup must read the Codex home that the spawn uses. Derive the lookup environment from the selected account home, not from the pre-patch environment, so both reads resolve the same home.

}
const servers = await readAgentMcpServers(
configAgent,
{ homeDir: homedir(), env, platform: process.platform },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Data Integrity & Integration · Quick win

Resolve the agent's user config from the launch HOME, not the host home.

agentOwnMcpServerNames passes homeDir: homedir() with the launch env. The resolvers in agent-mcp-config-locations.ts build user-file paths from homeDir unless a specific variable such as CODEX_HOME or XDG_CONFIG_HOME overrides them. A launch that sets HOME to another directory makes the helper read the host user's config. Name collisions and omitted servers are then computed from the wrong files.

The inspected launch paths set CODEX_HOME and the XDG variables, not HOME. This case does not occur on those paths today. The defect still exists in the helper: its homeDir does not match the environment it receives. Derive the home directory from env.HOME when present, and fall back to homedir() only when it is not set.

})

describe('the MCP servers a chat launches with', () => {
it('adds nothing from the host list while the switch is off, even to a bot that opted in', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Disable the switch explicitly in the switch-off test.

If the test process starts with ORCA_MCP_SERVERS=1, this test launches with host servers enabled and fails its empty-server assertions. afterEach clears the variable only after the test finishes.

Clear the variable before this test launches. Keep the next test's explicit assignment to '1'.

export function openMcpServersSettings(hostScope: RuntimeClientTarget, serverId?: string): void {
const { openSettingsTarget, openSettingsPage } = useAppStore.getState()
openSettingsTarget({
pane: 'mcp-servers',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

The MCP management link selects a settings section that no page renders.

openMcpServersSettings targets pane mcp-servers. The settings page resolves that pane to the section id mcp-servers. No section in this tree uses that id, so the link cannot open a rendered MCP servers page. The serverId argument also does not affect the resolved section for this pane.

Hide the Manage MCP servers link until the MCP servers section is registered. Alternatively, register that section in this change. Either choice makes the link match the rendered settings pages.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 09944d2f-f69b-402d-8fbf-56e07c8cb33d
Commits

Reviewing files that changed from the base of the PR and between aeca235 and 528bca8.

Files ignored due to path filters: 1

  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
Files selected for processing: 7

  • config/main-blocking-helper-baseline.txt
  • src/main/mcp-servers/mcp-host-list.ts
  • src/main/mcp-servers/mcp-plugin-server-sync.ts
  • src/main/runtime/rpc/methods/mcp-servers.ts
  • src/renderer/src/i18n/locales/en.json
  • src/shared/bot-types.ts
  • src/shared/mcp-servers/mcp-servers.ts
Files skipped from review as they are similar to previous changes: 2

  • config/main-blocking-helper-baseline.txt
  • src/renderer/src/i18n/locales/en.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

folder = mcpHostListFolder()
): Promise<BotToolServer[]> {
// Read only: a launch never writes the list, even to give an entry edited outside Orca its id.
return botToolEntries(await readBotToolsSnapshot(folder)).flatMap(({ server, extras }) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

mcpServersForLaunch documents a read-only launch, but its read can write legacy headers.

mcpServersForLaunch says a launch never writes the host list. It calls readBotToolsSnapshot, though, and that call runs readMigratedSnapshot. When any server still stores headers inline, readMigratedSnapshot writes the file to move them into the credential store before it returns. A launch therefore writes for that input, contrary to the function's stated contract.

If that write fails, for example because the host folder is not writable, the error propagates out of mcpServersForLaunch. session-mcp-launch.ts catches it, logs a warning, and starts the session without host MCP servers. The chat still starts, but the host servers are missing for that session. This affects only lists that still contain inline headers.

Give the launch read a path that does not migrate or write, and keep the migration on the settings and write paths that already perform it. The migration should stay on the path that already performs it. Confirm that the launch read returns the same servers and filtering that mcpServersForLaunch uses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant