feat(settings): list the MCP servers Claude Code loads #5227
Closedjash90(GitHub profile, opens in a new tab)wants to merge 9 commits into
main fromrefs/pull/5227/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/server/src/mcpServers/McpServerInventory.ts line 239Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +199,21 @@199+ : remoteDetail(trimmedOrUndefined(entry.url));200+201+ entries.push({202+ providerInstanceId: ProviderInstanceId.make(instanceId),203+ harness: instance.driver,204+ harnessDisplayName: displayName,205+ name: sanitizeDisplayName(name),206+ transport,207+ ...(detail ? { detail } : {}),208+ configPath: sourcePath,209+ scope,210+ // The listing may be missing servers the CLI would load, so say so rather211+ // than presenting a partial list as the whole truth.212+ ...(complete ? {} : { status: "config unreadable" }),213+ // Claude Code has no per-server enable flag: everything it resolves is214+ // loaded.215+ enabled: true,216+ });217+ }218+219+ return {apps/server/src/mcpServers/McpServerInventory.ts line 106Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +80,21 @@80+/**81+ * Render a stdio server as its command line for display. Environment values are82+ * dropped entirely, and an argument is shown only if it both looks structural83+ * and is not the value of a credential-carrying flag.84+ *85+ * Two signals are needed because neither is sufficient. Shape alone catches86+ * `postgres://u:p@host/db` and `Authorization: Bearer …` but would happily87+ * print a bare `hunter2`; a flag-name blocklist alone catches `--token secret`88+ * but misses everything positional. Together they cover every form seen in real89+ * MCP configs except one: a bare positional secret that also looks like a word.90+ * That residue is accepted — this is a display string, and the alternative is91+ * showing nothing useful at all.92+ */93+export function stdioDetail(command: string, args: unknown): string {94+ const parts = Array.isArray(args)95+ ? args.filter((arg): arg is string => typeof arg === "string")96+ : [];97+ const rendered: Array<string> = [];98+ let redactNext = false;99+ for (const part of parts) {100+ if (redactNext) {apps/server/src/mcpServers/ClaudeMcpConfig.ts line 103OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +83,21 @@83+84+/**85+ * `.claude.json` also stores `projects.<path>.history`, one entry per prompt86+ * the user has ever typed, so on an active machine it reaches tens of87+ * megabytes. Reading and parsing that on every settings request would block the88+ * event loop; past this size the file is treated as unreadable instead.89+ */90+const MAX_CONFIG_FILE_BYTES = 8 * 1024 * 1024;91+92+const readJsonObject = Effect.fn("ClaudeMcpConfig.readJsonObject")(function* (93+ filePath: string,94+): Effect.fn.Return<JsonFileRead, never, FileSystem.FileSystem> {95+ const fileSystem = yield* FileSystem.FileSystem;96+ // A failed stat (permissions, transient FS error) is *not* the same as a97+ // missing file: the contents stay unknown, so report `unusable`.98+ const info = yield* fileSystem.stat(filePath).pipe(Effect.orElseSucceed(() => null));99+ if (info === null) {100+ const exists = yield* fileSystem.exists(filePath).pipe(Effect.orElseSucceed(() => true));101+ return exists ? { kind: "unusable" } : { kind: "absent" };102+ }103+ if (info.type !== "File") return { kind: "absent" };docs/user/mcp.md lines 19 to 21OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,21 @@1+# MCP servers2+3+**Settings → MCP** lists the MCP servers Claude Code loads, on every computer connected to T3 Code,4+so you can see them without opening a terminal or a config file.5+6+MCP (Model Context Protocol) servers give an agent extra tools: a database it can query, a browser7+it can drive, an issue tracker it can read. You configure them in Claude Code itself, and T3 Code8+reports what it finds.9+10+## What the page shows11+12+One collapsible group per connected computer, and inside it one group per Claude provider. Each row13+is a server:14+15+**Name** — the name Claude Code knows it by.16+**Transport** — `stdio` for a local command, `http` or `sse` for a remote server.17+**Scope** — `project` for a server from the repo's `.mcp.json`, `local` for one private to that18+ workspace. Servers available everywhere show no scope badge.19+**Detail** — the command line or the server address, with secrets removed. Environment values are20+ never shown, and anything in an argument or URL that could be a credential is replaced with `…`.21+ The full value stays in your config; T3 Code just does not carry it across the network.apps/server/src/mcpServers/McpServerInventory.ts lines 129 to 129OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +109,21 @@109+ // whenever the flag hints at a credential or the value itself looks unsafe.110+ const inlineSeparator = part.indexOf("=");111+ if (inlineSeparator > 0) {112+ const flag = part.slice(0, inlineSeparator);113+ const value = part.slice(inlineSeparator + 1);114+ if (!SAFE_ARGUMENT_PATTERN.test(flag)) {115+ rendered.push(REDACTED);116+ continue;117+ }118+ const unsafeValue = SECRET_HINT_PATTERN.test(flag) || !SAFE_ARGUMENT_PATTERN.test(value);119+ rendered.push(unsafeValue ? `${flag}=${REDACTED}` : part);120+ continue;121+ }122+ if (!SAFE_ARGUMENT_PATTERN.test(part)) {123+ rendered.push(REDACTED);124+ continue;125+ }126+ if (part.startsWith("-") && SECRET_HINT_PATTERN.test(part)) redactNext = true;127+ rendered.push(part);128+ }129+ return [command, ...rendered].join(" ");apps/server/src/mcpServers/McpServerInventory.ts lines 159 to 159OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +139,21 @@139+ try {140+ const url = new URL(rawUrl);141+ const credentialed = url.username.length > 0 || url.password.length > 0;142+ return `${url.protocol}//${credentialed ? `${REDACTED}@` : ""}${url.host}${url.pathname}`;143+ } catch {144+ // Not a parseable URL, so nothing can be said about which part is a secret.145+ return REDACTED;146+ }147+}148+149+/**150+ * Server names come from a config file we do not control. Control characters —151+ * notably the RTL override U+202E — would reorder how a row reads on screen,152+ * and an unbounded name is a wire and layout hazard. React escapes markup, so153+ * this is about what a name can *look* like, not injection.154+ */155+const MAX_DISPLAY_NAME_LENGTH = 120;156+157+function sanitizeDisplayName(name: string): string {158+ const stripped = name.replace(/[\p{Cc}\p{Cf}]/gu, "").trim();159+ const safe = stripped.length > 0 ? stripped : name.trim();apps/server/src/mcpServers/McpServerInventory.ts lines 142 to 142OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +122,21 @@122+ if (!SAFE_ARGUMENT_PATTERN.test(part)) {123+ rendered.push(REDACTED);124+ continue;125+ }126+ if (part.startsWith("-") && SECRET_HINT_PATTERN.test(part)) redactNext = true;127+ rendered.push(part);128+ }129+ return [command, ...rendered].join(" ");130+}131+132+/**133+ * Render a remote server's URL without its credentials. Query strings,134+ * fragments, and userinfo routinely carry API keys (`?api_key=…`,135+ * `https://token@host/mcp`), so only the addressable part is shown.136+ */137+export function remoteDetail(rawUrl: string | undefined): string | undefined {138+ if (rawUrl === undefined) return undefined;139+ try {140+ const url = new URL(rawUrl);141+ const credentialed = url.username.length > 0 || url.password.length > 0;142+ return `${url.protocol}//${credentialed ? `${REDACTED}@` : ""}${url.host}${url.pathname}`;
- apps/server/src/mcpServers/McpServerInventory.ts line 230OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +210,21 @@210+ // The listing may be missing servers the CLI would load, so say so rather211+ // than presenting a partial list as the whole truth.212+ ...(complete ? {} : { status: "config unreadable" }),213+ // Claude Code has no per-server enable flag: everything it resolves is214+ // loaded.215+ enabled: true,216+ });217+ }218+219+ return {220+ entries,221+ // Reported separately from the rows because an unreadable config often222+ // yields *no* rows at all, and then there is nothing to hang a status on.223+ unreadable: complete224+ ? []225+ : [226+ {227+ providerInstanceId: ProviderInstanceId.make(instanceId),228+ harnessDisplayName: displayName,229+ configPath,230+ },apps/server/src/mcpServers/McpServerInventory.ts line 176Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +143,21 @@143+ } catch {144+ // Not a parseable URL, so nothing can be said about which part is a secret.145+ return REDACTED;146+ }147+}148+149+/**150+ * Server names come from a config file we do not control. Control characters —151+ * notably the RTL override U+202E — would reorder how a row reads on screen,152+ * and an unbounded name is a wire and layout hazard. React escapes markup, so153+ * this is about what a name can *look* like, not injection.154+ */155+const MAX_DISPLAY_NAME_LENGTH = 120;156+157+function sanitizeDisplayName(name: string): string {158+ const stripped = name.replace(/[\p{Cc}\p{Cf}]/gu, "").trim();159+ const safe = stripped.length > 0 ? stripped : name.trim();160+ return safe.length > MAX_DISPLAY_NAME_LENGTH161+ ? `${safe.slice(0, MAX_DISPLAY_NAME_LENGTH)}…`162+ : safe;163+}
- apps/web/src/components/settings/McpServersSettings.tsx line 207OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +187,21 @@187+ connectionDotClassName(environment.connection.phase),188+ )}189+ />190+ <span className="truncate font-medium text-[13px]">{environment.label}</span>191+ {serverCount !== null ? (192+ <span className="ml-auto shrink-0 text-muted-foreground/70 text-xs">193+ {serverCount} {serverCount === 1 ? "server" : "servers"}194+ </span>195+ ) : null}196+ </button>197+198+ {collapsed ? null : (199+ <div id={panelId}>200+ {Option.isNone(prepared) ? (201+ <StatusLine>Not connected.</StatusLine>202+ ) : state.status === "loading" ? (203+ <StatusLine>Loading MCP servers…</StatusLine>204+ ) : state.status === "error" ? (205+ <StatusLine tone="error">{state.message}</StatusLine>206+ ) : groups.length === 0 ? (207+ <StatusLine {...(unreadableCount > 0 && !query.trim() ? { tone: "error" } : {})}>
- apps/server/src/mcpServers/McpServerInventory.ts line 114Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +90,21 @@90+ * Two signals are needed because neither is sufficient. Shape alone catches91+ * `postgres://u:p@host/db` and `Authorization: Bearer …` but would happily92+ * print a bare `hunter2`; a flag-name blocklist alone catches `--token secret`93+ * but misses everything positional. Together they cover every form seen in real94+ * MCP configs except one: a bare positional secret that also looks like a word.95+ * That residue is accepted — this is a display string, and the alternative is96+ * showing nothing useful at all.97+ */98+export function stdioDetail(command: string, args: unknown): string {99+ const parts = Array.isArray(args)100+ ? args.filter((arg): arg is string => typeof arg === "string")101+ : [];102+ const rendered: Array<string> = [];103+ let redactNext = false;104+ for (const part of parts) {105+ if (redactNext) {106+ redactNext = false;107+ // Redact whatever it looks like: a credential can start with `-`, so108+ // "it parses as a flag" is not evidence that it is one.109+ rendered.push(REDACTED);110+ continue;
- apps/server/src/mcpServers/McpServerInventory.ts line 75OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +55,21 @@55+const EMPTY_DISCOVERY: InstanceDiscovery = { entries: [], unreadable: [] };56+57+function harnessDisplayName(instance: ProviderInstanceConfig, fallback: string): string {58+ return instance.displayName?.trim() || fallback;59+}60+61+function trimmedOrUndefined(value: unknown): string | undefined {62+ if (typeof value !== "string") return undefined;63+ const trimmed = value.trim();64+ return trimmed.length > 0 ? trimmed : undefined;65+}66+67+const REDACTED = "…";68+/**69+ * Shape of an argument safe to echo verbatim: a flag, a package specifier, a70+ * subcommand, or a filesystem path (POSIX, home-relative, or Windows drive).71+ * Anything with other punctuation — a quoted header, a connection string, a72+ * token containing `+`, `$`, or `:` — fails and is redacted.73+ */74+const SAFE_ARGUMENT_PATTERN =75+ /^(?:-{0,2}[A-Za-z0-9]|[.~]?[\\/]|[A-Za-z]:[\\/])[A-Za-z0-9._/\\@_-]*$/;
- @@ -0,0 +283,21 @@283+ ) : null}284+ </div>285+ {server.detail ? (286+ <p className="truncate text-muted-foreground/70 text-xs" title={server.detail}>287+ {server.detail}288+ </p>289+ ) : null}290+ </div>291+292+ {configPath ? (293+ <button294+ type="button"295+ className="shrink-0 text-muted-foreground/70 text-xs hover:text-foreground"296+ title={configPath}297+ onClick={() => onCopyConfigPath(configPath)}298+ >299+ <span className="inline-flex items-center gap-1">300+ <CopyIcon className="size-3" aria-hidden />301+ {formatMcpConfigPath(configPath)}302+ </span>303+ </button>@@ -0,0 +235,21 @@235+ server={server}236+ onCopyConfigPath={copyConfigPath}237+ />238+ ))}239+ </div>240+ ))}241+ </>242+ )}243+ </div>244+ )}245+ </div>246+ );247+}248+249+function RowBadge({ children }: { children: string }) {250+ return (251+ <span className="shrink-0 rounded border border-border/60 px-1 text-[10px] text-muted-foreground/80 uppercase">252+ {children}253+ </span>254+ );255+}
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
050886b4-05b5-4882-b5f9-ca29b475efedYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
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