Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Another bot's own connection stays theirs; limits and cleanup hold on edit and delete
Bruno88d0d4327064
diff --git a/server/host/mcp-config.test.ts b/server/host/mcp-config.test.tsindex f34dcdb1c2..7252edeab5 100644--- a/server/host/mcp-config.test.ts+++ b/server/host/mcp-config.test.ts@@ -208,6 +208,15 @@ describe("how many MCP servers fit", () => {expect(config.add("one-more", own("bot-new"))).toEqual({ status: 400, error: "You can add at most 100 MCP servers in all." });});+ it("an edit that gives a server to a bot counts it against that bot's limit, and other edits still save", () => {+ const { cfg, config } = fixture();+ fill(cfg, 20, () => own("bot-a"), "a");+ fill(cfg, 1, () => own("bot-b"), "b");+ expect(config.replace("b0", own("bot-a"))).toEqual({ status: 400, error: "A bot can use at most 20 MCP servers: the shared ones plus its own." });+ expect(config.replace("a0", own("bot-b"))).toMatchObject({ status: 200 });+ expect(config.replace("a1", { ...own("bot-a"), args: ["--readonly"] } as StoredMcpServer)).toMatchObject({ status: 200 });+ });+it("an import counts each pasted server against the same limits", async () => {const { cfg, config } = fixture();fill(cfg, 15, () => own("bot-a"), "a");diff --git a/server/host/mcp-config.ts b/server/host/mcp-config.tsindex f2f2c28f61..4a57c591cd 100644--- a/server/host/mcp-config.ts+++ b/server/host/mcp-config.ts@@ -178,6 +178,11 @@ export function createMcpConfig(deps: McpConfigDeps & { changed(): void }): McpCreplace: (name, server, keys) => write(() => {const found = stored(name);if (!found.existing) return found.result!;+ if (server.bot !== found.existing.bot) {+ const { [name]: _replaced, ...others } = found.current;+ const limit = mcpServerLimitError(others, [server]);+ if (limit) return { status: 400, error: limit };+ }const refusal = refused(name, server);if (refusal) return refusal;if (keys) deps.keys?.grant(name, keys);diff --git a/server/host/mcp-servers-host.test.ts b/server/host/mcp-servers-host.test.tsindex 4b57fdb888..d1b021db3e 100644--- a/server/host/mcp-servers-host.test.ts+++ b/server/host/mcp-servers-host.test.ts@@ -212,3 +212,14 @@ it("forgets the sign-in of a bot's own web connection when it goes with the bot,expect(cfg.mcpServers).toEqual({});expect(oauth.authState("linear_iris", url)).not.toBe("signed-in");});++it("still forgets the sign-in when forgetting the server's Vault items fails", () => {+ const data = mkdtempSync(join(tmpdir(), "omb-mcp-host-"));+ dirs.push(data);+ const forgotten: string[] = [];+ const cfg = { mcpServers: { linear_iris: { type: "http", url: "https://mcp.linear.app/mcp", headers: {}, enabled: true, bot: "iris" } } } as unknown as AppConfig;+ const keys = { forgetServer: () => { throw new Error("vault write failed"); } } as unknown as ReturnType<typeof createMcpKeys>;+ const host = createMcpServersHost({ dataDir: data, cfg: () => cfg, persist: (next) => { cfg.mcpServers = next; }, bots: () => [IRIS], startsServers: () => true, boxed: () => false, policy: (servers) => servers, tell: () => {}, keys, forgetSignIn: (name) => forgotten.push(name) });+ expect(() => host.botDeleted("iris")).toThrow("vault write failed");+ expect(forgotten).toEqual(["linear_iris"]);+});diff --git a/server/host/mcp-servers-host.ts b/server/host/mcp-servers-host.tsindex 8b82d5ad7e..ae609e5cb4 100644--- a/server/host/mcp-servers-host.ts+++ b/server/host/mcp-servers-host.ts@@ -155,8 +155,11 @@ export function createMcpServersHost(deps: McpServersHostDeps) {deps.persist(next);for (const name of Object.keys(before ?? {})) {if (Object.hasOwn(next, name)) continue;- deps.keys?.forgetServer(name);- deps.forgetSignIn?.(name);+ try {+ deps.keys?.forgetServer(name);+ } finally {+ deps.forgetSignIn?.(name);+ }}},/** At start: the first time bots run boxed here, servers in one existing bot's folders become its own (said once);diff --git a/server/mcp-bot-rules.test.ts b/server/mcp-bot-rules.test.tsindex cee061e1a7..3d43a16481 100644--- a/server/mcp-bot-rules.test.ts+++ b/server/mcp-bot-rules.test.ts@@ -32,9 +32,10 @@ describe("mcpOwner and botMayChange", () => {expect(owner(remote({ bot: "bot2" }))).toBe("theirs");expect(owner(remote({ bot: "bot1" }))).toBe("own");});- it("a Team Cloud personal server wins over everything else", () => {+ it("a Team Cloud personal server wins over everything but another bot's own", () => {expect(owner(remote(), ["x"])).toBe("person");- expect(owner(stdio({ bot: "bot2" }), ["x"])).toBe("person");+ expect(owner(stdio({ bot: "bot1" }), ["x"])).toBe("person");+ expect(owner(remote({ bot: "bot2" }), ["x"])).toBe("theirs");expect(botMayChange("person")).toEqual({ ok: false, error: "This connection is each person's own. Change it in Settings." });});it("a bot's own server that runs elsewhere is elsewhere", () => {diff --git a/server/mcp-bot-rules.ts b/server/mcp-bot-rules.tsindex 7bd8f4b50b..acb1daeccc 100644--- a/server/mcp-bot-rules.ts+++ b/server/mcp-bot-rules.ts@@ -12,8 +12,8 @@ const WHOLE_REF = /^secret-ref:[0-9a-f]{32}$/;const SECRET_FLAG_ARG = /^--(?:token|password|passwd|api-key|apikey|secret|access-key|auth-token)$/i;export function mcpOwner(name: string, server: StoredMcpServer, botId: string, personal: readonly string[]): McpOwner {- if (personal.includes(name)) return "person";if (server.bot && server.bot !== botId) return "theirs";+ if (personal.includes(name)) return "person";if (server.runsOn) return "elsewhere";if (server.bot) return "own";return "shared";