Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

test(grok): the URL form lists what the stdio proxies listed; every own server converts

milind-sonia6c54678d75a
diff --git a/server/drivers/own-mcp-http.test.ts b/server/drivers/own-mcp-http.test.ts
index 337dd32423..71fa54ca06 100644
--- a/server/drivers/own-mcp-http.test.ts
+++ b/server/drivers/own-mcp-http.test.ts
@@ -109,9 +109,14 @@ describe("an ACP engine", () => {
it("sends a session its own servers by URL only when that session's agent said it takes them, the person's as they were", () => {
const pairs = (record: Record<string, string>) => Object.entries(record).map(([name, value]) => ({ name, value }));
+ const harnessServer = (kind: string) => ({ name: kind, command: process.execPath, args: [SPAWNED_PROXIES.harnessMcp, kind],
+ env: pairs({ OMB_HARNESS_URL: HARNESS, [`OMB_MCP_TOKEN_${kind.toUpperCase()}`]: `${kind}-capability` }) });
const servers: AcpMcpServer[] = [
{ name: "agents", command: agents.command, args: agents.args, env: pairs(agents.env) },
{ name: "browser", command: browser.command, args: browser.args, env: pairs(browser.env) },
+ ...["computer", "data", "email", "device"].map(harnessServer),
+ { name: "phone", command: phone.command, args: phone.args, env: pairs(phone.env) },
+ { name: "ogb", command: ogb.command, args: ogb.args, env: [] },
{ name: "notes", command: "npx", args: ["notes"], env: [] },
];
const http = { agentCapabilities: { mcpCapabilities: { http: true, sse: false } } };
@@ -120,7 +125,12 @@ describe("an ACP engine", () => {
expect(acpSessionMcpServers(servers, "stdio", http)).toBe(servers);
const sent = acpSessionMcpServers(servers, "advertised", http);
expect(sent.map((server) => "type" in server ? `${server.name}:${server.url}` : server.name)).toEqual([
- `agents:${HARNESS}/api/internal/mcp-http/agents`, `browser:${HARNESS}/api/internal/mcp-http/browser`, "notes"]);
+ ...["agents", "browser", "computer", "data", "email", "device"].map((name) => `${name}:${HARNESS}/api/internal/mcp-http/${name}`),
+ "phone", "ogb", "notes"]);
+ expect(sent.slice(6)).toEqual(servers.slice(6));
+ for (const kind of ["computer", "data", "email", "device"]) {
+ expect((sent.find((server) => server.name === kind) as Extract<AcpMcpServer, { type: "http" }>).headers).toEqual([{ name: "authorization", value: `Bearer ${kind}-capability` }]);
+ }
const own = sent[1] as Extract<AcpMcpServer, { type: "http" }>;
expect(own.headers).toEqual([{ name: "authorization", value: "Bearer browse" }, { name: "x-omb-tool-limit", value: "12" }]);
const agentsHeaders = Object.fromEntries((sent[0] as Extract<AcpMcpServer, { type: "http" }>).headers.map(({ name, value }) => [name, value]));
diff --git a/server/grok-own-mcp-http.e2e.test.ts b/server/grok-own-mcp-http.e2e.test.ts
index f59c017fae..922499659c 100644
--- a/server/grok-own-mcp-http.e2e.test.ts
+++ b/server/grok-own-mcp-http.e2e.test.ts
@@ -21,12 +21,12 @@ it("gives a Grok turn OpenMausBot's own tools by URL, no proxy process each, eve
};
const dump = join(dataDir, "grok-launch.json");
const calls = join(dataDir, "grok-calls.json");
- const engine = (mode: string) => {
- const wrapper = join(dataDir, `grok-${mode}.mjs`);
+ const engine = (mode: string, http = true) => {
+ const wrapper = join(dataDir, `grok-${mode}-${http ? "http" : "stdio"}.mjs`);
writeFileSync(wrapper, [
"#!/usr/bin/env node",
`process.env.FAKE_ACP_MODE = ${JSON.stringify(mode)};`,
- 'process.env.FAKE_ACP_MCP_TRANSPORTS = "http";',
+ ...(http ? ['process.env.FAKE_ACP_MCP_TRANSPORTS = "http";'] : []),
`process.env.FAKE_ACP_DUMP = ${JSON.stringify(dump)};`,
`process.env.FAKE_ACP_MCP_CALLS_FILE = ${JSON.stringify(calls)};`,
`await import(${JSON.stringify(new URL("./testing/fake-acp-cli.ts", import.meta.url).href)});`,
@@ -35,7 +35,6 @@ it("gives a Grok turn OpenMausBot's own tools by URL, no proxy process each, eve
};
try {
expect((await cli("doctor")).ok).toBe(true);
- await engine("mcp-tools");
const bot = (await cli("new-bot", "--name", "Grok tools")).bot;
const threadId = bot.activeTaskId ?? bot.threadId;
await api("PATCH", `/api/bots/${bot.id}`, { modelSelection: { instanceId: "grok", model: "fake-model" } });
@@ -46,18 +45,29 @@ it("gives a Grok turn OpenMausBot's own tools by URL, no proxy process each, eve
return messages.filter((message) => message.role === "bot" && !message.text?.startsWith("[digest]")).at(-1)?.text ?? "";
};
- const listed = await turn("List your tools.");
- const sent = JSON.parse(readFileSync(`${dump}.mcp.json`, "utf8")) as Array<{ name: string; type?: string; url?: string; command?: string }>;
- evidence.push({ sent: sent.map(({ name, type, url, command }) => ({ name, type, url, command })) });
+ type Sent = Array<{ name: string; type?: string; url?: string; command?: string; args?: string[] }>;
+ const ownProxy = (server: Sent[number]) => (server.args ?? []).some((arg) => /(?:agents-proxy|harness-mcp-proxy)\.[jt]s$/.test(arg));
+ const lists = (text: string) => Object.fromEntries(text.trim().split("\n").map((line) => line.split(": "))
+ .map(([name, tools]) => [name, tools!.split(",").sort()])) as Record<string, string[]>;
+
+ // The same bot over the stdio proxies, as an agent that does not take MCP servers by URL gets them.
+ await engine("mcp-tools", false);
+ const overStdio = lists(await turn("List your tools."));
+ const stdioSent = JSON.parse(readFileSync(`${dump}.mcp.json`, "utf8")) as Sent;
+ expect(stdioSent.filter(ownProxy).map((server) => server.name)).toEqual(expect.arrayContaining(["agents", "data"]));
+
+ await engine("mcp-tools");
+ const overUrl = lists(await turn("List your tools."));
+ const sent = JSON.parse(readFileSync(`${dump}.mcp.json`, "utf8")) as Sent;
+ evidence.push({ stdioSent: stdioSent.map(({ name, type, command }) => ({ name, type, command })), sent: sent.map(({ name, type, url, command }) => ({ name, type, url, command })) });
+ // None of OpenMausBot's own servers is a process any more: each is this server's endpoint, with every tool it listed before.
+ expect(sent.filter(ownProxy)).toEqual([]);
const own = sent.filter((server) => server.type === "http");
- // Every server this fixture's turn has is OpenMausBot's own, and none is a process.
- expect(own.map((server) => server.name)).toEqual(expect.arrayContaining(["agents", "data"]));
- expect(sent.filter((server) => server.command !== undefined)).toEqual([]);
+ expect(own.map((server) => server.name).sort()).toEqual(stdioSent.filter(ownProxy).map((server) => server.name).sort());
for (const server of own) expect(server.url).toBe(`${url}/api/internal/mcp-http/${server.name}`);
- const lists = Object.fromEntries(listed.trim().split("\n").map((line) => line.split(": ")).map(([name, tools]) => [name, tools!.split(",")]));
- expect(Object.keys(lists).sort()).toEqual(own.map((server) => server.name).sort());
- expect(lists.agents).toEqual(expect.arrayContaining(["list_bots"]));
- expect(lists.data).toEqual(expect.arrayContaining(["data_sql"]));
+ for (const server of own) expect(overUrl[server.name], server.name).toEqual(overStdio[server.name]);
+ expect(overUrl.agents).toEqual(expect.arrayContaining(["list_bots"]));
+ expect(overUrl.data).toEqual(expect.arrayContaining(["data_sql"]));
await engine("mcp-calls");
writeFileSync(calls, JSON.stringify([
@@ -67,7 +77,7 @@ it("gives a Grok turn OpenMausBot's own tools by URL, no proxy process each, eve
const called = await turn("Call them.");
expect(called).toContain("list_bots: ");
expect(called).toMatch(/data_sql: .*42/s);
- expect(JSON.parse(readFileSync(`${dump}.mcp.json`, "utf8")).every((server: { type?: string }) => server.type === "http")).toBe(true);
+ expect((JSON.parse(readFileSync(`${dump}.mcp.json`, "utf8")) as Sent).filter(ownProxy)).toEqual([]);
evidence.push({ called });
} finally {
const evidencePath = `${logPath}.grok-own-mcp.json`;