Skip to content

feat(mcp): per-host MCP server list with the mcpServers RPC, behind ORCA_MCP_SERVERS - #48631

Merged
AmoabaKelvin merged 8 commits into
mainfrom
mcp-host-list
Nov 25, 2026
Merged

AmoabaKelvin merged 8 commits into
mainfrom
mcp-host-list

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

Each computer Orca runs agents on gets its own list of MCP servers. A client can add a server, sign in to it once, choose which agents and workspaces get it, and remove it. All of this stays hidden behind a switch that's off by default. No screens yet; later PRs add them and deliver the servers to sessions.

Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​136 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​135
Prod 38 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1181 $\color{#cf222e}{\Huge{\mathbf{−}}}$​55 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1126

What Changed

  • Host list. A bot-tools-shaped file at <userData>/mcp-servers/.orca/bot-tools.json. It reuses the bot-tools file I/O, version and epoch, folder-keyed sealed credentials, and Orca's own OAuth sign-in exactly as they are. Each server's id, agentsOff, workspaces {later, on, off} and sharedProcess ride on the entry's extra keys, which bot-tools writes already keep. Workspace keys are a repo id or folder:<id>, never a worktree id. The consent for agents that read only their own MCP file (agentFiles) is a top-level key.
  • mcpServers.* RPC. Params are zod schemas in src/shared/rpc-contract/mcp-servers-params.ts, and the catalog is regenerated.
    • Working now: list, add (paste a URL or command, or editor config), details, update, remove, problems, cancelProblems, signIn.start/wait/finish/cancel, signOut, setAgentEnabled, setWorkspaces, setSharedProcess, agentFiles.allow.
    • Typed mcp_servers_not_yet until their PRs land: discover, move, copy, sessions.stale, sessions.restart.
    • Errors carry codes: mcp_servers_off, mcp_server_gone, mcp_server_name_taken, mcp_server_stale, mcp_server_no_sign_in, mcp_server_not_command.
  • Sign-in. Reuses the bots' owned sign-in attempts. Desktop on the same computer uses routed, phones use paste-back. add, and update to a new headerless URL, run the same OAuth discovery as bot tools, so a server that needs a sign-in gets Orca's.
  • problems. Reuses the bots' Claude Code / Codex CLI check over the host list. Until the relay-principals PR adds host grants, its relay grant uses a reserved owner (mcp-host-list). botOf() never returns a bot for that owner.
  • mcpServersChanged client event. Emitted after every change and when a host-list sign-in changes state (the sign-in change bus now carries its folder). It reaches local windows (notifier → preload → window event), paired desktops (renderer whitelist → window event) and phones (shared client event).
  • Phone allowlist. Every mcpServers.* method is routed to the execution host.
  • Capability mcp-servers.v1. Advertised only while the switch is on.

The switch. isMcpServersFeatureEnabled() returns true only when the host's own env has ORCA_MCP_SERVERS=1. It is read on every call, so a dev build, orca serve or orcad each decides for itself. Turn it on locally with ORCA_MCP_SERVERS=1 pnpm dev, or set it on a serve's environment.

Why

Orca has no MCP server list of its own; only bot folders have one. Every later PR in the MCP servers work (chat and terminal delivery, desktop and phone screens, import from agents, shared processes, plugins) builds on this list and this contract.

Reusing the bot-tools file format in its own folder keeps credentials, the seal, OAuth and the relay keyed by a folder path exactly as they are today. The alternative was refactoring every credential key from a folder to an opaque scope. That would have touched the seal binding and every bot's saved values.

Linked Issue

N/A. Internal feature work (MCP servers in Orca, first of about ten PRs); there is no issue to link.

Visual Proof

N/A. No UI in this PR; the desktop and phone screens come in later 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

macOS, against a hidden orca serve built from this branch, driven over RPC with a loopback MCP app that is also its own OAuth server:

  • Switch on. The capability is advertised. I ran add (command and OAuth URL), a refused taken name, list, paste-back sign-in (signed-in), signOut (signed-out, and mcp_server_no_sign_in on a command server), setAgentEnabled, setWorkspaces (a worktree key is refused), setSharedProcess (refused for HTTP), update of a command server to an OAuth URL (gets Orca's sign-in), a stale editor save (mcp_server_stale), remove, and remove again (mcp_server_gone). A real phone-protocol client (E2EE, clientKind: mobile) paired to the same serve called mcpServers.list through the phone allowlist. It heard one mcpServersChanged per change, including the sign-in completing.
  • Switch off (gate-off equals main). A fresh serve without the env var advertises no mcp-servers.v1, refuses mcpServers.list and mcpServers.add with mcp_servers_off, and creates no mcp-servers folder. Nothing outside mcpServers.* reads the list, and no session or agent file is touched by this PR.

Tests kept to persistence and security boundaries:

  • mcp-host-list.test.ts: a server's id, agents and workspaces, plus the agent-file consent, survive edits, a rename and a plain bot-tools write. Header values stay sealed. A switch flipped while the editor is open doesn't make its save stale. A hand-edited entry gets an id once, and an entry whose workspaces can't be read is on nowhere, never everywhere.
  • bot-tool-relay.test.ts: the host list's relay token reaches its tools but never names a bot.
  • The existing bot-tools file, OAuth, credentials and relay tests pass unchanged.

Performance

None, because it all runs only when a client calls mcpServers.*, and every method refuses at once while the switch is off. One listener is added to the existing sign-in change bus; it compares a folder path per sign-in change.

Risk

Level: Low

  • Riskiest part: the shared bot-tools write path. changeBotToolServers now goes through changeBotToolEntries, and extra keys can be set per entry. With no extras given, it carries them over by name and rename exactly as before; the existing bot-tools tests cover that.
  • Other shared-code changes: botToolsHome is split into toolsHomeFor (same object for bots). readBotToolDetails is split into botToolDetailsOf. The sign-in change listener now receives the folder; the bots' listener ignores it.
  • Reused synchronous I/O: the new host-list files read the same synchronous credential store bots use, so they get main-blocking-helper baseline rows with notes.
  • Mixed versions: older clients ignore the new event type, and older hosts don't advertise the capability.
  • Back out: a plain revert. With the switch off no state is written.

AI Disclosure

Review

Look closest at src/main/bots/bot-tools-file.ts (the shared write path) and src/main/mcp-servers/mcp-host-list.ts.

Known gap for the phone PR: a phone that reaches a remote host through the Mac relay doesn't get that host's mcpServersChanged. The same is true of every execution-host event today, such as botsChanged.

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 token boundary is kept. Header values are sealed as for bot tools. The phone never sends a URL for the host to fetch, only the returned query.
  • Cross-platform: paths go through node:path.
  • Remote: the list lives on and is served by the execution host.
  • Mobile: allowlisted, and gated by the capability.

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)

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The changes add host MCP server storage, settings, sign-in support, and RPC methods. Shared contracts define server data and request validation. Bot-tool file updates preserve unknown per-server keys. Runtime and renderer event paths propagate MCP server list changes.

Merge Risk: Low · up to d9868 · 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: a per-host MCP server list exposed through the mcpServers RPC, gated behind the ORCA_MCP_SERVERS switch. The changeset adds the host list storage, the RPC methods, sig…
Description check Passed The description follows the repository template and fills in most sections: ELI5, What Changed, Why, Testing with manual macOS results, Performance, Risk with level Low and a back-out plan, and Notes.…
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: a per-host MCP server list exposed through the mcpServers RPC, gated behind the ORCA_MCP_SERVERS switch. The changeset adds the host list storage, the RPC methods, sign-in helpers, and the feature gate, so the title matches the primary change. It is 84 characters, slightly long but still readable and specific.

Full details: Description check

Explanation

The description follows the repository template and fills in most sections: ELI5, What Changed, Why, Testing with manual macOS results, Performance, Risk with level Low and a back-out plan, and Notes. Gaps: the Linked Issue section says N/A with a reason, which the template does not allow for outside contributors, though the author marks the PR as internal. The Visual Proof N/A has a reason. The AI Disclosure section is empty, and the Review section lists files without a required item. The final checklist item for lint, typecheck, test, and build is unchecked with no note on CI status. The Review section's and Testing's automated test claims are reasonable. Overall the description is mostly complete.

  • 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

@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: 17679123-acdc-4cc4-adaa-d9b30fdaee5c
Commits

Reviewing files that changed from the base of the PR and between 315dacd and d986844.

Files ignored due to path filters: 1

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

  • config/main-blocking-helper-baseline.txt
  • src/main/bots/bot-settings-change-sources.ts
  • src/main/bots/bot-tool-credentials.ts
  • src/main/bots/bot-tool-details.ts
  • src/main/bots/bot-tool-entry-extras.ts
  • src/main/bots/bot-tool-sign-in-changed.ts
  • src/main/bots/bot-tools-file.ts
  • src/main/bots/bot-tools-host.ts
  • src/main/bots/tool-oauth/bot-tool-owned-sign-in.ts
  • src/main/bots/tool-relay/bot-tool-relay.test.ts
  • src/main/bots/tool-relay/bot-tool-relay.ts
  • src/main/mcp-servers/mcp-host-list-sign-in.ts
  • src/main/mcp-servers/mcp-host-list.test.ts
  • src/main/mcp-servers/mcp-host-list.ts
  • src/main/mcp-servers/mcp-servers-error.ts
  • src/main/mcp-servers/mcp-servers-feature.ts
  • src/main/runtime/client/events/runtime-notifier-contract.ts
  • src/main/runtime/construction/dark-switch-runtime-capabilities.ts
  • src/main/runtime/rpc/methods/bots-tools-owned-sign-in.ts
  • src/main/runtime/rpc/methods/bots-tools.ts
  • src/main/runtime/rpc/methods/mcp-servers-sign-in.ts
  • src/main/runtime/rpc/methods/mcp-servers.ts
  • src/main/runtime/rpc/methods/rpc-method-registry.ts
  • src/main/runtime/rpc/responses/rpc-response.ts
  • src/main/runtime/rpc/server/runtime-rpc-mobile-mcp-server-methods.ts
  • src/main/runtime/rpc/server/runtime-rpc-mobile-method-routing.ts
  • src/main/runtime/workspaces/catalog/runtime-workspace-catalog-events.ts
  • src/main/window/runtime-window-lifecycle.ts
  • src/preload/api/runtime/runtime-api.ts
  • src/preload/api/runtime/runtime-bridge.ts
  • src/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.ts
  • src/renderer/src/hooks/ipc-events/runtime-events/runtime-client-window-events.ts
  • src/renderer/src/lib/host-window-event.ts
  • src/renderer/src/lib/mcp-servers-changed-window-event.ts
  • src/renderer/src/lib/peer-mail-returned-window-event.ts
  • src/renderer/src/runtime/rpc/subscriptions/runtime-client-events.ts
  • src/shared/mcp-servers/mcp-servers.ts
  • src/shared/remote-runtime/session-graph/runtime-client-events.ts
  • src/shared/rpc-contract/mcp-servers-params.ts

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

// Resolved against this read; the version check inside the write proves it still holds, so the
// rename (which keeps a header server's credential id) and any new sign-in fit the stored entry.
const before = await entryById(folder, id)
const resolved = resolveBotToolInput(input, withSavedBotToolHeaders(folder, before.server))

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

Use a new credential when replacing OAuth with headers.

If an OAuth-backed server is saved with an explicit header, resolveBotToolInput returns headers without the OAuth credential ID. However, writeServers reuses the previous credential ID. changeBotToolCredentials then throws toolSignInManaged because that ID still contains OAuth data.

This blocks an HTTP configuration accepted by McpServerUpdate. Allocate a new header credential for this transition. Keep the existing credential ID for header-to-header edits so existing relay addresses continue to work.

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