Skip to content

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

Team setup: check a plan's MCP server names in mcp-registry, not server/index.ts

Bruno824dd03eaba3
diff --git a/server/index.ts b/server/index.ts
index af12db8280..9a857fc699 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -216,7 +216,7 @@ import { decodeGeneratedImage } from "./generated-image.ts";
import { createMcpServersHost } from "./host/mcp-servers-host.ts"; import { createMcpKeys } from "./vault/mcp-keys.ts"; import { createLimitTakeover, signedOutStop } from "./host/limit-takeover.ts";
import {
isRemoteMcpServer,
- mcpServerServes,
+ mcpServerProblemFor,
parseStoredMcpServer,
} from "./mcp-registry.ts";
import { attachCustomMcp } from "./mcp-result-budget.ts"; import { mcpToolProblem } from "./mcp-failure.ts";
@@ -9195,12 +9195,7 @@ const teamSetupRequests = new TeamSetupRequestService({
store, teams: teamSetupTeams, hasTeamAuthority, canPersist: proposalPersistence, maxBots: MAX_WORKSPACE_BOTS,
autoApply: appliesDirectly,
validateChange: (before, fields) => assertTeamComputerChangeIdle(before, { ...before, ...fields }),
- mcpServerProblem: (name, botId) => {
- const server = cfg.mcpServers && Object.hasOwn(cfg.mcpServers, name) ? cfg.mcpServers[name] : undefined;
- if (!server) return "no such server";
- return mcpServerServes(server, botId) ? null : "that server belongs to another bot";
- },
- ownsThread: (botId, threadId) => Boolean(connectorThread(botId, threadId)),
+ mcpServerProblem: (name, botId) => mcpServerProblemFor(cfg.mcpServers, name, botId), ownsThread: (botId, threadId) => Boolean(connectorThread(botId, threadId)),
targetBusy: (botId, sourceThreadId) => {
if (!sourceThreadId) return Boolean(store.bot(botId)?.busy || hasDirectDispatch(botId) || activeGroupTurnForBot(botId) || routines?.activeRunForBot(botId));
const group = activeGroupTurnForBot(botId);
diff --git a/server/mcp-registry.test.ts b/server/mcp-registry.test.ts
index 187ef4da2a..da347f5b0a 100644
--- a/server/mcp-registry.test.ts
+++ b/server/mcp-registry.test.ts
@@ -7,11 +7,23 @@ import {
mcpServerLimitError,
mcpSharedServerRoom,
mcpServerNameError,
+ mcpServerProblemFor,
parseMcpServerMutation,
parseMcpServersImport,
parseStoredMcpServer,
} from "./mcp-registry.ts";
+describe("a team setup plan's MCP server", () => {
+ it("knows only configured names and refuses another bot's own server", () => {
+ const servers = { hindsight: {}, notes: { bot: "clive" } };
+ expect(mcpServerProblemFor(servers, "hindsight", "ada")).toBeNull();
+ expect(mcpServerProblemFor(servers, "notes", "clive")).toBeNull();
+ expect(mcpServerProblemFor(servers, "notes", "ada")).toBe("that server belongs to another bot");
+ expect(mcpServerProblemFor(servers, "constructor", "ada")).toBe("no such server");
+ expect(mcpServerProblemFor(undefined, "hindsight", "ada")).toBe("no such server");
+ });
+});
+
describe("custom MCP registry", () => {
it("parses stdio servers and keeps newly added commands disabled", () => {
expect(parseMcpServerMutation("notes", { command: "npx", args: ["-y", "notes-mcp"] })).toEqual({
diff --git a/server/mcp-registry.ts b/server/mcp-registry.ts
index 8bd965979e..825c2d429f 100644
--- a/server/mcp-registry.ts
+++ b/server/mcp-registry.ts
@@ -82,6 +82,13 @@ export function mcpServerServes(server: object & { bot?: string }, botId: string
return !server.bot || server.bot === botId;
}
+/** Why a team setup plan cannot give this bot the named server, or null when it can. */
+export function mcpServerProblemFor(servers: Record<string, unknown> | undefined, name: string, botId: string): string | null {
+ const server = servers && Object.hasOwn(servers, name) ? servers[name] : undefined;
+ if (!server || typeof server !== "object") return "no such server";
+ return mcpServerServes(server, botId) ? null : "that server belongs to another bot";
+}
+
/** How many MCP servers one bot can use: the shared ones plus its own. */
export const MAX_MCP_SERVERS = 20;
/** How many the whole install can hold, shared and per-bot together. */