Skip to content
Source
Sign inSign up
pingdotgg/t3code

Add cross-harness MCP server manager #4634

Closedm-de-graaff(GitHub profile, opens in a new tab)wants to merge 5 commits intomain fromrefs/pull/4634/headopened View on GitHub

What Changed

Adds a Settings → MCP page that inventories the MCP servers each harness loads on every connected computer, and lets one be switched off without hand-editing config files.

  • Contracts: mcpInventory.ts (McpServerInventoryEntry, McpServerInventory, McpServerEnabledPatch) and an EnvironmentMcpServersHttpApi group — GET /api/mcp-servers (orchestration read scope) and POST /api/mcp-servers/enabled (operate scope). disabledMcpServers is added to ClaudeSettings and CodexSettings.
  • Server: apps/server/src/mcpServers/ — Claude discovery reads .claude.json directly (the CLI's own claude mcp list health-checks every server over the network, far too slow for a settings page); Codex discovery shells out to codex mcp list --json, which already reports the enabled flag Codex honours natively, so no TOML parser is needed.
  • Enforcement at session launch: Claude gets strictMcpConfig plus an explicit server map (configured servers minus disabled, plus t3-code) — only once something is actually disabled, so a gap in the reader can never silently drop a server the CLI would have loaded. Codex gets -c mcp_servers.<name>.enabled=false overrides alongside the existing t3-code args, leaving config.toml untouched.
  • Web: McpServersSettings page + /settings/mcp route + sidebar entry, and a @t3tools/client-runtime/state/mcp fetch/toggle helper.
  • Server env values are never returned to clients — those blocks routinely hold API keys and this endpoint is reachable remotely.

Cursor, Grok, and OpenCode are deliberately out of scope: they run over ACP, which can add MCP servers to a session but has no lever to suppress the ones the agent loads from its own config. Listing them without a working switch would be misleading.

Structure follows #4630 (cross-harness skill manager) file-for-file — same inventory-endpoint + settings-page shape.

Why

T3 Code already acts as an MCP server (it injects t3-code into every session), but has no view of the servers the underlying CLIs load, and no way to turn one off. Today that means editing ~/.claude.json or ~/.codex/config.toml by hand — on a machine that is often being driven remotely through this exact GUI. MCP tool definitions also cost context on every turn, so switching off servers you are not using is worth doing per project.

Storing the disabled list (rather than an allow-list) keeps "a newly added server is on by default" true, and keeps the toggle out of the user's own config files.

Explicitly not included: a marketplace or install flow. Installing an MCP server means running an arbitrary command, and a one-click installer on a remotely reachable GUI is remote code execution with a trust model this app does not currently own.

UI Changes

New settings page: server list grouped by harness with transport badge, command line, config path, and an enable/disable switch. Screenshots of the page (all servers enabled, and one toggled off) are being attached in a follow-up comment — the page is new, so there is no "before" state.

Validation

  • vp test run apps/server/src/mcpServers apps/server/src/provider/Layers/ClaudeAdapter.test.ts apps/server/src/provider/Layers/codexLaunchArgs.test.ts apps/web/src/components/settings/McpServersSettings.test.ts
  • vp run --filter t3 typecheck, vp run --filter @t3tools/web typecheck, vp run --filter @t3tools/contracts typecheck, vp lint
  • Manually through the web dev environment: paired, opened Settings → MCP, saw both Claude servers from ~/.claude.json, toggled one off, and confirmed disabledMcpServers persisted to userdata/settings.json.
  • Pre-existing unrelated failures on Windows in ProviderInstanceRegistryLive.test.ts (POSIX path assertions) reproduce on a clean tree.
screenshot-1785152922498-0 screenshot-1785152939886-1

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes — attaching in a follow-up comment
  • I included a video for animation/interaction changes

Note

Medium Risk Touches authenticated remote APIs and session MCP wiring; Claude intentionally skips disable enforcement when config reads are incomplete, which can surprise users who expect toggles to always apply.

Overview Adds a cross-harness MCP server manager: contracts and HTTP (GET /api/mcp-servers, POST /api/mcp-servers/enabled), server discovery in apps/server/src/mcpServers/, and a Settings → MCP page with search, per-environment lists, and enable/disable switches.

Discovery reads Claude .claude.json (user/local scopes plus approved .mcp.json project servers) and runs codex mcp list --json for Codex. Inventory rows redact secret-looking stdio args and mark Claude rows non-toggleable when config is incomplete.

Persistence adds hidden disabledMcpServers on Claude/Codex settings; toggles patch explicit providerInstances or legacy providers.* blobs via planDisabledMcpServersWrite, using new updateSettingsWith for locked read-modify-write.

Session launch: when anything is disabled, Claude enables strictMcpConfig and passes an explicit filtered mcpServers map (plus t3-code); if config cannot be read fully, it falls back to CLI resolution so disables may not apply that run. Codex adds -c mcp_servers.<name>.enabled=false overrides alongside existing t3-code app-server args.

Cursor/Grok/OpenCode are intentionally omitted from inventory (no suppress lever over ACP).

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 15be076e8808d2ef524d6e41a2b8af5f0e67e9b1. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add cross-harness MCP server manager with inventory API and settings UI

  • Adds McpServerInventory discovery for Claude and Codex providers, reading MCP server configs across scopes (user, project, local) and spawning codex mcp list --json for Codex instances.
  • Adds two HTTP endpoints under EnvironmentHttpApi: GET /api/mcp-servers to list all MCP servers and POST /api/mcp-servers/enabled to toggle a server's enabled state.
  • Introduces a /settings/mcp route and McpServersSettings UI with per-environment inventory display, search/filter, grouped server rows, and optimistic enable/disable toggles.
  • Integrates MCP filtering into ClaudeAdapter and CodexAdapter: when servers are disabled, Claude sets strictMcpConfig and passes a filtered server map; Codex forwards -c mcp_servers.<name>.enabled=false TOML overrides.
  • Adds disabledMcpServers array field to ClaudeSettings and CodexSettings schemas, and a new updateSettingsWith atomic read-modify-write method to ServerSettingsService.
  • Risk: Claude MCP filtering silently falls back to CLI resolution if any config file is unreadable, which may result in servers appearing enabled that the user intended to disable.
Macroscope summarized 15be076.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 767524e5-59d6-455a-8c78-3478190ea5af

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      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
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      This PR introduces a new feature for cross-harness MCP server management, including new HTTP API endpoints, a new settings UI page, new contracts, and changes to how Claude and Codex sessions filter MCP servers at launch. The scope and behavioral impact warrant human review.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 15be076e8808d2ef524d6e41a2b8af5f0e67e9b1. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -0,0 +102,21 @@
      102+export const discoverClaudeMcpServerEntries = Effect.fn(
      103+ "McpServerInventory.discoverClaudeMcpServers",
      104+)(function* (
      105+ instanceId: string,
      106+ instance: ProviderInstanceConfig,
      107+ environment: NodeJS.ProcessEnv,
      108+ cwd: string | undefined,
      109+): Effect.fn.Return<ReadonlyArray<McpServerInventoryEntry>, never, McpInventoryEnv> {
      110+ const decoded = decodeClaudeSettings(instance.config ?? {});
      111+ if (decoded._tag === "None") return [];
      112+ const settings = decoded.value;
      113+
      114+ const { complete, definitions } = yield* readClaudeMcpServers(settings, environment, cwd);
      115+
      116+ const disabled = new Set(settings.disabledMcpServers);
      117+ const entries: McpServerInventoryEntry[] = [];
      118+ for (const { name, scope, sourcePath, definition: entry } of definitions) {
      119+ const transport = claudeTransport(entry);
      120+ const command = trimmedOrUndefined(entry.command);
      121+ const url = trimmedOrUndefined(entry.url);
      122+ const detail = transport === "stdio" && command ? stdioDetail(command, entry.args) : url;

      Remote inventory leaks URL secrets

      Medium Severity

      Stdio args are redacted for the remotely reachable inventory API, but HTTP/SSE detail is the raw url. Tokens or API keys in query strings (or path segments) are returned to clients unchanged, undercutting the same secret-exposure goal called out for env and flag values.

      Additional Locations (1)
      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 15be076e8808d2ef524d6e41a2b8af5f0e67e9b1. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -0,0 +183,21 @@
      183+ typeof projectEntry === "object" && projectEntry !== null
      184+ ? (projectEntry as Record<string, unknown>)
      185+ : undefined;
      186+
      187+ const mcpJsonPath = path.join(cwd, ".mcp.json");
      188+ const mcpJsonRead = yield* readJsonObject(mcpJsonPath);
      189+ const mcpJson = mcpJsonRead.kind === "object" ? mcpJsonRead.value : undefined;
      190+ if (mcpJsonRead.kind === "unusable") complete = false;
      191+ const approveAll = projectConfig?.enableAllProjectMcpServers === true;
      192+ const approved = new Set(readStringArray(projectConfig?.enabledMcpjsonServers));
      193+ const rejected = new Set(readStringArray(projectConfig?.disabledMcpjsonServers));
      194+ for (const [name, definition] of readServerMap(mcpJson?.mcpServers)) {
      195+ if (rejected.has(name) || (!approveAll && !approved.has(name))) continue;
      196+ byName.set(name, { name, scope: "project", sourcePath: mcpJsonPath, definition });
      197+ }
      198+
      199+ for (const [name, definition] of readServerMap(projectConfig?.mcpServers)) {
      200+ byName.set(name, { name, scope: "local", sourcePath: configPath, definition });
      201+ }
      202+
      203+ return { complete, definitions: [...byName.values()] };

      Strict mode drops missed project servers

      High Severity

      projects is keyed only with path.resolve(cwd) or the raw cwd. A miss (realpath//private//var drift, trailing slash, etc.) yields no local servers and no .mcp.json approvals, while complete stays true. With any disabledMcpServers entry, strictMcpConfig then replaces CLI resolution and silently omits servers the CLI would still load — the failure mode this path was written to avoid.

      Additional Locations (1)
      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 15be076e8808d2ef524d6e41a2b8af5f0e67e9b1. Configure [here](https://www.cursor.com/dashboard/bugbot).
    5. Closing in favor of #2829 (orchestration V2).

      #2829 deletes the V1 orchestration layer this PR builds on — apps/server/src/orchestration/**, provider/Layers/*Adapter.ts and provider/Services/** are removed and replaced by apps/server/src/orchestration-v2/**, with the IPC surface renamed to ORCHESTRATION_V2_WS_METHODS. The files this PR touches either no longer exist or are rewritten, so it can't be rebased — it would need reimplementing against the V2 adapters.

      This is not a judgement on the change itself. Several of these are real gaps we still want fixed; the base just moved out from under them.

      Once #2829 merges, please rebase onto main, port the change to the V2 equivalent, and reopen (or open a fresh PR). Ping me and I'll prioritise the review.

    6. juliusmarminge closed this

Sign in to join this conversation.