Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix: MCP env handshake per config, credential names in whole parts

ogsamrat81ed112ea0ae
diff --git a/apps/server/src/mcp-allow/PARITY.sha256 b/apps/server/src/mcp-allow/PARITY.sha256
index 909b3113..f28dfa86 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.
-bad379b4cf7987cf858c6b557567c0ecdac199c7c65e681be7346a17657e1440 mcp-allow.mjs
+9e49d8bb16e36d089e01f916dc134f09489a738d416e2e0606214427fca4b16d mcp-allow.mjs
fe81f4d8eb0360fe47a086f59dace916f5138713073df7b1ffda7bf0dc846591 mcp-allow.d.mts
diff --git a/apps/server/src/mcp-allow/mcp-allow.mjs b/apps/server/src/mcp-allow/mcp-allow.mjs
index b2ec43d0..282e79b3 100644
--- a/apps/server/src/mcp-allow/mcp-allow.mjs
+++ b/apps/server/src/mcp-allow/mcp-allow.mjs
@@ -186,10 +186,12 @@ const MCP_ENV_ALLOW_UPPER = new Set(MCP_ENV_ALLOW.map((k) => k.toUpperCase()));
// The engine's values a server's entry must not hold anywhere (its command, variables or folder): the app's
// tokens and the engine's password, from 8 characters on. A project config could copy them in ({env:...}).
-const PROTECTED_VALUE_NAME = /^(?:OPENCODE_SERVER_|OPENCODE_PASSWORD$)|^OMNIRUSH_.*(?:TOKEN|SECRET|PASSWORD|PASSWD|KEY|AUTH|CREDENTIAL|COOKIE|SESSION)/i;
+// Whole name parts only, and not a setting that names where something is (…_URL, …_DIR, …_PATH, …).
+const PROTECTED_VALUE_NAME = /^(?:OPENCODE_SERVER_|OPENCODE_PASSWORD$)|^OMNIRUSH_(?:\w*_)?(?:TOKENS?|SECRETS?|PASSWORD|PASSWD|KEYS?|CREDENTIALS?|COOKIES?|AUTH)(?:_|$)/i;
+const PROTECTED_VALUE_NOT = /_(?:URL|DIR|PATH|FILE|STORE|MS|MODULE|MODE)$/i;
export function protectedValues(engineEnv) {
return [...new Set(Object.entries(engineEnv ?? {})
- .filter(([k, v]) => typeof v === "string" && v.length >= 8 && PROTECTED_VALUE_NAME.test(k))
+ .filter(([k, v]) => typeof v === "string" && v.length >= 8 && PROTECTED_VALUE_NAME.test(k) && !(k.startsWith("OMNIRUSH_") && PROTECTED_VALUE_NOT.test(k)))
.map(([, v]) => v))];
}
diff --git a/apps/server/src/opencode-plugins/omnirush-mcp-policy.ts b/apps/server/src/opencode-plugins/omnirush-mcp-policy.ts
index b732f782..1dd4201b 100644
--- a/apps/server/src/opencode-plugins/omnirush-mcp-policy.ts
+++ b/apps/server/src/opencode-plugins/omnirush-mcp-policy.ts
@@ -17,7 +17,7 @@
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
import path from "node:path";
-import { createMcpPolicyHooks, engineStartsServersEnvOnly, mcpServerEnvironment, reportPath, type McpBox } from "../mcp-allow/mcp-allow.mjs";
+import { createMcpPolicyHooks, MCP_ENV_VALUES_MARK, mcpServerEnvironment, reportPath, type McpBox } from "../mcp-allow/mcp-allow.mjs";
import { readWorkspaceMcp } from "../mcp-allow/state.js";
import { computerUseBuiltins, COMPUTER_USE_DIR_ENV } from "../computer-use/desktop.js";
import { isComputerTool, SERVER_ID } from "../computer-use/shared/contract.mjs";
@@ -143,7 +143,9 @@ export default async function omnirushMcpPolicy(input?: { directory?: string; cl
// Like every server: the engine's tokens never reach it, only the variables the allowlist keeps plus
// the ones the app gives it.
const own = isRecord(builtin.environment) ? Object.fromEntries(Object.entries(builtin.environment).filter((entry): entry is [string, string] => typeof entry[1] === "string")) : {};
- const environment = { ...mcpServerEnvironment(process.env, {}, [], process.platform, { envOnly: engineStartsServersEnvOnly() }), ...own };
+ // Values only when the filter marked this config (the engine then leaves the rest of its environment out).
+ const envOnly = (target as Record<symbol, unknown>)[MCP_ENV_VALUES_MARK] === true;
+ const environment = { ...mcpServerEnvironment(process.env, {}, [], process.platform, { envOnly }), ...own };
target.mcp = { ...(isRecord(target.mcp) ? target.mcp : {}), [SERVER_ID]: { ...builtin, environment } };
// The host asks the person itself (never the engine's permission prompts), in every mode.
const permission: Record<string, unknown> = typeof target.permission === "string" ? { "*": target.permission } : isRecord(target.permission) ? { ...target.permission } : {};