A desktop coding agent with free access to frontier models.
TypeScript
fix: turn off Figma server telemetry
ogsamrat28baf84b399c
diff --git a/apps/server/src/mcp-allow/PARITY.sha256 b/apps/server/src/mcp-allow/PARITY.sha256index 34f1cbe7..ae38c365 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.-0626335ae120a2f35558fde1b743e68ad603d9b812d297c8a29e01ce3e8534bd mcp-allow.mjs-a6ebbd91aac94482fd933ff835a2629c63350bb380197de567998b75ab5d4d08 mcp-allow.d.mts+f647dccfe78833a8c988fdbfae0beb2018921d35b8c8d8215560c65821611ed6 mcp-allow.mjs+72c6590d565a4d005ec069b3c0f1c47d2ec05084f84d7fb95e3199e9404afacd 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 e4cbe31a..17bab47d 100644--- a/apps/server/src/mcp-allow/mcp-allow.d.mts+++ b/apps/server/src/mcp-allow/mcp-allow.d.mts@@ -25,6 +25,8 @@ export type McpRules = {path_inputs?: string[];/** Variables read only from the person's own environment (one must be set). */secret_env?: string[];+ /** Variables the server always starts with, set to these literal values (never from a config file). */+ fixed_env?: Record<string, string>;/** Flags whose value must be one of these. */flag_values?: Record<string, string[]>;};diff --git a/apps/server/src/mcp-allow/mcp-allow.mjs b/apps/server/src/mcp-allow/mcp-allow.mjsindex aa554697..bb9d082c 100644--- a/apps/server/src/mcp-allow/mcp-allow.mjs+++ b/apps/server/src/mcp-allow/mcp-allow.mjs@@ -131,6 +131,9 @@ export function validRange(range) {// -------------------------------------------------------------------- policy+// Variables a `fixed_env` rule may not set: they change which program runs or how it loads.+const FIXED_ENV_REFUSED = /^(?:PATH|PATHEXT|HOME|USERPROFILE|COMSPEC|SHELL|TMPDIR|TEMP|TMP|NODE_.*|NPM_.*|LD_.*|DYLD_.*|PYTHON.*|UV_.*|VIRTUAL_ENV|BUN_.*|DENO_.*|OMNIRUSH_.*|OPENCODE_.*|.*_PROXY|.*(?:KEY|TOKEN|SECRET|PASSWORD).*)$/i;+function normalizeRules(value) {const rules = isRecord(value) ? value : {};const out = {};@@ -160,6 +163,16 @@ function normalizeRules(value) {// 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;+ // Variables the server always starts with, set to the list's literal values (a telemetry opt-out): never+ // taken from a config file and never overridden by one. Names that change what runs (PATH, NODE_OPTIONS,+ // LD_*, npm_config_*, ...) and the names of path_env / secret_env are not accepted.+ if (isRecord(rules.fixed_env)) {+ const taken = new Set([...Object.keys(out.path_env ?? {}), ...(out.secret_env ?? [])]);+ const env = Object.fromEntries(Object.entries(rules.fixed_env)+ .filter(([k, v]) => /^[A-Z_][A-Z0-9_]{0,63}$/.test(k) && !FIXED_ENV_REFUSED.test(k) && !taken.has(k) && typeof v === "string" && /^[A-Za-z0-9._-]{1,64}$/.test(v))+ .slice(0, 8));+ if (Object.keys(env).length) out.fixed_env = env;+ }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;@@ -659,6 +672,9 @@ export function evaluateMcp(mcpMap, policy, ctx = {}) {}}if (refusal) { decisions.push(refusal); continue; }+ // Last, so neither the config nor path_env can change them; in the sandbox they go through `env` below.+ for (const [key, value] of Object.entries(rules.fixed_env ?? {})) environment[key] = value;+ if (rules.fixed_env) notes.push(`starts with ${Object.entries(rules.fixed_env).map(([k, v]) => `${k}=${v}`).join(" ")}`);for (const flag of rules.add_flags ?? []) {const at = flag.indexOf("=");if (!flagValue(rest, at > 0 ? flag.slice(0, at) : flag)) { rest = [...rest, flag]; notes.push(`adds ${flag}`); }diff --git a/apps/server/src/mcp-allow/mcp-policy.fixture.json b/apps/server/src/mcp-allow/mcp-policy.fixture.jsonindex d85baab2..f3f83cce 100644--- a/apps/server/src/mcp-allow/mcp-policy.fixture.json+++ b/apps/server/src/mcp-allow/mcp-policy.fixture.json@@ -11,7 +11,7 @@{"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 (on a Mac, open the desktop app from a terminal that has it); 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", "--env=/dev/null"], "allow_flags": ["--stdio", "--no-telemetry", "--json", "--skip-image-downloads", "--image-dir"], "path_flags": ["--image-dir"], "path_inputs": ["localPath"]}}+ {"id": "figma", "title": "Figma (API key)", "setup": "Set FIGMA_API_KEY (a Figma personal access token) in your environment before starting the app (on a Mac, open the desktop app from a terminal that has it); 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"], "fixed_env": {"FRAMELINK_TELEMETRY": "off", "DO_NOT_TRACK": "1"}, "add_flags": ["--stdio", "--no-telemetry", "--env=/dev/null"], "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/mcp-allow/state.test.ts b/apps/server/src/mcp-allow/state.test.tsindex f39bf140..88294bcc 100644--- a/apps/server/src/mcp-allow/state.test.ts+++ b/apps/server/src/mcp-allow/state.test.ts@@ -5,7 +5,7 @@ import path from "node:path";import omnirushMcpPolicy from "../opencode-plugins/omnirush-mcp-policy.js";import { keyOf } from "../box/plugin-lib.js";-import { describeIgnored, readPolicyFile } from "./mcp-allow.mjs";+import { describeIgnored, evaluateMcp, normalizePolicy, readPolicyFile } from "./mcp-allow.mjs";import {decideMcpEntry,mcpEngineEnv,@@ -218,3 +218,13 @@ describe("the engine plugin (omnirush-mcp-policy)", () => {}});});++describe("MCP fixed environment", () => {+ test("the Figma key server always starts with its telemetry off, whatever the config says", () => {+ const policy = normalizePolicy(policyFixture);+ const ctx = { root: "/work/app", platform: "linux", npmPrefix: "/state/npx", resolveRunner: (runner: string) => runner, env: { FIGMA_API_KEY: "x".repeat(24) } };+ const { mcp, decisions } = evaluateMcp({ figma: { type: "local", command: ["npx", "-y", "figma-developer-mcp"], environment: { FRAMELINK_TELEMETRY: "on", DO_NOT_TRACK: "0" } } }, policy, ctx);+ expect(decisions[0]).toMatchObject({ status: "allowed", id: "figma" });+ expect((mcp as Record<string, { environment?: Record<string, string> }>).figma?.environment).toEqual({ FRAMELINK_TELEMETRY: "off", DO_NOT_TRACK: "1" });+ });+});