Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix: MCP programs from the package only

ogsamratb41e46a261e2
diff --git a/apps/server/src/mcp-allow/PARITY.sha256 b/apps/server/src/mcp-allow/PARITY.sha256
index ebdaba44..01cadd92 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.
-5de89e179a24fee3dd7ceb8c3af050195953979684bf3d8e49e6ced943a6ae06 mcp-allow.mjs
-e7372163d8df8285b60d97b9f679c5b68ee202f009253e2e5ff2d57b0203dd0d mcp-allow.d.mts
+cb9d65c9bfde0212a94103ef6e44246efc518cb505bae3c760f601a9e3062e83 mcp-allow.mjs
+595fb56b35a751af51b3c91ff8235f27fefe2b69e19a52b53d49093f1acf8f1f mcp-allow.d.mts
diff --git a/apps/server/src/mcp-allow/mcp-allow.d.mts b/apps/server/src/mcp-allow/mcp-allow.d.mts
index 735b32af..8259fc0a 100644
--- a/apps/server/src/mcp-allow/mcp-allow.d.mts
+++ b/apps/server/src/mcp-allow/mcp-allow.d.mts
@@ -23,6 +23,8 @@ export type McpRules = {
path_env?: Record<string, string>;
local_urls?: boolean;
path_inputs?: string[];
+ /** Flags whose value must be one of these. */
+ flag_values?: Record<string, string[]>;
};
export type McpAllowEntry = {
diff --git a/apps/server/src/mcp-allow/mcp-allow.mjs b/apps/server/src/mcp-allow/mcp-allow.mjs
index 1d51321a..7f35b7bc 100644
--- a/apps/server/src/mcp-allow/mcp-allow.mjs
+++ b/apps/server/src/mcp-allow/mcp-allow.mjs
@@ -124,6 +124,13 @@ function normalizeRules(value) {
const out = {};
if (rules.path_args === "positional") out.path_args = "positional";
if (Number.isInteger(rules.min_args) && rules.min_args > 0 && rules.min_args < 9) out.min_args = rules.min_args;
+ if (isRecord(rules.flag_values)) {
+ const values = Object.fromEntries(Object.entries(rules.flag_values)
+ .filter(([k, v]) => /^-{1,2}[\w-]+$/.test(k) && Array.isArray(v))
+ .map(([k, v]) => [k, strings(v, 16)])
+ .slice(0, 16));
+ if (Object.keys(values).length) out.flag_values = values;
+ }
const defaults = strings(rules.default_args, 8);
if (defaults.length) out.default_args = defaults;
for (const key of ["path_flags", "require_flags", "add_flags", "forbid_flags", "allow_flags"]) {
@@ -402,9 +409,14 @@ 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
- && (launch.bin === null || e.bins.length === 0 || e.bins.includes(launch.bin)));
+ const entry = policy.allow.find((e) => 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 ...`.
+ if (launch.bin !== null && !entry.bins.includes(launch.bin)) {
+ decisions.push(blocked(name, "unknown_command", { package: launch.name, reason: `${MCP_REASONS.unknown_command} (${launch.bin} is not one of its programs)` }));
+ continue;
+ }
const base = { id: entry.id, package: entry.package, runtime: entry.runtime, title: entry.title };
if (Object.hasOwn(out, entry.id)) { decisions.push(blocked(name, "duplicate", base)); continue; }
let version = launch.version;
@@ -436,6 +448,10 @@ export function evaluateMcp(mcpMap, policy, ctx = {}) {
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})` });
}
+ if (!refusal) for (const [flag, values] of Object.entries(rules.flag_values ?? {})) {
+ const found = flagValue(rest, flag);
+ if (found && !values.includes(found.value ?? "")) { refusal = blocked(name, "flag", { ...base, version, reason: `${MCP_REASONS.flag} (${flag} ${found.value ?? ""}; supported: ${values.join(", ")})` }); break; }
+ }
if (!refusal) for (const flag of rules.forbid_flags ?? []) {
if (flagValue(rest, flag)) { refusal = blocked(name, "flag", { ...base, version, reason: `${MCP_REASONS.flag} (${flag})` }); break; }
}
diff --git a/apps/server/src/mcp-allow/mcp-policy.fixture.json b/apps/server/src/mcp-allow/mcp-policy.fixture.json
index 4e4c5d68..3375f470 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": ["."]}},
- {"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"]}},
- {"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}},
- {"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"}}},
- {"id": "sequential-thinking", "title": "Sequential thinking", "runtime": "npm", "package": "@modelcontextprotocol/server-sequential-thinking", "versions": ">=2025.7.1", "pin": "2026.8.31"},
- {"id": "time", "title": "Time", "runtime": "pypi", "package": "mcp-server-time", "versions": ">=2025.1.0", "pin": "2026.8.18", "rules": {"allow_flags": ["--local-timezone"]}},
- {"id": "everything", "title": "Everything (test server)", "runtime": "npm", "package": "@modelcontextprotocol/server-everything", "versions": ">=2025.7.1", "pin": "2026.8.31"},
- {"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"]}}
+ {"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"]}
],
"deny": [
{"match": "@modelcontextprotocol/server-github", "reason": "The GitHub server works on your GitHub account."},