A desktop coding agent with free access to frontier models.
TypeScript
fix: MCP servers keep uv, pip and npm settings
ogsamrat0cf7b0455f06
diff --git a/apps/server/src/mcp-allow/PARITY.sha256 b/apps/server/src/mcp-allow/PARITY.sha256index 587db842..ac89cdff 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.-07210e6d093e3850a3e0515b0ffd6cffc253a0b64c24ee6771fb2465becb9f20 mcp-allow.mjs+c1af272ae82090c87413d425d9f777bae8674e529e16c6fff8d893b43a07af7b mcp-allow.mjs3cd05cf4c762ef50667a2539f8fc8d8dffadc75ca9fd963cdb20cc32ea457dc3 mcp-allow.d.mtsdiff --git a/apps/server/src/mcp-allow/mcp-allow.mjs b/apps/server/src/mcp-allow/mcp-allow.mjsindex 8ce695d0..853f6946 100644--- a/apps/server/src/mcp-allow/mcp-allow.mjs+++ b/apps/server/src/mcp-allow/mcp-allow.mjs@@ -152,11 +152,14 @@ export const MCP_ENV_ALLOW = Object.freeze([// The desktop session, so a server can open a window (a headed browser on Linux)."DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "DBUS_SESSION_BUS_ADDRESS", "PLAYWRIGHT_BROWSERS_PATH",]);-// Locale, desktop folders, Volta and git's own settings (identity, config file, ssh, certificates).-const MCP_ENV_ALLOW_PREFIX = /^(?:LC_|XDG_|VOLTA_|GIT_)/i;-// Git settings that can carry a login or start a helper that hands one out (http.extraHeader through-// GIT_CONFIG_*, an askpass or credential helper): empty for a server like every other variable.-const MCP_ENV_GIT_CREDENTIAL = /^GIT_(?:ASKPASS$|CREDENTIAL|HTTP_EXTRAHEADER|CONFIG_PARAMETERS$|CONFIG_COUNT$|CONFIG_KEY_|CONFIG_VALUE_)|(?:^|_)(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|AUTH|CREDENTIALS?|ASKPASS|COOKIE|KEY)(?:_|$)/i;+// Locale, desktop folders, Volta, git's own settings (identity, config file, ssh, certificates) and the+// package tools' settings (uv, pip, npm: caches, mirrors, Python choice), which an empty value would break.+// Like the proxy and index settings above, a mirror address among them may hold a user:pass@ login.+const MCP_ENV_ALLOW_PREFIX = /^(?:LC_|XDG_|VOLTA_|GIT_|UV_|PIP_|NPM_CONFIG_)/i;+// Among those, the names that can carry a login or start a helper that hands one out (http.extraHeader+// through GIT_CONFIG_*, an askpass or credential helper, a publish token, an index password, npm's+// _authToken): empty for a server like every other variable.+const MCP_ENV_GIT_CREDENTIAL = /^GIT_(?:ASKPASS$|CREDENTIAL|HTTP_EXTRAHEADER|CONFIG_PARAMETERS$|CONFIG_COUNT$|CONFIG_KEY_|CONFIG_VALUE_)|TOKEN|SECRET|PASSW|PASSPHRASE|(?:^|_)PASS(?:_|$)|AUTH(?!OR(?!I[SZ]))|CREDENTIAL|COOKIE|KEY|ASKPASS|(?:^|_)OTP$/i;// Never reaches a server, whatever its rules say.const MCP_ENV_NEVER = /^(?:OMNIRUSH_|OPENCODE_SERVER_|OPENCODE_PASSWORD$)/i;diff --git a/apps/server/src/mcp-allow/state.test.ts b/apps/server/src/mcp-allow/state.test.tsindex 636fdd35..647272bb 100644--- a/apps/server/src/mcp-allow/state.test.ts+++ b/apps/server/src/mcp-allow/state.test.ts@@ -281,6 +281,17 @@ describe("MCP server environment", () => {expect(new Set(Object.values(out))).toEqual(new Set([""]));});+ test("a server keeps uv, pip and npm settings, never their logins", () => {+ const env = {+ UV_CACHE_DIR: "/home/u/.cache/uv", UV_PYTHON: "3.12", PIP_CACHE_DIR: "/p", npm_config_cache: "/n", NPM_CONFIG_PREFIX: "/np", GIT_AUTHOR_EMAIL: "a@b",+ UV_PUBLISH_TOKEN: "x", UV_INDEX_CORP_PASSWORD: "x", PIP_PASSWORD: "x", npm_config__authToken: "x", NPM_CONFIG__AUTH: "x",+ };+ expect(Object.keys(mcpServerEnvironment({ ...env, UV_KEYRING_PROVIDER: "subprocess", PIP_CLIENT_CERT_KEY: "x" }, {}, [], "linux")).sort()).toEqual(["NPM_CONFIG__AUTH", "PIP_CLIENT_CERT_KEY", "PIP_PASSWORD", "UV_INDEX_CORP_PASSWORD", "UV_KEYRING_PROVIDER", "UV_PUBLISH_TOKEN", "npm_config__authToken"]);+ const more = { "npm_config_//registry.npmjs.org/:_authToken": "x", "npm_config_//host/:_password": "x", npm_config_authorization: "x", npm_config_otp: "123456", GIT_HTTP_PASS: "x", GIT_SSH_PASSPHRASE: "x", UV_INDEX_X_PASS: "x",+ XDG_SESSION_TYPE: "wayland", GIT_AUTHOR_NAME: "A", LC_ALL: "C", npm_config_init_author_name: "A" };+ expect(Object.keys(mcpServerEnvironment(more, {}, [], "linux")).sort()).toEqual(["GIT_HTTP_PASS", "GIT_SSH_PASSPHRASE", "UV_INDEX_X_PASS", "npm_config_//host/:_password", "npm_config_//registry.npmjs.org/:_authToken", "npm_config_authorization", "npm_config_otp"]);+ });+test("Windows: a server's own variable wins over the engine's whatever the case", () => {expect(mcpServerEnvironment({ memory_file_path: "C:\\other" }, { MEMORY_FILE_PATH: "C:\\work\\m" }, [], "win32")).toEqual({ MEMORY_FILE_PATH: "C:\\work\\m" });});