A desktop coding agent with free access to frontier models.
TypeScript
fix: let prompts run when other tools' config lists MCP servers
ogsamrat9f62710d53b6
diff --git a/apps/server/src/engine-plugin-bridge.e2e.test.ts b/apps/server/src/engine-plugin-bridge.e2e.test.tsindex ec2226c5..df5875da 100644--- a/apps/server/src/engine-plugin-bridge.e2e.test.ts+++ b/apps/server/src/engine-plugin-bridge.e2e.test.ts@@ -1,5 +1,5 @@import { afterAll, beforeAll, describe, expect, test } from "bun:test";-import { existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";+import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";import { tmpdir } from "node:os";import { join, resolve } from "node:path";@@ -126,6 +126,12 @@ rl.on("line", (line) => {send({ jsonrpc: "2.0", id: m.id, result: { content: [{ type: "text", text: "ok" }] } });});`);+ // MCP servers another tool left in the user's global config and in the+ // project config: launching either one writes its marker file.+ const userMcp = (marker: string) => ({ type: "local", command: ["node", "-e", `require("node:fs").writeFileSync(${JSON.stringify(marker)}, "")`], enabled: true });+ mkdirSync(join(data, "xdg-config", "opencode"), { recursive: true });+ writeFileSync(join(data, "xdg-config", "opencode", "opencode.jsonc"), `// another tool\n${JSON.stringify({ mcp: { blender: userMcp(join(data, "blender-started")) } })}`);+ writeFileSync(join(work, "opencode.json"), JSON.stringify({ mcp: { supabase: userMcp(join(data, "supabase-started")) } }));const configPath = join(data, "runtime-opencode-config.json");writeFileSync(configPath, JSON.stringify({model: "mock/mock-model",@@ -198,6 +204,8 @@ rl.on("line", (line) => {return (await response.json()) as Record<string, unknown>;}, "the engine MCP inventory");expect(status.anyof).toBeUndefined();+ expect(status.blender).toBeUndefined();+ expect(status.supabase).toBeUndefined();await prompt({ providerID: "anth", modelID: "claude-mock" }, "Use the export tool.");await waitFor(async () => seen.find((entry) => entry.path === "/v1/messages"), "an Anthropic request");@@ -208,5 +216,7 @@ rl.on("line", (line) => {expect(tools.some((entry) => typeof entry === "object" && entry !== null&& "name" in entry && typeof entry.name === "string" && entry.name.endsWith("export_batch"))).toBe(false);}+ expect(existsSync(join(data, "blender-started"))).toBe(false);+ expect(existsSync(join(data, "supabase-started"))).toBe(false);}, 90_000);});diff --git a/apps/server/src/omnirush-ui-mcp-guard.e2e.test.ts b/apps/server/src/omnirush-ui-mcp-guard.e2e.test.tsindex 9f2d0a60..b4f5c995 100644--- a/apps/server/src/omnirush-ui-mcp-guard.e2e.test.ts+++ b/apps/server/src/omnirush-ui-mcp-guard.e2e.test.ts@@ -1,6 +1,6 @@import { afterEach, describe, expect, test } from "bun:test";import { Database } from "bun:sqlite";-import { mkdtemp, readFile, rm } from "node:fs/promises";+import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";import { tmpdir } from "node:os";import { join } from "node:path";@@ -51,6 +51,7 @@ function startMockEngine() {return Response.json({ [name]: { status: "connected" } });}if (url.pathname === "/mcp") return Response.json({});+ if (url.pathname === "/session/ses_1/prompt_async") return new Response(null, { status: 204 });if (url.pathname === "/session/status") return Response.json({});if (url.pathname === "/instance/dispose") return Response.json(true);return Response.json({ code: "not_found", message: "Not found" }, { status: 404 });@@ -60,7 +61,8 @@ function startMockEngine() {const pushedNames = () => requests.filter((entry) => entry.method === "POST" && entry.pathname === "/mcp").map((entry) => (entry.body as { name?: string } | null)?.name);- return { baseUrl: `http://127.0.0.1:${server.port}`, pushedNames };+ const prompts = () => requests.filter((entry) => entry.pathname === "/session/ses_1/prompt_async");+ return { baseUrl: `http://127.0.0.1:${server.port}`, pushedNames, prompts };}async function fixture() {@@ -188,4 +190,37 @@ describe("complete MCP ban at the HTTP and runtime boundaries", () => {// can repair it; runtime and engine boundaries never expose it.expect((await readRuntimeOpencodeConfig(config, "ws_1")).mcp?.["omnirush-ui"]).toEqual(LEGACY);});++ test("MCP servers left in the user's own config do not block prompts", async () => {+ const { config, engine } = await fixture();+ const root = config.workspaces[0]!.path;+ const globalDir = join(root, "global-opencode");+ await mkdir(globalDir, { recursive: true });+ await writeFile(join(globalDir, "opencode.jsonc"), `// written by another tool\n${JSON.stringify({ mcp: { blender: SAFE } })}`);+ await writeFile(join(root, "opencode.json"), JSON.stringify({ mcp: { supabase: SAFE } }));+ await seedRuntimeRow(config, "ws_1", { mcp: { "omnirush-ui": LEGACY } });+ const saved = {+ OPENCODE_CONFIG_DIR: process.env.OPENCODE_CONFIG_DIR,+ OMNIRUSH_DEV_MODE: process.env.OMNIRUSH_DEV_MODE,+ OMNIRUSH_SESSION_UPLOAD_OPTIONAL: process.env.OMNIRUSH_SESSION_UPLOAD_OPTIONAL,+ };+ stops.push(() => {+ for (const [name, value] of Object.entries(saved)) {+ if (value === undefined) delete process.env[name];+ else process.env[name] = value;+ }+ });+ process.env.OPENCODE_CONFIG_DIR = globalDir;+ process.env.OMNIRUSH_DEV_MODE = "1";+ process.env.OMNIRUSH_SESSION_UPLOAD_OPTIONAL = "1";+ const { call } = await start(config, engine.baseUrl);++ // The engine's MCP policy plugin strips these entries; the prompt itself runs.+ const response = await call("POST", "/workspace/ws_1/opencode/session/ses_1/prompt_async", {+ parts: [{ type: "text", text: "Fix the build" }],+ });+ expect(response.status).toBe(204);+ expect(engine.prompts()).toHaveLength(1);+ expect(engine.pushedNames()).toEqual([]);+ });});diff --git a/apps/server/src/server.ts b/apps/server/src/server.tsindex 74d0d978..0562f51f 100644--- a/apps/server/src/server.ts+++ b/apps/server/src/server.ts@@ -2154,10 +2154,6 @@ export async function proxyOpencodeRequest(input: {assertMcpAllowed(input.config);}if (workspace && workspace.workspaceType !== "remote" && isUploadPromptDispatch(method, proxyPath)) {- await assertNoConfiguredMcp(- workspace.path,- await readRuntimeOpencodeConfig(input.config, workspace.id),- );if (uploadDispatchRefused(input.config, workspace)) {// Drain the unread body so the client's keep-alive connection stays usable.await input.request.arrayBuffer().catch(() => undefined);