Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Lent MCP: test that the computer's server port reaches the refusal
aivsomkarfaeafb97409e
diff --git a/electron/lent-mcp.mjs b/electron/lent-mcp.mjsindex 15c9faf8de..61c468b953 100644--- a/electron/lent-mcp.mjs+++ b/electron/lent-mcp.mjs@@ -56,7 +56,8 @@ export function isLoopbackAddress(url) {}/** Why this computer won't run `server` for this grant, or null. A command server starts a program here, which only a- * lent terminal allows; a URL server must be at this computer's own loopback address. */+ * lent terminal allows; a URL server must be at this computer's own loopback address on an explicit port of 1024 or+ * higher, and `createLentMcp` refuses this computer's own ports as it calls. */export function lentMcpRefusal(grant, server) {if (!grant?.cloud) return "MCP servers run here only for the person's own Clouds";if ("command" in server) return grant.terminal === true ? null : "Running commands is not enabled for this server";diff --git a/server/cloud-lent-mcp.e2e.test.ts b/server/cloud-lent-mcp.e2e.test.tsindex abd49360a3..396767cd80 100644--- a/server/cloud-lent-mcp.e2e.test.ts+++ b/server/cloud-lent-mcp.e2e.test.ts@@ -195,8 +195,9 @@ readline.createInterface({ input: process.stdin }).on("line", (line) => {mkdirSync(dirname(file), { recursive: true });writeFileSync(file, JSON.stringify({ version: 1, records: { [env.id]: { sessionId: null, environmentId: null, id: randomUUID(), secret: randomBytes(32).toString("hex"), enabled: true,folders: [], terminal: false, computer: false, internet: true, cloud: { accountId: "acct_fixture", origin: base } } } }));+ let macServerPorts: number[] = [];connector = createComputerSharing({- file, environments: () => [env], localEnvironments: () => [MAC_INSTALL], myCloud: () => env, ownClouds: () => [env], cuaConnection: async () => null, enabled: async () => false,+ file, serverPorts: () => macServerPorts, environments: () => [env], localEnvironments: () => [MAC_INSTALL], myCloud: () => env, ownClouds: () => [env], cuaConnection: async () => null, enabled: async () => false,cloud: () => ({ status: "connected", accountId: "acct_fixture", origin: base }), home: join(home, "mac-home"),fetch: (url: string, init: RequestInit) => fetch(url, { ...init, headers: { ...init.headers as Record<string, string>, authorization: `Bearer ${owner}`, host: HOST, "x-forwarded-for": "203.0.113.9", "x-forwarded-proto": "https", origin: `https://${HOST}` } }),});@@ -228,6 +229,15 @@ readline.createInterface({ input: process.stdin }).on("line", (line) => {expect(macRequests.every((request) => request.authorization === "Bearer mac-header-key")).toBe(true);expect(connector.activity(env.id).map((entry) => [entry.action, entry.ok])).toEqual(expect.arrayContaining([["mcp_tools", true], ["mcp_call", true]]));+ // Were the Mac's own OpenMausBot server on that port, the Mac refuses the call itself, in words the bot reads, and+ // nothing reaches the port.+ macServerPorts = [Number(new URL(macUrl).port)];+ const reached = macRequests.length;+ const own = await call("tools/call", { name: "search_notes", arguments: { q: "plan" } });+ expect(own.result).toEqual({ content: [{ type: "text", text: "Only an MCP server on its own port (1024 or higher) at this computer's address can be reached, never this computer's own OpenMausBot or Chrome ports" }], isError: true });+ expect(macRequests.length).toBe(reached);+ macServerPorts = [];+// The person lets My Cloud run commands on this Mac: the program starts there, from the connector, never on My Cloud.await connector.lendTerminal(true);await expect.poll(async () => (await api("GET", "/api/shared-computers", { token: owner })).body.computers?.[0]?.scopes?.terminal, { timeout: 8000 }).toBe(true);