A desktop coding agent with free access to frontier models.
TypeScript
feat: Figma MCP routes
ogsamrat314d1011e6ca
diff --git a/apps/app/src/app/lib/omnirush-server.ts b/apps/app/src/app/lib/omnirush-server.tsindex 75f5ab32..8a245d24 100644--- a/apps/app/src/app/lib/omnirush-server.ts+++ b/apps/app/src/app/lib/omnirush-server.ts@@ -656,9 +656,12 @@ export type OmniRushMcpDecision = {reason?: string;id?: string;package?: string;- runtime?: "npm" | "pypi";+ runtime?: "npm" | "pypi" | "remote";title?: string;version?: string;+ /** runtime "remote": the address it reaches, and whether it signs in with OAuth. */+ url?: string;+ oauth?: boolean;sandbox?: boolean;renamed_to?: string;notes?: string[];@@ -669,12 +672,19 @@ export type OmniRushMcpPreset = {id: string;title: string;why: string | null;- runtime: "npm" | "pypi";+ runtime: "npm" | "pypi" | "remote";package: string;version: string | null;versions: string;command: string[];localPagesOnly: boolean;+ /** A remote server's exact address (runtime "remote"), and whether it signs in with OAuth. */+ url?: string | null;+ oauth?: boolean;+ /** How to set it up (account servers such as Figma). */+ setup?: string | null;+ /** Uses the person's own account: its sessions cannot be repeated. */+ account?: boolean;};/** The MCP list as the desktop last saw it (GET /workspace/:id/mcp). */diff --git a/apps/app/src/react-app/domains/settings/pages/mcp-supported-panel.tsx b/apps/app/src/react-app/domains/settings/pages/mcp-supported-panel.tsxindex 3ae1a8d3..bccde0d0 100644--- a/apps/app/src/react-app/domains/settings/pages/mcp-supported-panel.tsx+++ b/apps/app/src/react-app/domains/settings/pages/mcp-supported-panel.tsx@@ -3,16 +3,20 @@// presets) and this project's configured servers with the engine plugin's// decision for each: on (its version, and whether it runs in the sandbox) or// blocked with the reason. Remote and account-linked services are not-// supported: a session that used them could not be repeated.+// supported (a session that used them could not be repeated), with one+// exception the list names: Figma, listed apart with its setup.import { useState } from "react";-import { Loader2, Plus } from "lucide-react";+import { LogIn, Loader2, Plus } from "lucide-react";import type { OmniRushMcpDecision, OmniRushMcpPolicyView, OmniRushMcpPreset } from "../../../../app/lib/omnirush-server";import type { McpServerEntry } from "../../../../app/types";import { Button } from "@/components/ui/button";export const MCP_REMOTE_NOT_SUPPORTED =- "Remote services (Notion, Linear, GitHub, Slack and other sign-in connectors) are not supported: they answer from an outside account, so a session that used them could not be repeated.";+ "Other remote services (Notion, Linear, GitHub, Slack and other sign-in connectors) are not supported: they answer from an outside account, so a session that used them could not be repeated.";++export const MCP_ACCOUNT_NOTE =+ "These use your own account, so a session with them cannot be repeated from the project. Keys and sign-ins stay on this computer: never in a config file.";export const MCP_ENGINE_V2_NOTE ="MCP servers are off while the preview engine runs chats. Turn the preview engine off to use them.";@@ -26,6 +30,8 @@ export const MCP_BLOCKED_HINTS: Record<string, string> = {outside_project: "Point it at a folder or file inside the project.",version: "Leave the version out to use the supported one.",runner_missing: "Install Node.js (for npx) or uv (for uvx), then restart the app.",+ secret_missing: "Set the key in your environment, then restart the app.",+ remote_settings: "Remove the headers and settings: only the plain address is supported.",};export type McpServerState =@@ -48,7 +54,8 @@ export function mcpServerState(entry: Pick<McpServerEntry, "name" | "config">, d}if ((entry.config as { enabled?: unknown } | undefined)?.enabled === false) return { kind: "off" };const parts = [- decision.package && decision.version ? `${decision.package}@${decision.version}` : null,+ decision.runtime === "remote" ? decision.url ?? null : null,+ decision.runtime !== "remote" && decision.package && decision.version ? `${decision.package}@${decision.version}` : null,decision.sandbox ? "runs in the sandbox" : null,decision.renamed_to && decision.renamed_to !== decision.name ? `tools named ${decision.renamed_to}_…` : null,].filter((part): part is string => Boolean(part));@@ -68,17 +75,24 @@ export function PlainText(props: { text: string }) {);}-/** The command a preset adds, as one line. */-export function presetCommandLine(preset: Pick<OmniRushMcpPreset, "command">): string {+/** The command a preset adds, as one line (a remote server: its address). */+export function presetCommandLine(preset: Pick<OmniRushMcpPreset, "command"> & Partial<Pick<OmniRushMcpPreset, "url">>): string {+ if (!preset.command.length && preset.url) return preset.url;return preset.command.map((word) => (/^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replace(/'/g, "'\\''")}'`)).join(" ");}-/** Whether a configured entry already starts the preset's package. */-export function presetConfigured(preset: Pick<OmniRushMcpPreset, "id">, servers: Array<Pick<McpServerEntry, "name">>, decisions: OmniRushMcpDecision[]): boolean {+/** Whether a configured entry already starts the preset's package (an account server: that route of it). */+export function presetConfigured(preset: Pick<OmniRushMcpPreset, "id"> & Partial<Pick<OmniRushMcpPreset, "account" | "package">>, servers: Array<Pick<McpServerEntry, "name">>, decisions: OmniRushMcpDecision[]): boolean {+ if (preset.account) return decisions.some((decision) => decision.status === "allowed" && decision.id === preset.id && decision.package === preset.package);return servers.some((server) => server.name === preset.id)|| decisions.some((decision) => decision.status === "allowed" && decision.id === preset.id);}+/** A configured server that signs in with an account (Figma's remote server), from its decision. */+export function needsSignIn(decision: OmniRushMcpDecision | null | undefined): boolean {+ return Boolean(decision && decision.status === "allowed" && decision.runtime === "remote" && decision.oauth === true);+}+export function McpSupportedPanel(props: {policy: OmniRushMcpPolicyView;servers: McpServerEntry[];@@ -86,6 +100,8 @@ export function McpSupportedPanel(props: {busy: boolean;addPreset: (preset: OmniRushMcpPreset) => Promise<{ ok: boolean; error?: string }>;removeServer?: (name: string) => void;+ /** Starts the engine's own sign-in for a configured server (Figma's remote server). */+ signIn?: (name: string) => void;}) {const [adding, setAdding] = useState<string | null>(null);const [addError, setAddError] = useState<{ id: string; message: string } | null>(null);@@ -106,16 +122,18 @@ export function McpSupportedPanel(props: {);}- const add = async (preset: OmniRushMcpPreset) => {- setAdding(preset.id);+ const add = async (preset: OmniRushMcpPreset, key: string = preset.id) => {+ setAdding(key);setAddError(null);try {const result = await props.addPreset(preset);- if (!result.ok) setAddError({ id: preset.id, message: result.error ?? "Could not add this server." });+ if (!result.ok) setAddError({ id: key, message: result.error ?? "Could not add this server." });} finally {setAdding(null);}};+ const local = props.policy.supported.filter((preset) => !preset.account);+ const account = props.policy.supported.filter((preset) => preset.account);return (<div data-testid="mcp-supported-panel" className="mb-6 flex flex-col gap-5">@@ -152,11 +170,19 @@ export function McpSupportedPanel(props: {<p className="mt-0.5 text-xs text-dls-secondary">{server.source === "config.project" ? "From the project's opencode.json" : "From your global opencode config"}</p>) : null}</div>- {props.removeServer && server.source === "config.remote" ? (- <Button variant="ghost" size="sm" disabled={props.busy} onClick={() => props.removeServer?.(server.name)}>- Remove- </Button>- ) : null}+ <div className="flex shrink-0 items-center gap-1">+ {props.signIn && needsSignIn(decisionFor(server.name)) ? (+ <Button data-testid={`mcp-sign-in-${server.name}`} variant="outline" size="sm" disabled={props.busy} onClick={() => props.signIn?.(server.name)}>+ <LogIn size={13} />+ Sign in+ </Button>+ ) : null}+ {props.removeServer && server.source === "config.remote" ? (+ <Button variant="ghost" size="sm" disabled={props.busy} onClick={() => props.removeServer?.(server.name)}>+ Remove+ </Button>+ ) : null}+ </div></li>);})}@@ -164,12 +190,12 @@ export function McpSupportedPanel(props: {</div>) : null}- {props.policy.supported.length > 0 ? (+ {local.length > 0 ? (<div className="flex flex-col gap-2"><h3 className="text-sm font-medium text-foreground">Supported servers</h3><p className="text-xs text-dls-secondary">Local servers that work on this project's own files. Each runs a fixed version, inside the project's sandbox when it is on.</p><ul className="flex flex-col divide-y divide-dls-border rounded-xl border border-dls-border">- {props.policy.supported.map((preset) => {+ {local.map((preset) => {const configured = presetConfigured(preset, props.servers, props.policy.decisions);return (<li key={preset.id} data-testid={`mcp-preset-${preset.id}`} className="flex items-start justify-between gap-3 px-4 py-3">@@ -200,6 +226,40 @@ export function McpSupportedPanel(props: {</div>) : null}+ {account.length > 0 ? (+ <div data-testid="mcp-account-servers" className="flex flex-col gap-2">+ <h3 className="text-sm font-medium text-foreground">Servers that use your account</h3>+ <p className="text-xs text-dls-secondary">{MCP_ACCOUNT_NOTE}</p>+ <ul className="flex flex-col divide-y divide-dls-border rounded-xl border border-dls-border">+ {account.map((preset) => {+ const key = `${preset.id}-${preset.package}`;+ const configured = presetConfigured(preset, props.servers, props.policy.decisions);+ return (+ <li key={key} data-testid={`mcp-preset-${key}`} className="flex items-start justify-between gap-3 px-4 py-3">+ <div className="min-w-0">+ <p className="text-sm font-medium text-foreground">{preset.title}</p>+ {preset.why ? <p className="mt-0.5 text-xs text-dls-secondary"><PlainText text={preset.why} /></p> : null}+ <code className="mt-1 block truncate rounded-md bg-dls-hover px-2 py-1 font-mono text-[11px] text-dls-secondary" title={presetCommandLine(preset)}>+ {presetCommandLine(preset)}+ </code>+ {preset.setup ? <p data-testid={`mcp-setup-${key}`} className="mt-1 text-[11px] text-dls-secondary"><PlainText text={preset.setup} /></p> : null}+ {addError?.id === key ? <p className="mt-1 text-xs text-red-11">{addError.message}</p> : null}+ </div>+ {configured ? (+ <span className="shrink-0 pt-1 text-xs text-dls-secondary">Added</span>+ ) : props.canAdd ? (+ <Button variant="outline" size="sm" className="shrink-0" disabled={props.busy || adding !== null} onClick={() => void add(preset, key)}>+ {adding === key ? <Loader2 size={13} className="animate-spin" /> : <Plus size={13} />}+ Add+ </Button>+ ) : null}+ </li>+ );+ })}+ </ul>+ </div>+ ) : null}+<p data-testid="mcp-remote-not-supported" className="text-xs text-dls-secondary">{MCP_REMOTE_NOT_SUPPORTED}</p></div>);diff --git a/apps/app/src/react-app/domains/settings/pages/mcp-view.tsx b/apps/app/src/react-app/domains/settings/pages/mcp-view.tsxindex 2d6eb883..db5fee50 100644--- a/apps/app/src/react-app/domains/settings/pages/mcp-view.tsx+++ b/apps/app/src/react-app/domains/settings/pages/mcp-view.tsx@@ -553,17 +553,24 @@ export function McpView(props: McpViewProps) {// The supported-servers panel stands for the MCP part of the library.const mcpPanelShown = Boolean(mcpPolicy) && (filter === "all" || filter === "mcp") && inventoryState === "all";const addSupportedMcp = async (preset: OmniRushMcpPreset) => {- const result = await props.connectMcp({- id: preset.id,- name: preset.id,- description: preset.why ?? preset.title,- kind: "mcp",- type: "local",- command: preset.command,- oauth: false,- });+ // A remote server on the list (Figma's): its exact address only; the engine signs in itself.+ const result = await props.connectMcp(preset.runtime === "remote" && preset.url+ ? { id: preset.id, name: preset.id, description: preset.why ?? preset.title, kind: "mcp", type: "remote", url: preset.url, oauth: false }+ : {+ id: preset.id,+ name: preset.id,+ description: preset.why ?? preset.title,+ kind: "mcp",+ type: "local",+ command: preset.command,+ oauth: false,+ });return result.ok ? { ok: true } : { ok: false, error: result.error };};+ const signInSupportedMcp = (name: string) => {+ const server = props.mcpServers.find((entry) => entry.name === name);+ if (server) props.authorizeMcp(server);+ };const libraryDetailLists = {quickConnect: quickConnectList,skills: installedSkills,@@ -1525,6 +1532,7 @@ export function McpView(props: McpViewProps) {canAdd={props.allowManageExtensions && !props.isRemoteWorkspace && mcpPolicy.engineV2 !== true}busy={props.busy}addPreset={addSupportedMcp}+ signIn={signInSupportedMcp}removeServer={props.allowManageExtensions ? (name) => {setRemoveTarget(name);setRemoveOpen(true);diff --git a/apps/app/tests/mcp-supported-panel.test.tsx b/apps/app/tests/mcp-supported-panel.test.tsxindex 4b3089ff..1600d649 100644--- a/apps/app/tests/mcp-supported-panel.test.tsx+++ b/apps/app/tests/mcp-supported-panel.test.tsx@@ -12,6 +12,7 @@ import {mcpServerState,presetCommandLine,presetConfigured,+ needsSignIn,} from "../src/react-app/domains/settings/pages/mcp-supported-panel";const filesystem: OmniRushMcpPreset = {@@ -138,4 +139,32 @@ describe("Settings > MCP: supported servers", () => {expect(mcpServerState(server("x", { type: "local", command: ["npx", "x"], enabled: false }), { name: "x", status: "allowed", code: "allowed" })).toEqual({ kind: "off" });expect(mcpServerState(server("x"), null)).toEqual({ kind: "pending" });});++ test("Figma: listed apart as an account server, with its address or command and how to set it up", () => {+ const desk: OmniRushMcpPreset = { ...filesystem, id: "figma", title: "Figma (desktop app)", why: "Reads designs through the Figma desktop app.", runtime: "remote", package: "figma-dev-mode", version: null, command: [], url: "http://127.0.0.1:3845/mcp", oauth: false, setup: "In the Figma desktop app, turn on the MCP server.", account: true };+ const remote: OmniRushMcpPreset = { ...desk, title: "Figma (remote)", package: "figma-remote", url: "https://mcp.figma.com/mcp", oauth: true, setup: "Sign in on the Figma card." };+ const key: OmniRushMcpPreset = { ...filesystem, id: "figma", title: "Figma (API key)", why: null, package: "figma-developer-mcp", version: "0.13.2", command: ["npx", "-y", "figma-developer-mcp"], setup: "Set FIGMA_API_KEY in your environment.", account: true };+ const html = render({ policy: policy({ supported: [filesystem, desk, remote, key] }) });+ expect(html).toContain("mcp-account-servers");+ expect(html).toContain("Servers that use your account");+ expect(html).toContain("http://127.0.0.1:3845/mcp");+ expect(html).toContain("https://mcp.figma.com/mcp");+ expect(html).toContain("npx -y figma-developer-mcp");+ expect(html).toContain("mcp-setup-figma-figma-dev-mode");+ expect(html).toContain("Set FIGMA_API_KEY in your environment.");+ expect(html).toContain("never in a config file");+ // Three routes of one id: each is its own row; one being on marks only that route added.+ const on = [{ name: "figma", status: "allowed" as const, code: "allowed", id: "figma", package: "figma-remote", runtime: "remote" as const, url: "https://mcp.figma.com/mcp", oauth: true }];+ expect(presetConfigured(remote, [server("figma")], on)).toBe(true);+ expect(presetConfigured(desk, [server("figma")], on)).toBe(false);+ expect(presetCommandLine(desk)).toBe("http://127.0.0.1:3845/mcp");+ // The configured remote server offers its sign-in; the desktop app's server does not need one.+ expect(needsSignIn(on[0])).toBe(true);+ expect(needsSignIn({ ...on[0], oauth: false, package: "figma-dev-mode" })).toBe(false);+ const signed = render({ policy: policy({ supported: [remote], decisions: on }), servers: [server("figma", { type: "remote", url: "https://mcp.figma.com/mcp" })], signIn: () => undefined });+ expect(signed).toContain("mcp-sign-in-figma");+ expect(signed).toContain("https://mcp.figma.com/mcp");+ expect(render({ policy: policy({ supported: [remote], decisions: on }), servers: [server("figma", { type: "remote", url: "https://mcp.figma.com/mcp" })] })).not.toContain("mcp-sign-in-figma");+ expect(MCP_BLOCKED_HINTS.secret_missing).toContain("environment");+ });});diff --git a/apps/server/src/agent-context-diagnostics-schema.ts b/apps/server/src/agent-context-diagnostics-schema.tsindex 828e9d3a..ef786902 100644--- a/apps/server/src/agent-context-diagnostics-schema.ts+++ b/apps/server/src/agent-context-diagnostics-schema.ts@@ -58,7 +58,7 @@ const diagnosticUrlPattern = /\b[a-z][a-z0-9+.-]{0,31}:\s*\/\/[^\s<>"'`]+/iu;const diagnosticAuthorizationPattern = /(?:^|[^A-Za-z0-9])(?:b[\s._-]*e[\s._-]*a[\s._-]*r[\s._-]*e[\s._-]*r|b[\s._-]*a[\s._-]*s[\s._-]*i[\s._-]*c)(?:\s|[.:=+_-])+(?:"[^"\r\n]*"|'[^'\r\n]*'|[^\s,;)}\]])/iu;const diagnosticSecretAssignmentPattern = /(?:^|[^A-Za-z0-9])(?:a[\s._-]*u[\s._-]*t[\s._-]*h[\s._-]*o[\s._-]*r[\s._-]*i[\s._-]*z[\s._-]*a[\s._-]*t[\s._-]*i[\s._-]*o[\s._-]*n|p[\s._-]*r[\s._-]*o[\s._-]*x[\s._-]*y[\s._-]*a[\s._-]*u[\s._-]*t[\s._-]*h[\s._-]*o[\s._-]*r[\s._-]*i[\s._-]*z[\s._-]*a[\s._-]*t[\s._-]*i[\s._-]*o[\s._-]*n|a[\s._-]*c[\s._-]*c[\s._-]*e[\s._-]*s[\s._-]*s[\s._-]*t[\s._-]*o[\s._-]*k[\s._-]*e[\s._-]*n|r[\s._-]*e[\s._-]*f[\s._-]*r[\s._-]*e[\s._-]*s[\s._-]*h[\s._-]*t[\s._-]*o[\s._-]*k[\s._-]*e[\s._-]*n|i[\s._-]*d[\s._-]*t[\s._-]*o[\s._-]*k[\s._-]*e[\s._-]*n|a[\s._-]*p[\s._-]*i[\s._-]*k[\s._-]*e[\s._-]*y|x[\s._-]*a[\s._-]*p[\s._-]*i[\s._-]*k[\s._-]*e[\s._-]*y|c[\s._-]*l[\s._-]*i[\s._-]*e[\s._-]*n[\s._-]*t[\s._-]*s[\s._-]*e[\s._-]*c[\s._-]*r[\s._-]*e[\s._-]*t|p[\s._-]*a[\s._-]*s[\s._-]*s[\s._-]*w[\s._-]*o[\s._-]*r[\s._-]*d|p[\s._-]*a[\s._-]*s[\s._-]*s[\s._-]*w[\s._-]*d|s[\s._-]*e[\s._-]*c[\s._-]*r[\s._-]*e[\s._-]*t|t[\s._-]*o[\s._-]*k[\s._-]*e[\s._-]*n)[\s._-]*[:=][\s._-]*(?:"[^"\r\n]*"|'[^'\r\n]*'|[^\s,;)}\]])/iu;const diagnosticJwtPattern = /\beyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/u;-const diagnosticKnownTokenPattern = /\b(?:owt_[A-Za-z0-9_-]+|ow_mcp_at_[A-Za-z0-9_-]+|sk-[A-Za-z0-9_-]+|gh[pousr]_[A-Za-z0-9_]+|github_pat_[A-Za-z0-9_]+|xox[baprs]-[A-Za-z0-9-]+)\b/iu;+const diagnosticKnownTokenPattern = /\b(?:owt_[A-Za-z0-9_-]+|ow_mcp_at_[A-Za-z0-9_-]+|sk-[A-Za-z0-9_-]+|gh[pousr]_[A-Za-z0-9_]+|github_pat_[A-Za-z0-9_]+|xox[baprs]-[A-Za-z0-9-]+|fig(?:d|u|ur)_[A-Za-z0-9_-]{20,})\b/iu;const diagnosticWindowsPathPattern = /(^|[\s("'=,:])(?:[A-Za-z]:[\\/]|\\\\)[^,;)}\]>"'`\r\n]+/mu;const diagnosticHomePathPattern = /(^|[\s("'=,:])~[\\/][^,;)}\]>"'`\r\n]+/mu;const diagnosticPosixPathPattern = /(^|[\s("'=,:])\/(?!mcp\/agent(?:$|[\s.,;:!)}\]"']))[^/\s<>:"'`][^,;)}\]>"'`\r\n]*/mu;diff --git a/apps/server/src/context/PARITY.sha256 b/apps/server/src/context/PARITY.sha256index d4fe0803..38358503 100644--- a/apps/server/src/context/PARITY.sha256+++ b/apps/server/src/context/PARITY.sha256@@ -13,8 +13,8 @@ d772119f2785b6926cd765a44589c171542d5e79b3677bfa076851775d794480 outside.tsd7c5638ca9204a9c51a4552e7a9b09cf7beeae9c63d9352d5950118fd5536967 pm-config.ts932c1eff09d540590abf99ede63447f4e0af9396096d325fa5fcfbcde49eda10 privacy.tsd67e99ceab9f67ebe7c0aa028b585208c37198e4fef5250608e677bce3f3c79c processes.ts-d26f1bc752a8cbd4b24dd9066be3b6aefd07ce69d8aef1d7aa616584581bc95b redact-policy.ts-5a179a0ebfcaadcbda4350775d1358886941f7a7174140fd75064a7fc79d32b1 redact-vectors.json+2f94eb21c1649be8c87f8c987d8d43bc6eb0fa7a80f318c615a92ab92df23d88 redact-policy.ts+c338bc867048adc9677bd7312e7f2a47b638c5e71a7602bbda7e7b9f6e2dca56 redact-vectors.jsond8c0636406c8cd9d55f9fb06af8827b3d1b73247393f48aaca2ef053ccf5a1ff services.ts92030e186fcd58a6acaeb9acbaac67c8003d12d0c2eb9e29113faa701885b0eb setup.tsd51d434283f757f0ed45bb6996a74fb5bf9e1d56f34146e99df3c392cde5ea19 shell-aliases.tsdiff --git a/apps/server/src/context/redact-policy.ts b/apps/server/src/context/redact-policy.tsindex ba9b16eb..70918225 100644--- a/apps/server/src/context/redact-policy.ts+++ b/apps/server/src/context/redact-policy.ts@@ -292,6 +292,8 @@ const TOKEN_RULES: TokenRule[] = [{ name: "github_token", gate: /gh[pousr]_/, pattern: token(String.raw`gh[pousr]_[A-Za-z0-9]{36}(?![A-Za-z0-9])`) },{ name: "github_pat", gate: "github_pat_", pattern: token(String.raw`github_pat_[A-Za-z0-9_]{60,}`) },{ name: "gitlab_token", gate: "glpat-", pattern: token(String.raw`glpat-[A-Za-z0-9_-]{20,}`) },+ // Figma: personal access tokens (figd_), OAuth tokens (figu_, figur_).+ { name: "figma_token", gate: /fig(?:d|u|ur)_/, pattern: token(String.raw`fig(?:d|u|ur)_[A-Za-z0-9_-]{20,}`) },{ name: "slack_token", gate: /xox[abprs]-/, pattern: token(String.raw`xox[abprs]-[A-Za-z0-9-]{10,}`) },{ name: "slack_webhook", gate: "hooks.slack.com", pattern: /(https:\/\/hooks\.slack\.com\/services\/T[A-Z0-9]+\/B[A-Z0-9]+\/)([A-Za-z0-9]{20,})/g, keep: 1 },{ name: "discord_webhook", gate: "/api/webhooks/", pattern: /(https:\/\/(?:canary\.|ptb\.)?discord(?:app)?\.com\/api\/webhooks\/\d+\/)([A-Za-z0-9_-]{50,})/g, keep: 1 },diff --git a/apps/server/src/context/redact-vectors.json b/apps/server/src/context/redact-vectors.jsonindex 808dca53..68a3bc81 100644--- a/apps/server/src/context/redact-vectors.json+++ b/apps/server/src/context/redact-vectors.json@@ -488,6 +488,11 @@"input": "token_hash=8f3a9b2c7d1e4f5a6b8c9d0e1f2a3b4c5d6e7f8a\n/verify?token_hash={{ .TokenHash }}&type=x\n/verify?token_hash=YOUR_TOKEN_HASH&x=1\n/search?q=hello-world-2024-x&page_token_hash=abc\n","expect": null,"same": true+ },+ {+ "name": "figma tokens",+ "input": "personal fig⟨+⟩d_Q3x9Lm2Pz7Kd4Vt8Rb1Nw6Hy0Cs5Fj-AbCdEfGh oauth fig⟨+⟩u_Z8y7X6w5V4u3T2s1R0q9P8o7N6m5L4k and fig⟨+⟩ur_K4j3H2g1F0e9D8c7B6a5Z4y3X2w1V0u kept: configd_abcdefghijklmnopqrstuvwxyz figd_short",+ "expect": "personal [REDACTED] oauth [REDACTED] and [REDACTED] kept: configd_abcdefghijklmnopqrstuvwxyz figd_short"}]}\ No newline at end of filediff --git a/apps/server/src/mcp-allow/PARITY.sha256 b/apps/server/src/mcp-allow/PARITY.sha256index e5506eab..e6cdda4e 100644--- a/apps/server/src/mcp-allow/PARITY.sha256+++ b/apps/server/src/mcp-allow/PARITY.sha256@@ -1,4 +1,4 @@# The MCP allowlist module: the same files in omnirush-cli (src/mcp/) and omnirush-gui (apps/server/src/mcp-allow/).# A change to one must be ported to the other and this list updated in both.-86cae20ebb11df3d31119218619b20842aacb30725c27574c418a24be13abfb6 mcp-allow.mjs-198d76c6a96a0ec51521f86bc569861503b2916a2c3a5b29ff3b9ccc45c99114 mcp-allow.d.mts+5bdd9e1ba56bfe55fdb67ae4eb8be689abdf721364c5fe6c70d75d989edd433a mcp-allow.mjs+482fb25ea7dba6dc91aeeb24891e0b2e94d4abe8ff585b0068eb2a7575e75491 mcp-allow.d.mtsdiff --git a/apps/server/src/mcp-allow/mcp-allow.d.mts b/apps/server/src/mcp-allow/mcp-allow.d.mtsindex 49a6ee2a..035297f4 100644--- a/apps/server/src/mcp-allow/mcp-allow.d.mts+++ b/apps/server/src/mcp-allow/mcp-allow.d.mts@@ -5,10 +5,10 @@ export const MCP_POLICY_FILE_VERSION: 1;export const BOX_NPM_PREFIX: string;export const MCP_REASONS: Record<McpDecisionCode, string>;-export type McpRuntime = "npm" | "pypi";+export type McpRuntime = "npm" | "pypi" | "remote";export type McpDecisionCode =| "allowed" | "disabled" | "remote" | "unknown_command" | "not_allowed" | "denied"- | "version" | "outside_project" | "missing_flag" | "missing_arg" | "flag" | "duplicate" | "invalid" | "runner_missing";+ | "version" | "outside_project" | "missing_flag" | "missing_arg" | "flag" | "duplicate" | "invalid" | "runner_missing" | "secret_missing" | "remote_settings";export type McpRules = {path_args?: "positional";@@ -23,6 +23,8 @@ export type McpRules = {path_env?: Record<string, string>;local_urls?: boolean;path_inputs?: string[];+ /** Variables read only from the person's own environment (one must be set). */+ secret_env?: string[];/** Flags whose value must be one of these. */flag_values?: Record<string, string[]>;};@@ -36,8 +38,14 @@ export type McpAllowEntry = {pin: string | null;title: string;why: string | null;+ /** Setup hint shown with the preset. */+ setup: string | null;+ /** runtime "remote": the exact address, and whether the engine signs in with OAuth. */+ url?: string;+ oauth?: boolean;/** null: not listed, every tool counts as one that changes something. */write_tools: string[] | null;+ read_tools: string[] | null;rules: McpRules;};@@ -63,7 +71,10 @@ export type McpDecision = {enabled?: boolean;renamed_to?: string;url_host?: string | null;+ url?: string;+ oauth?: boolean;write_tools?: string[] | null;+ read_tools?: string[] | null;notes?: string[];};@@ -92,6 +103,7 @@ export function splitSpec(spec: string, runtime: McpRuntime): { name: string; veexport function parseLaunch(command: unknown): McpLaunch | null;export function launchCommand(entry: McpAllowEntry, launch: McpLaunch, version: string, npmPrefix: string): string[];export function windowsDirect(found: string, platform?: string, exists?: (file: string) => boolean): string[] | null;+export function normalizeRemoteUrl(value: unknown): string | null;export function resolveRunner(runner: string, options?: { root?: string | null; platform?: string; env?: Record<string, string | undefined>; exists?: (file: string) => boolean; home?: string; accept?: ((file: string) => boolean) | null }): string | null;export function projectCodeIgnored(cfg: unknown): McpIgnored[];export function describeIgnored(items: McpIgnored[] | null | undefined): string | null;@@ -101,7 +113,7 @@ export function shellQuote(word: string): string;export function evaluateMcp(mcpMap: unknown,policy: McpPolicy | null,- ctx?: { root?: string; platform?: string; box?: McpBox | null; npmPrefix?: string; resolveRunner?: (runner: string, options: { root: string; platform: string; accept?: (file: string) => boolean }) => string | null; exists?: (file: string) => boolean },+ ctx?: { root?: string; platform?: string; box?: McpBox | null; npmPrefix?: string; resolveRunner?: (runner: string, options: { root: string; platform: string; accept?: (file: string) => boolean }) => string | null; exists?: (file: string) => boolean; env?: Record<string, string | undefined> },): { mcp: Record<string, Record<string, unknown>>; decisions: McpDecision[] };export function toolPrefix(name: string): string;export function mcpPermissionRules(decisions: McpDecision[] | null | undefined, mode: unknown): Record<string, "allow" | "ask">;diff --git a/apps/server/src/mcp-allow/mcp-allow.mjs b/apps/server/src/mcp-allow/mcp-allow.mjsindex 77a9e983..52c9bae0 100644--- a/apps/server/src/mcp-allow/mcp-allow.mjs+++ b/apps/server/src/mcp-allow/mcp-allow.mjs@@ -18,6 +18,14 @@// Allowed servers are keyed by the entry's id (the engine names their tools// `<id>_<tool>`), so the same server gets the same tool names whatever the// user called it. With the project's sandbox on, they run in the sandbox.+//+// One exception, account servers (Figma): an entry with `runtime: "remote"`+// matches its exact address only (no headers or OAuth settings from a config+// file, where a token would travel with the project), and an entry whose+// `rules.secret_env` names a key reads it from the person's own environment+// only, never writes it into the server's settings, and runs on this computer+// (the sandbox never sees the key). `read_tools` lists the tools that run+// without asking in Normal (every other one asks).import { createHash } from "node:crypto";import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from "node:fs";@@ -44,6 +52,8 @@ export const MCP_REASONS = {duplicate: "Another entry already starts this MCP server.",invalid: "This MCP server entry is not valid.",runner_missing: "npx or uvx was not found on this computer outside the project folder, so the server does not start.",+ secret_missing: "This MCP server needs a key in your own environment (not in a config file).",+ remote_settings: "This remote MCP server is supported only with its plain address: no headers or other settings.",};const ID = /^[a-z0-9][a-z0-9-]{0,39}$/;@@ -145,14 +155,56 @@ function normalizeRules(value) {if (Object.keys(env).length) out.path_env = env;}if (rules.local_urls === true) out.local_urls = true;+ // Keys a server needs, read only from the person's own environment (never from a config file, which the+ // project upload could carry); the first one present is passed on, none present: blocked.+ const secrets = strings(rules.secret_env, 4).filter((k) => /^[A-Z_][A-Z0-9_]{0,63}$/.test(k));+ if (secrets.length) out.secret_env = secrets;const inputs = strings(rules.path_inputs, 16).filter((k) => /^[A-Za-z_][\w]{0,63}$/.test(k));if (inputs.length) out.path_inputs = inputs;return out;}+/** A remote server's address as compared: scheme, host and path, lower-case host, no trailing slash. */+export function normalizeRemoteUrl(value) {+ let u;+ try { u = new URL(String(value ?? "")); } catch { return null; }+ if (u.protocol !== "https:" && u.protocol !== "http:") return null;+ if (u.username || u.password || u.search || u.hash) return null;+ // Plain http only to this computer (the Figma desktop app's server); anything else must be https.+ if (u.protocol === "http:" && !["127.0.0.1", "localhost", "[::1]"].includes(u.hostname)) return null;+ // localhost and 127.0.0.1 name the same server here.+ const host = u.hostname.toLowerCase() === "localhost" ? `127.0.0.1${u.port ? `:${u.port}` : ""}` : u.host.toLowerCase();+ return `${u.protocol}//${host}${u.pathname.replace(/\/+$/, "") || "/"}`;+}++function normalizeRemoteEntry(value, id) {+ const url = normalizeRemoteUrl(value.url);+ const pkg = text(value.package, 214);+ if (!url || !pkg || !/^(@[\w.-]+\/)?[\w.-]+$/.test(pkg)) return null;+ return {+ id,+ runtime: "remote",+ package: pkg,+ url,+ // OAuth sign-in through the engine (its own token store, never a config file); false: none.+ oauth: value.oauth === true,+ bins: [],+ versions: "*",+ pin: null,+ title: text(value.title, 80) ?? id,+ why: text(value.why, 400),+ setup: text(value.setup, 400),+ write_tools: Array.isArray(value.write_tools) ? strings(value.write_tools, 64).filter((t) => /^[\w-]{1,64}$/.test(t)) : null,+ // Or the other way round: only these run without asking (a server whose tool list grows, such as Figma's).+ read_tools: Array.isArray(value.read_tools) ? strings(value.read_tools, 64).filter((t) => /^[\w-]{1,64}$/.test(t)) : null,+ rules: {},+ };+}+function normalizeEntry(value) {if (!isRecord(value)) return null;const id = text(value.id, 40)?.toLowerCase();+ if (value.runtime === "remote") return id && ID.test(id) ? normalizeRemoteEntry(value, id) : null;const runtime = value.runtime === "npm" || value.runtime === "pypi" ? value.runtime : null;const pkg = text(value.package, 214);if (!id || !ID.test(id) || !runtime || !pkg || !/^(@[\w.-]+\/)?[\w.-]+$/.test(pkg)) return null;@@ -170,10 +222,13 @@ function normalizeEntry(value) {pin,title: text(value.title, 80) ?? id,why: text(value.why, 400),+ setup: text(value.setup, 400),// The server's tools that change something (files, a database, the// repository, the memory file): Normal permission mode asks before them.// null (a list without the field): every tool counts as one that changes something.write_tools: Array.isArray(value.write_tools) ? strings(value.write_tools, 64).filter((t) => /^[\w-]{1,64}$/.test(t)) : null,+ // Or the other way round: only these run without asking (a server whose tool list grows, such as Figma's).+ read_tools: Array.isArray(value.read_tools) ? strings(value.read_tools, 64).filter((t) => /^[\w-]{1,64}$/.test(t)) : null,rules: normalizeRules(value.rules),};}@@ -195,7 +250,8 @@ export function normalizePolicy(block) {const seen = new Set();for (const raw of Array.isArray(block.allow) ? block.allow.slice(0, 64) : []) {const entry = normalizeEntry(raw);- if (entry && !seen.has(entry.id)) { seen.add(entry.id); allow.push(entry); }+ const key = entry ? `${entry.id}|${entry.runtime}|${entry.package}|${entry.url ?? ""}` : null;+ if (entry && !seen.has(key)) { seen.add(key); allow.push(entry); }}const deny = (Array.isArray(block.deny) ? block.deny.slice(0, 128) : []).map(normalizeDeny).filter(Boolean);return { enabled: block.enabled === true, allow, deny, message: text(block.message, 400) };@@ -446,6 +502,23 @@ export function evaluateMcp(mcpMap, policy, ctx = {}) {if (!isRecord(raw)) { decisions.push(blocked(name, "invalid")); continue; }if (!policy || !policy.enabled) { decisions.push(blocked(name, "disabled", policy?.message ? { reason: policy.message } : {})); continue; }if (raw.type === "remote" || typeof raw.url === "string") {+ const url = normalizeRemoteUrl(raw.url);+ const remote = url ? policy.allow.find((e) => e.runtime === "remote" && e.url === url) : null;+ if (remote) {+ const base = { id: remote.id, package: remote.package, runtime: "remote", title: remote.title };+ if (Object.hasOwn(out, remote.id)) { decisions.push(blocked(name, "duplicate", base)); continue; }+ // Headers could carry a token into a config file (and the project upload): the plain address only.+ const extra = Object.keys(raw).filter((k) => !["type", "url", "enabled", "timeout", "oauth"].includes(k));+ if (extra.length || (raw.oauth !== undefined && typeof raw.oauth !== "boolean")) {+ decisions.push(blocked(name, "remote_settings", { ...base, reason: `${MCP_REASONS.remote_settings} (${extra.concat(typeof raw.oauth === "object" ? ["oauth"] : []).slice(0, 4).join(", ")})` }));+ continue;+ }+ const next = { type: "remote", url: remote.url, oauth: remote.oauth ? undefined : false, ...(raw.enabled === false ? { enabled: false } : {}), ...(Number.isInteger(raw.timeout) ? { timeout: raw.timeout } : {}) };+ if (next.oauth === undefined) delete next.oauth;+ out[remote.id] = next;+ decisions.push({ name, status: "allowed", code: "allowed", ...base, version: "remote", url: remote.url, oauth: remote.oauth, sandbox: false, enabled: raw.enabled !== false, write_tools: remote.write_tools, read_tools: remote.read_tools, ...(name !== remote.id ? { renamed_to: remote.id } : {}), notes: [remote.oauth ? "signs in with your account in the browser" : "reaches an app on this computer"] });+ continue;+ }const reason = denyReason(policy, name, hostOf(raw.url));decisions.push(blocked(name, "remote", { url_host: hostOf(raw.url), ...(reason ? { reason: `${reason} ${MCP_REASONS.remote}` } : {}) }));continue;@@ -460,7 +533,7 @@ export function evaluateMcp(mcpMap, policy, ctx = {}) {}const denied = denyReason(policy, launch.name);if (denied) { decisions.push(blocked(name, "denied", { reason: denied, package: launch.name })); continue; }- const entry = policy.allow.find((e) => e.runtime === launch.runtime && e.package.toLowerCase() === launch.name);+ const entry = policy.allow.find((e) => e.runtime !== "remote" && e.runtime === launch.runtime && e.package.toLowerCase() === launch.name);if (!entry) { decisions.push(blocked(name, "not_allowed", { package: launch.name })); continue; }// `-p <pkg> <program>` / `--from <pkg> <program>`: the program must be one// the package itself provides (the entry's `bins`), never `node -e ...`.@@ -495,6 +568,15 @@ export function evaluateMcp(mcpMap, policy, ctx = {}) {const ignored = Object.keys(given).filter((k) => !kept.has(k));if (ignored.length) notes.push(`ignores ${ignored.slice(0, 4).join(", ")}${ignored.length > 4 ? " ..." : ""}`);let refusal = null;+ const userEnv = ctx.env ?? process.env;+ const secretNames = (rules.secret_env ?? []).filter((k) => typeof userEnv[k] === "string" && userEnv[k] !== "");+ if (rules.secret_env && !secretNames.length) {+ refusal = blocked(name, "secret_missing", { ...base, version, reason: `${MCP_REASONS.secret_missing} Set ${rules.secret_env.join(" or ")} before starting the app.` });+ }+ // A server that needs the person's key runs on this computer, where the engine's own environment holds it+ // (the sandbox never sees it, and the key is never written into the server's settings).+ const boxHere = rules.secret_env ? null : box;+ if (box && !boxHere) notes.push("runs on this computer (needs your key)");if (rules.allow_flags) {const other = rest.map((a) => (a.includes("=") ? a.slice(0, a.indexOf("=")) : a)).find((a) => a.startsWith("-") && !rules.allow_flags.includes(a));if (other) refusal = blocked(name, "flag", { ...base, version, reason: `${MCP_REASONS.flag} (${other})` });@@ -527,27 +609,27 @@ export function evaluateMcp(mcpMap, policy, ctx = {}) {if (!refusal && rules.min_args && rest.filter((a) => !a.startsWith("-")).length < rules.min_args) {refusal = blocked(name, "missing_arg", { ...base, version });}- if (!refusal) rest = rest.map((a) => (a.startsWith("-") ? a : boxPath(a, root, box, platform)));+ if (!refusal) rest = rest.map((a) => (a.startsWith("-") ? a : boxPath(a, root, boxHere, platform)));}if (!refusal) for (const flag of rules.path_flags ?? []) {const found = flagValue(rest, flag);if (!found || found.value === null) continue;if (!inside(found.value)) { refusal = blocked(name, "outside_project", { ...base, version, reason: `${MCP_REASONS.outside_project} (${flag} ${found.value})` }); break; }- const mapped = boxPath(found.value, root, box, platform);+ const mapped = boxPath(found.value, root, boxHere, platform);rest = [...rest];if (found.inline) rest[found.index] = `${flag}=${mapped}`; else rest[found.index] = mapped;}if (!refusal) for (const [key, fallback] of Object.entries(rules.path_env ?? {})) {const value = environment[key];if (value === undefined || value === "") {- environment[key] = boxPath(lib.join(lib.resolve(root), fallback), root, box, platform);+ environment[key] = boxPath(lib.join(lib.resolve(root), fallback), root, boxHere, platform);notes.push(`keeps its data in ${fallback.split("\\").join("/")}`);} else if (!inside(value)) {refusal = blocked(name, "outside_project", { ...base, version, reason: `${MCP_REASONS.outside_project} (${key})` });break;} else {// Absolute: a server may resolve a relative path against its own install folder.- environment[key] = boxPath(lib.resolve(workRoot, value), root, box, platform);+ environment[key] = boxPath(lib.resolve(workRoot, value), root, boxHere, platform);}}if (refusal) { decisions.push(refusal); continue; }@@ -555,10 +637,10 @@ export function evaluateMcp(mcpMap, policy, ctx = {}) {const at = flag.indexOf("=");if (!flagValue(rest, at > 0 ? flag.slice(0, at) : flag)) { rest = [...rest, flag]; notes.push(`adds ${flag}`); }}- const npmPrefix = box ? BOX_NPM_PREFIX : ctx.npmPrefix || path.join(os.homedir(), ".cache", "omnirush-mcp-npx");+ const npmPrefix = boxHere ? BOX_NPM_PREFIX : ctx.npmPrefix || path.join(os.homedir(), ".cache", "omnirush-mcp-npx");const argv = [...launchCommand(entry, launch, version, npmPrefix), ...rest];if (launch.runner !== (entry.runtime === "npm" ? "npx" : "uvx")) notes.push(`runs with ${argv[0]}`);- if (!box) {+ if (!boxHere) {// By absolute path: the engine starts the server in the project folder, and on Windows a bare name// is looked up there before PATH (a repo's own npx.cmd would run instead).const exists = ctx.exists ?? existsSync;@@ -573,7 +655,7 @@ export function evaluateMcp(mcpMap, policy, ctx = {}) {argv.splice(0, 1, ...program);}const next = { ...raw, type: "local" };- if (box) {+ if (boxHere) {const envWords = Object.entries(environment).map(([k, v]) => `${k}=${shellQuote(v)}`);next.command = [box.shell, "-c", `${entry.runtime === "npm" ? `mkdir -p ${BOX_NPM_PREFIX} && ` : ""}exec ${envWords.length ? `env ${envWords.join(" ")} ` : ""}${argv.map(shellQuote).join(" ")}`];next.environment = { OMNIRUSH_BOX_KEY: box.key };@@ -582,8 +664,9 @@ export function evaluateMcp(mcpMap, policy, ctx = {}) {next.command = argv;if (Object.keys(environment).length) next.environment = environment; else delete next.environment;}+ if (secretNames.length) notes.push(`uses ${secretNames[0]} from your environment`);out[entry.id] = next;- decisions.push({ name, status: "allowed", code: "allowed", ...base, version, sandbox: Boolean(box), enabled: raw.enabled !== false, write_tools: entry.write_tools, ...(name !== entry.id ? { renamed_to: entry.id } : {}), notes });+ decisions.push({ name, status: "allowed", code: "allowed", ...base, version, sandbox: Boolean(boxHere), enabled: raw.enabled !== false, write_tools: entry.write_tools, read_tools: entry.read_tools, ...(name !== entry.id ? { renamed_to: entry.id } : {}), notes });}return { mcp: out, decisions };}@@ -637,7 +720,8 @@ export function toolRefusal(state, tool, args) {* The engine `permission` rules the MCP servers add in a permission mode* (the safety modes, OMNIRUSH_PERMISSION_MODE): Normal lets an allowed* server's tools run (`<id>_*: allow`) and asks before the ones that change- * something (`<id>_<tool>: ask`, its entry's `write_tools`); Careful asks+ * something (`<id>_<tool>: ask`, its entry's `write_tools`; with `read_tools`, it asks for every+ * tool but those); Careful asks* for every tool already and Auto for none, so they add nothing. The* engine takes the last rule that matches, so these go after the mode's own.*/@@ -646,6 +730,11 @@ export function mcpPermissionRules(decisions, mode) {const rules = {};for (const d of decisions ?? []) {if (!d || d.status !== "allowed" || !d.id) continue;+ if (Array.isArray(d.read_tools)) {+ rules[`${toolPrefix(d.id)}*`] = "ask";+ for (const tool of d.read_tools) rules[`${toolPrefix(d.id)}${String(tool).replace(/[^a-zA-Z0-9_-]/g, "_")}`] = "allow";+ continue;+ }if (!Array.isArray(d.write_tools)) {rules[`${toolPrefix(d.id)}*`] = "ask";continue;@@ -736,7 +825,8 @@ export function describeDecision(d) {if (d.status === "allowed") {// The version is in the line already; the other notes say what the app changed.const notes = (d.notes ?? []).filter((n) => !n.startsWith("runs version "));- return `MCP ${d.id}${d.renamed_to && d.name !== d.id ? ` (${d.name})` : ""}: ${d.enabled === false ? "turned off" : "on"}${d.version ? `, ${d.package}@${d.version}` : ""}${notes.length ? ` (${notes.join("; ")})` : ""}`;+ const what = d.runtime === "remote" ? (d.url ? `, ${d.url}` : "") : d.version ? `, ${d.package}@${d.version}` : "";+ return `MCP ${d.id}${d.renamed_to && d.name !== d.id ? ` (${d.name})` : ""}: ${d.enabled === false ? "turned off" : "on"}${what}${notes.length ? ` (${notes.join("; ")})` : ""}`;}return `MCP ${d.name}: blocked. ${d.reason}`;}diff --git a/apps/server/src/mcp-allow/mcp-policy.fixture.json b/apps/server/src/mcp-allow/mcp-policy.fixture.jsonindex 57ee0da2..6f5db9d6 100644--- a/apps/server/src/mcp-allow/mcp-policy.fixture.json+++ b/apps/server/src/mcp-allow/mcp-policy.fixture.json@@ -8,7 +8,10 @@{"id": "sequential-thinking", "title": "Sequential thinking", "runtime": "npm", "package": "@modelcontextprotocol/server-sequential-thinking", "versions": ">=2025.7.1", "pin": "2026.8.31", "write_tools": [], "bins": ["mcp-server-sequential-thinking"]},{"id": "time", "title": "Time", "runtime": "pypi", "package": "mcp-server-time", "versions": ">=2025.1.0", "pin": "2026.8.18", "write_tools": [], "rules": {"allow_flags": ["--local-timezone"]}, "bins": ["mcp-server-time"]},{"id": "everything", "title": "Everything (test server)", "runtime": "npm", "package": "@modelcontextprotocol/server-everything", "versions": ">=2025.7.1", "pin": "2026.8.31", "write_tools": [], "bins": ["mcp-server-everything"]},- {"id": "playwright", "title": "Playwright (local pages)", "runtime": "npm", "package": "@playwright/mcp", "versions": ">=0.0.40", "pin": "0.0.83", "write_tools": ["browser_file_upload", "browser_evaluate", "browser_run_code", "browser_take_screenshot", "browser_pdf_save"], "rules": {"add_flags": ["--isolated", "--proxy-server=http://127.0.0.1:9", "--proxy-bypass=localhost,127.0.0.1,[::1],*.localhost"], "forbid_flags": ["--cdp-endpoint", "--cdp-header", "--extension", "--user-data-dir", "--storage-state", "--config", "--init-page", "--init-script", "--executable-path", "--proxy-server", "--proxy-bypass", "--allowed-hosts", "--allowed-origins", "--blocked-origins", "--output-dir", "--port", "--host"], "local_urls": true, "allow_flags": ["--isolated", "--headless", "--browser", "--device", "--viewport-size", "--user-agent", "--ignore-https-errors", "--no-sandbox", "--caps", "--image-responses", "--save-trace", "--save-session", "--timeout-action", "--timeout-navigation", "--test-id-attribute", "--snapshot-mode", "--console-level"], "flag_values": {"--browser": ["chrome", "chromium", "msedge", "chrome-for-testing"]}}, "bins": ["playwright-mcp"]}+ {"id": "playwright", "title": "Playwright (local pages)", "runtime": "npm", "package": "@playwright/mcp", "versions": ">=0.0.40", "pin": "0.0.83", "write_tools": ["browser_file_upload", "browser_evaluate", "browser_run_code", "browser_take_screenshot", "browser_pdf_save"], "rules": {"add_flags": ["--isolated", "--proxy-server=http://127.0.0.1:9", "--proxy-bypass=localhost,127.0.0.1,[::1],*.localhost"], "forbid_flags": ["--cdp-endpoint", "--cdp-header", "--extension", "--user-data-dir", "--storage-state", "--config", "--init-page", "--init-script", "--executable-path", "--proxy-server", "--proxy-bypass", "--allowed-hosts", "--allowed-origins", "--blocked-origins", "--output-dir", "--port", "--host"], "local_urls": true, "allow_flags": ["--isolated", "--headless", "--browser", "--device", "--viewport-size", "--user-agent", "--ignore-https-errors", "--no-sandbox", "--caps", "--image-responses", "--save-trace", "--save-session", "--timeout-action", "--timeout-navigation", "--test-id-attribute", "--snapshot-mode", "--console-level"], "flag_values": {"--browser": ["chrome", "chromium", "msedge", "chrome-for-testing"]}}, "bins": ["playwright-mcp"]},+ {"id": "figma", "title": "Figma (desktop app)", "setup": "In the Figma desktop app, open a design file, switch to Dev Mode and turn on the MCP server (needs a Dev or Full seat).", "runtime": "remote", "package": "figma-dev-mode", "url": "http://127.0.0.1:3845/mcp", "oauth": false, "read_tools": ["get_design_context", "get_code", "get_variable_defs", "get_code_connect_map", "get_code_connect_suggestions", "get_screenshot", "get_image", "get_metadata", "get_figjam", "whoami"], "write_tools": ["add_code_connect_map", "send_code_connect_mappings", "create_design_system_rules", "generate_figma_design"]},+ {"id": "figma", "title": "Figma (remote)", "setup": "Sign in once: omnirush mcp login figma (the desktop app: Sign in on the Figma card). The sign-in stays on this computer.", "runtime": "remote", "package": "figma-remote", "url": "https://mcp.figma.com/mcp", "oauth": true, "read_tools": ["get_design_context", "get_code", "get_variable_defs", "get_code_connect_map", "get_code_connect_suggestions", "get_screenshot", "get_image", "get_metadata", "get_figjam", "whoami"], "write_tools": ["add_code_connect_map", "send_code_connect_mappings", "create_design_system_rules", "generate_figma_design"]},+ {"id": "figma", "title": "Figma (API key)", "setup": "Set FIGMA_API_KEY (a Figma personal access token) in your environment before starting the app; never put it in a config file.", "runtime": "npm", "package": "figma-developer-mcp", "bins": ["figma-developer-mcp"], "versions": ">=0.13.2 <0.14", "pin": "0.13.2", "read_tools": ["get_figma_data"], "write_tools": ["download_figma_images"], "rules": {"secret_env": ["FIGMA_API_KEY", "FIGMA_OAUTH_TOKEN"], "add_flags": ["--stdio", "--no-telemetry"], "allow_flags": ["--stdio", "--no-telemetry", "--json", "--skip-image-downloads", "--image-dir"], "path_flags": ["--image-dir"], "path_inputs": ["localPath"]}}],"deny": [{"match": "@modelcontextprotocol/server-github", "reason": "The GitHub server works on your GitHub account."},diff --git a/apps/server/src/omnirush-ui-mcp-guard.e2e.test.ts b/apps/server/src/omnirush-ui-mcp-guard.e2e.test.tsindex 91975744..0afa1c5d 100644--- a/apps/server/src/omnirush-ui-mcp-guard.e2e.test.ts+++ b/apps/server/src/omnirush-ui-mcp-guard.e2e.test.ts@@ -270,6 +270,46 @@ describe("MCP allowlist at the HTTP and runtime boundaries", () => {expect(engine.pushedNames()).toEqual([]);});+ test("Figma: its exact addresses can be added, and only its remote server's sign-in reaches the engine", async () => {+ const { config, engine } = await fixture();+ const { call } = await start(config, engine.baseUrl);+ // MCP off: no sign-in either.+ const off = await call("POST", "/workspace/ws_1/opencode/mcp/figma/auth/authenticate", {});+ expect(off.status).toBe(403);+ allowList(config);+ const view = await (await call("GET", "/workspace/ws_1/mcp")).json() as { mcpPolicy: { supported: Array<{ id: string; package: string; url: string | null; account: boolean; setup: string | null; command: string[] }> } };+ const figma = view.mcpPolicy.supported.filter((preset) => preset.id === "figma");+ expect(figma.map((preset) => [preset.package, preset.url, preset.account])).toEqual([+ ["figma-dev-mode", "http://127.0.0.1:3845/mcp", true],+ ["figma-remote", "https://mcp.figma.com/mcp", true],+ ["figma-developer-mcp", null, true],+ ]);+ expect(figma.every((preset) => Boolean(preset.setup))).toBe(true);+ expect(figma[2]?.command).toEqual(["npx", "-y", "figma-developer-mcp"]);+ expect(view.mcpPolicy.supported.find((preset) => preset.id === "filesystem")?.account).toBe(false);++ const added = await call("POST", "/workspace/ws_1/mcp", { name: "figma", config: { type: "remote", url: "http://127.0.0.1:3845/mcp", enabled: true } });+ expect(added.status).toBe(200);+ for (const bad of [+ { type: "remote", url: "https://mcp.figma.com/other", enabled: true },+ { type: "remote", url: "https://mcp.figma.com/mcp", headers: { "X-Figma-Token": "x" }, enabled: true },+ ]) {+ const refused = await call("POST", "/workspace/ws_1/mcp", { name: "figma2", config: bad });+ expect(refused.status).toBe(403);+ expect(await refused.json()).toMatchObject({ code: "mcp_not_supported" });+ }++ for (const path of ["/workspace/ws_1/opencode/mcp/figma/auth", "/workspace/ws_1/opencode/mcp/figma/auth/authenticate", "/workspace/ws_1/opencode/api/mcp/figma/auth/callback"]) {+ const response = await call("POST", path, {});+ expect(response.status).not.toBe(403);+ }+ for (const path of ["/workspace/ws_1/opencode/mcp/filesystem/auth/authenticate", "/workspace/ws_1/opencode/mcp/figma-x/auth", "/workspace/ws_1/opencode/mcp/notion/auth/authenticate"]) {+ const response = await call("POST", path, {});+ expect(response.status).toBe(403);+ expect(await response.json()).toMatchObject({ code: "mcp_account_linked" });+ }+ });+test("legacy stored rows are never pushed, and registry launches never reach the plugin's file", async () => {const { config, engine } = await fixture();allowList(config);diff --git a/apps/server/src/server.ts b/apps/server/src/server.tsindex ca482c52..c8551128 100644--- a/apps/server/src/server.ts+++ b/apps/server/src/server.ts@@ -6420,12 +6420,29 @@ function assertEngineMcpRouteAllowed(config: ServerConfig, method: string, routeassertMcpAllowed(config);return;}- if (/^[^/]+\/auth(?:\/|$)/.test(rest)) refuseAccountLinkedMcp();+ const auth = /^([^/]+)\/auth(?:\/|$)/.exec(rest);+ if (auth) {+ // The one account sign-in the list allows: a remote server on it that signs in with OAuth (Figma's), by+ // its id (the engine plugin keys it so); the engine keeps the tokens in its own store, not in a config.+ if (mcpSignInAllowed(config, decodeURIComponent(auth[1] ?? ""))) return;+ refuseAccountLinkedMcp();+ }throw new ApiError(403, "engine_mcp_managed", "Add MCP servers in Settings > MCP: only the supported servers run.");}+/** Whether `name` is a remote server on the list that signs in with OAuth. */+export function mcpSignInAllowed(config: ServerConfig, name: string): boolean {+ if (!mcpAllowed(config)) return false;+ const policy = currentMcpPolicy(runtimeStorageDir(config));+ return Boolean(policy?.allow.some((entry) => entry.runtime === "remote" && entry.oauth === true && entry.id === name));+}+/** A supported server as a one-click preset: what it is, and the command it adds. */-function mcpPreset(entry: McpAllowEntry): { id: string; title: string; why: string | null; runtime: string; package: string; version: string | null; versions: string; command: string[]; localPagesOnly: boolean } {+function mcpPreset(entry: McpAllowEntry): { id: string; title: string; why: string | null; runtime: string; package: string; version: string | null; versions: string; command: string[]; localPagesOnly: boolean; url: string | null; oauth: boolean; setup: string | null; account: boolean } {+ const account = { url: entry.url ?? null, oauth: entry.oauth === true, setup: entry.setup ?? null, account: Boolean(entry.setup) };+ if (entry.runtime === "remote") {+ return { id: entry.id, title: entry.title, why: entry.why, runtime: entry.runtime, package: entry.package, version: null, versions: entry.versions, command: [], localPagesOnly: false, ...account };+ }// The file a database server needs is a placeholder in the project: data.db.const placeholder = /sqlite|db/i.test(`${entry.id} ${entry.package}`) ? "data.db" : ".";const args: string[] = [...(entry.rules.default_args ?? [])];@@ -6445,6 +6462,7 @@ function mcpPreset(entry: McpAllowEntry): { id: string; title: string; why: striversions: entry.versions,command,localPagesOnly: entry.rules.local_urls === true,+ ...account,};}diff --git a/apps/server/src/session-uploader.ts b/apps/server/src/session-uploader.tsindex 99c0974d..accc1f4a 100644--- a/apps/server/src/session-uploader.ts+++ b/apps/server/src/session-uploader.ts@@ -1091,6 +1091,7 @@ const SECRET_PATTERNS: Redaction[] = [[tokenPattern(String.raw`gh[pousr]_[A-Za-z0-9]{16,}\b`), REDACTED],[tokenPattern(String.raw`github_pat_[A-Za-z0-9_]{16,}\b`), REDACTED],[tokenPattern(String.raw`xox[abpr]-[A-Za-z0-9-]{10,}`), REDACTED],+ [tokenPattern(String.raw`fig(?:d|u|ur)_[A-Za-z0-9_-]{20,}`), REDACTED],[tokenPattern(String.raw`AIza[0-9A-Za-z_-]{30,}`), REDACTED],[tokenPattern(String.raw`[sr]k_(?:live|test)_[A-Za-z0-9]{8,}\b`), REDACTED],[tokenPattern(String.raw`sk-ant-[A-Za-z0-9_-]{16,}`), REDACTED],@@ -1639,6 +1640,7 @@ const SECRET_PATTERN_GATES: Array<(text: string) => boolean> = [(text) => /gh[pousr]_/.test(text),(text) => text.includes("github_pat_"),(text) => /xox[abpr]-/.test(text),+ (text) => /fig(?:d|u|ur)_/.test(text),(text) => text.includes("AIza"),(text) => /[sr]k_(?:live|test)_/.test(text),(text) => text.includes("sk-ant-"),@@ -1649,7 +1651,7 @@ const SECRET_PATTERN_GATES: Array<(text: string) => boolean> = [// Every literal the gates above look for, in one scan: when none occurs (and// no Discord-shaped run either) no provider-token rule can run, so the text// each later gate would see is unchanged and the whole loop is skipped.-const PROVIDER_TOKEN_LITERALS = /AKIA|ASIA|gh[pousr]_|github_pat_|xox[abpr]-|AIza|[sr]k_(?:live|test)_|sk-ant-|(?:sk|rk|pk)-|eyJ/;+const PROVIDER_TOKEN_LITERALS = /AKIA|ASIA|gh[pousr]_|github_pat_|xox[abpr]-|fig(?:d|u|ur)_|AIza|[sr]k_(?:live|test)_|sk-ant-|(?:sk|rk|pk)-|eyJ/;/*** Runs `redact` over each line holding a gate match and leaves every other