Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(mcp): skip personal servers in shared app probes
Sebastian Bf45b8adc989a
diff --git a/server/chat-apps-mcp.ts b/server/chat-apps-mcp.tsindex 7d275f01ad..1d9087e79b 100644--- a/server/chat-apps-mcp.ts+++ b/server/chat-apps-mcp.ts@@ -43,6 +43,7 @@ export interface ChatAppsMcpDeps {apps: ChatApps;storedServers(): Record<string, unknown>;mountedServers(bot: BotRecord): Record<string, McpServerSpec>;+ personMcp?(): readonly string[];oauth: ChatAppsMcpOAuth;dataDir?: string;catalog?: McpAppCatalog;@@ -371,7 +372,7 @@ export function createChatAppsMcp(deps: ChatAppsMcpDeps): ChatAppsMcp {queued.add(name);probing = probing.then(async () => {queued.delete(name);- if (closed) return;+ if (closed || deps.personMcp?.().includes(name)) return;const stored = storedServer(name, deps.storedServers()[name]);if (!stored?.enabled || stored.apps === false) return;if (isRemoteMcpServer(stored) && deps.oauth.authState(name, stored.url) === "needs-sign-in") return;diff --git a/server/cloud-team-connections.e2e.test.ts b/server/cloud-team-connections.e2e.test.tsindex 6211a9a22f..62002beffa 100644--- a/server/cloud-team-connections.e2e.test.ts+++ b/server/cloud-team-connections.e2e.test.ts@@ -36,7 +36,7 @@ beforeAll(async () => {mail = await startFakeHttpMcp({ tools: [{ name: "read_inbox" }] });oauth = await startFakeOAuth();notes = await startFakeHttpMcp({ tools: [{ name: "read_notes" }], acceptBearer: oauth.isValid, wwwAuthenticate: oauth.challenge });- fx = await launchCloudSendFixture({ onePasswordToken: TOKEN, broker, team: { id: "team-acme-1", name: "Acme", engine: ENGINE } });+ fx = await launchCloudSendFixture({ onePasswordToken: TOKEN, broker, team: { id: "team-acme-1", name: "Acme", engine: ENGINE, env: { OMB_BOT_BOX: "0" } } });team = fx.team!;owner = (await team.pair(OWNER)).token!;admin = (await team.pair(ADMIN)).token!;@@ -256,3 +256,49 @@ it("disconnects her own, and switching back to the team gives every turn the teaexpect(back.config).toContain(TEAM_KEY);expect(gmailCallsBy(teamUser)).toBe(teamBefore + 1);}, hostTimeout(120_000));++it("skips automatic personal MCP probes after setup and restart while still probing team servers", async () => {+ const ownAuthorization = "Bearer own-probe-key";+ const teamAuthorization = "Bearer team-probe-key";+ const personal = await startFakeHttpMcp({ requireHeaders: { Authorization: ownAuthorization } });+ const shared = await startFakeHttpMcp({ requireHeaders: { Authorization: teamAuthorization },+ tools: [{ name: "show_view", _meta: { ui: { resourceUri: "ui://probe/view.html" } } }] });+ try {+ const own = { type: "http", url: personal.url, headers: { Authorization: "" } };+ expect((await team.as(owner, "POST", "/api/mcp/servers", { name: "personal_probe", ...own })).status).toBe(201);+ expect((await team.as(owner, "PUT", "/api/team/connection-scopes", { kind: "mcp", id: "personal_probe", scope: "person" })).status).toBe(200);+ expect((await team.as(owner, "PUT", "/api/team/my-connections/mcp/personal_probe/key", { value: ownAuthorization })).status).toBe(200);+ expect((await team.as(owner, "PUT", "/api/mcp/servers/personal_probe", { ...own, enabled: false })).status).toBe(200);+ const tested = await team.as(owner, "POST", "/api/mcp/servers/personal_probe/test", {});+ expect(tested.status).toBe(200);+ expect(tested.body).toMatchObject({ ok: true });+ expect(personal.toolsLists).toBe(1);+ expect((await team.as(owner, "PATCH", "/api/mcp/servers/personal_probe", { enabled: true })).status).toBe(200);++ expect((await team.as(owner, "POST", "/api/mcp/servers", {+ name: "team_probe", type: "http", url: shared.url, headers: { Authorization: teamAuthorization },+ })).status).toBe(201);+ expect((await team.as(owner, "PATCH", "/api/mcp/servers/team_probe", { enabled: true })).status).toBe(200);+ const teamHasApps = async () => {+ const listed = await team.as(owner, "GET", "/api/mcp/servers");+ expect(listed.status).toBe(200);+ return listed.body.servers.find((server: { name: string }) => server.name === "team_probe")?.hasApps;+ };+ await expect.poll(teamHasApps, { timeout: 20_000 }).toBe(true);+ expect(shared.toolsLists).toBe(1);+ expect.soft(personal.seenHeaders.filter((headers) => headers.authorization !== ownAuthorization), "after personal setup").toEqual([]);++ personal.seenHeaders.length = 0;+ rmSync(join(team.home, ".openmausbot", "mcp-app-catalog.json"));+ await team.relaunch();+ await expect.poll(teamHasApps, { timeout: 40_000 }).toBe(true);+ expect(shared.toolsLists).toBe(2);+ expect.soft(personal.seenHeaders, "after restart with a cold app catalog").toEqual([]);+ expect(shared.seenHeaders.every((headers) => headers.authorization === teamAuthorization)).toBe(true);+ } finally {+ await team.as(owner, "DELETE", "/api/mcp/servers/personal_probe");+ await team.as(owner, "DELETE", "/api/mcp/servers/team_probe");+ await personal.close();+ await shared.close();+ }+}, hostTimeout(120_000));diff --git a/server/index.ts b/server/index.tsindex 1eb61ec497..8b363b534b 100644--- a/server/index.ts+++ b/server/index.ts@@ -12518,7 +12518,7 @@ ROUTES.push(createBotMessageRoutes({{ emoji, name: person.name ?? person.email, at: Date.now() }),}));const chatApps = createChatApps({ store, dataDir: DATA_DIR });-const chatAppsMcp = createChatAppsMcp({ store, apps: chatApps, dataDir: DATA_DIR, storedServers: () => cfg.mcpServers ?? {}, mountedServers: engineMcpServers, oauth: mcpOAuth });+const chatAppsMcp = createChatAppsMcp({ store, apps: chatApps, dataDir: DATA_DIR, storedServers: () => cfg.mcpServers ?? {}, mountedServers: engineMcpServers, personMcp: teamConnections.personMcp, oauth: mcpOAuth });ROUTES.push(createChatAppRoutes({ store, apps: chatApps, threadRefusal: cloudThreadRefusal, mcpRpc: chatAppsMcp.rpc }));const { react } = createReactions({store, reply: (input) => personReplies.deliver({ ...input, about: "message" }),