A desktop coding agent with free access to frontier models.
TypeScript
feat: MCP write tools ask in Normal mode
ogsamratc08c8f6e7c0e
diff --git a/apps/server/src/mcp-allow/PARITY.sha256 b/apps/server/src/mcp-allow/PARITY.sha256index 01cadd92..fae7cf9d 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.-cb9d65c9bfde0212a94103ef6e44246efc518cb505bae3c760f601a9e3062e83 mcp-allow.mjs-595fb56b35a751af51b3c91ff8235f27fefe2b69e19a52b53d49093f1acf8f1f mcp-allow.d.mts+a6fc17499befcd29c47c69563c04f17429f460d2aefad20bc1c5cac383321add mcp-allow.mjs+1462cdd9278e07c6c8c55ea29abca116956db58ce3c990a62b4231a3426c9c01 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 8259fc0a..c086a682 100644--- a/apps/server/src/mcp-allow/mcp-allow.d.mts+++ b/apps/server/src/mcp-allow/mcp-allow.d.mts@@ -36,6 +36,8 @@ export type McpAllowEntry = {pin: string | null;title: string;why: string | null;+ /** null: not listed, every tool counts as one that changes something. */+ write_tools: string[] | null;rules: McpRules;};@@ -61,6 +63,7 @@ export type McpDecision = {enabled?: boolean;renamed_to?: string;url_host?: string | null;+ write_tools?: string[] | null;notes?: string[];};@@ -96,6 +99,7 @@ export function evaluateMcp(ctx?: { root?: string; platform?: string; box?: McpBox | null; npmPrefix?: string },): { 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">;export function toolRefusal(state: { localOnly?: string[]; pathInputs?: Array<{ id: string; keys: string[] }>; roots?: Array<{ root: string; platform: string }> },tool: unknown,@@ -112,6 +116,7 @@ export function createMcpPolicyHooks(options?: {reportDir?: string | null;box?: McpBox | null | ((root: string) => McpBox | null);npmPrefix?: string;+ permissionMode?: string | null | (() => string | null | undefined);platform?: string;now?: () => number;}): {diff --git a/apps/server/src/mcp-allow/mcp-allow.mjs b/apps/server/src/mcp-allow/mcp-allow.mjsindex 7f35b7bc..26bb772d 100644--- a/apps/server/src/mcp-allow/mcp-allow.mjs+++ b/apps/server/src/mcp-allow/mcp-allow.mjs@@ -169,6 +169,10 @@ function normalizeEntry(value) {pin,title: text(value.title, 80) ?? id,why: text(value.why, 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,rules: normalizeRules(value.rules),};}@@ -518,7 +522,7 @@ export function evaluateMcp(mcpMap, policy, ctx = {}) {if (Object.keys(environment).length) next.environment = environment; else delete next.environment;}out[entry.id] = next;- decisions.push({ name, status: "allowed", code: "allowed", ...base, version, sandbox: Boolean(box), enabled: raw.enabled !== false, ...(name !== entry.id ? { renamed_to: entry.id } : {}), notes });+ 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 });}return { mcp: out, decisions };}@@ -566,6 +570,39 @@ export function toolRefusal(state, tool, args) {return null;}+// ------------------------------------------------------------- permissions++/**+ * 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+ * 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.+ */+export function mcpPermissionRules(decisions, mode) {+ if (String(mode ?? "").trim().toLowerCase() !== "normal") return {};+ const rules = {};+ for (const d of decisions ?? []) {+ if (!d || d.status !== "allowed" || !d.id) continue;+ if (!Array.isArray(d.write_tools)) {+ rules[`${toolPrefix(d.id)}*`] = "ask";+ continue;+ }+ rules[`${toolPrefix(d.id)}*`] = "allow";+ for (const tool of d.write_tools) rules[`${toolPrefix(d.id)}${String(tool).replace(/[^a-zA-Z0-9_-]/g, "_")}`] = "ask";+ }+ return rules;+}++/** `permission` with `rules` after its own (a string value becomes its "*" rule). */+function withRules(permission, rules) {+ if (!Object.keys(rules).length) return permission;+ const base = typeof permission === "string" ? { "*": permission } : isRecord(permission) ? { ...permission } : {};+ for (const key of Object.keys(rules)) delete base[key];+ return { ...base, ...rules };+}+// --------------------------------------------------------- the plugin's hooks/** The policy the app wrote for the engine (`{v, policy, at}`); null: MCP off. */@@ -621,7 +658,9 @@ function configTarget(input, output) {/*** The engine plugin's hooks. `options`: `{directory, policyFile, reportDir,* box (null or a function of the root returning {shell, key, croot} or- * null), npmPrefix (default: <reportDir>/../npx-prefix), platform, now}`. The `config` hook replaces `mcp` with the allowed+ * null), npmPrefix (default: <reportDir>/../npx-prefix), permissionMode+ * (default: OMNIRUSH_PERMISSION_MODE; see mcpPermissionRules), platform,+ * now}`. The `config` hook replaces `mcp` with the allowed* servers (none without a readable policy); `tool.execute.before` refuses* non-local pages for `local_urls` servers and paths outside the project* for `path_inputs` servers.@@ -640,6 +679,9 @@ export function createMcpPolicyHooks(options = {}) {}const { mcp, decisions } = evaluateMcp(target.mcp, policy, { root, platform: options.platform, box, npmPrefix });target.mcp = mcp;+ const mode = typeof options.permissionMode === "function" ? options.permissionMode() : options.permissionMode ?? process.env.OMNIRUSH_PERMISSION_MODE;+ const rules = mcpPermissionRules(decisions, mode);+ if (Object.keys(rules).length) target.permission = withRules(target.permission, rules);const on = policy ? policy.allow.filter((e) => Object.hasOwn(mcp, e.id)) : [];state.localOnly = on.filter((e) => e.rules.local_urls).map((e) => e.id);state.pathInputs = on.filter((e) => e.rules.path_inputs).map((e) => ({ id: e.id, keys: e.rules.path_inputs }));diff --git a/apps/server/src/mcp-allow/mcp-policy.fixture.json b/apps/server/src/mcp-allow/mcp-policy.fixture.jsonindex 3375f470..57ee0da2 100644--- a/apps/server/src/mcp-allow/mcp-policy.fixture.json+++ b/apps/server/src/mcp-allow/mcp-policy.fixture.json@@ -1,14 +1,14 @@{"enabled": true,"allow": [- {"id": "filesystem", "title": "Filesystem", "runtime": "npm", "package": "@modelcontextprotocol/server-filesystem", "versions": ">=2025.1.14", "pin": "2026.8.31", "rules": {"path_args": "positional", "default_args": ["."]}, "bins": ["mcp-server-filesystem"]},- {"id": "git", "title": "Git", "runtime": "pypi", "package": "mcp-server-git", "versions": ">=2025.1.0", "pin": "2026.8.18", "rules": {"path_flags": ["--repository", "-r"], "path_inputs": ["repo_path"], "allow_flags": ["--repository", "-r", "-v", "--verbose"]}, "bins": ["mcp-server-git"]},- {"id": "sqlite", "title": "SQLite", "runtime": "npm", "package": "mcp-server-sqlite-npx", "versions": ">=0.8.0", "pin": "0.8.0", "rules": {"path_args": "positional", "min_args": 1}, "bins": ["mcp-server-sqlite-npx"]},- {"id": "memory", "title": "Memory", "runtime": "npm", "package": "@modelcontextprotocol/server-memory", "versions": ">=2025.4.25", "pin": "2026.8.31", "rules": {"path_env": {"MEMORY_FILE_PATH": ".mcp-memory.jsonl"}}, "bins": ["mcp-server-memory"]},- {"id": "sequential-thinking", "title": "Sequential thinking", "runtime": "npm", "package": "@modelcontextprotocol/server-sequential-thinking", "versions": ">=2025.7.1", "pin": "2026.8.31", "bins": ["mcp-server-sequential-thinking"]},- {"id": "time", "title": "Time", "runtime": "pypi", "package": "mcp-server-time", "versions": ">=2025.1.0", "pin": "2026.8.18", "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", "bins": ["mcp-server-everything"]},- {"id": "playwright", "title": "Playwright (local pages)", "runtime": "npm", "package": "@playwright/mcp", "versions": ">=0.0.40", "pin": "0.0.83", "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": "filesystem", "title": "Filesystem", "runtime": "npm", "package": "@modelcontextprotocol/server-filesystem", "versions": ">=2025.1.14", "pin": "2026.8.31", "write_tools": ["write_file", "edit_file", "create_directory", "move_file"], "rules": {"path_args": "positional", "default_args": ["."]}, "bins": ["mcp-server-filesystem"]},+ {"id": "git", "title": "Git", "runtime": "pypi", "package": "mcp-server-git", "versions": ">=2025.1.0", "pin": "2026.8.18", "write_tools": ["git_commit", "git_add", "git_reset", "git_create_branch", "git_checkout"], "rules": {"path_flags": ["--repository", "-r"], "path_inputs": ["repo_path"], "allow_flags": ["--repository", "-r", "-v", "--verbose"]}, "bins": ["mcp-server-git"]},+ {"id": "sqlite", "title": "SQLite", "runtime": "npm", "package": "mcp-server-sqlite-npx", "versions": ">=0.8.0", "pin": "0.8.0", "write_tools": ["write_query", "create_table"], "rules": {"path_args": "positional", "min_args": 1}, "bins": ["mcp-server-sqlite-npx"]},+ {"id": "memory", "title": "Memory", "runtime": "npm", "package": "@modelcontextprotocol/server-memory", "versions": ">=2025.4.25", "pin": "2026.8.31", "write_tools": ["create_entities", "create_relations", "add_observations", "delete_entities", "delete_observations", "delete_relations"], "rules": {"path_env": {"MEMORY_FILE_PATH": ".mcp-memory.jsonl"}}, "bins": ["mcp-server-memory"]},+ {"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"]}],"deny": [{"match": "@modelcontextprotocol/server-github", "reason": "The GitHub server works on your GitHub account."},