Skip to content

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

Show MCP servers on the Simple apps page and in the Apps row

aivsomkarfc6a0f601406
diff --git a/src/components/BotSettingsDialog.simple.test.ts b/src/components/BotSettingsDialog.simple.test.ts
index b61556879f..5fcf1a4f7e 100644
--- a/src/components/BotSettingsDialog.simple.test.ts
+++ b/src/components/BotSettingsDialog.simple.test.ts
@@ -7,6 +7,7 @@ import type { MemoryDoc } from "@/lib/memory";
import type { Bot, BotSettingsSection, InstanceInfo } from "@/state/store";
import { AVATAR_FOCUS_CENTER, AVATAR_ZOOM_MIN } from "../../shared/bot-avatar";
import type { ManagedSkill } from "./bot-settings/SkillsSection";
+import type { McpServerSummary } from "@/lib/mcp-servers";
import type { BotApps } from "./bot-settings/useBotApps";
// Hook-by-call-order harness: component state survives between renders, effects never run, and handlers are read off
@@ -42,6 +43,7 @@ const fixture = vi.hoisted(() => {
derived: {} as Record<string, unknown>,
apps: { phase: "ready", apps: [], connectedSlugs: [] } as BotApps,
places: {} as Record<string, [boolean, boolean, string]>,
+ mcp: { servers: null as McpServerSummary[] | null, error: false },
};
});
vi.mock("react", async (original) => ({
@@ -59,6 +61,10 @@ vi.mock("@/lib/interface-mode", () => ({
useAdvancedMode: () => fixture.advanced,
setAdvancedMode: (enabled: boolean) => fixture.setAdvanced(enabled),
}));
+vi.mock("@/lib/mcp-servers", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("@/lib/mcp-servers")>()),
+ useMcpServers: () => ({ ...fixture.mcp, refresh: () => Promise.resolve(fixture.mcp.servers ?? []) }),
+}));
vi.mock("@/lib/use-owner-or-admin", () => ({ useOwnerOrAdmin: () => fixture.ownerOrAdmin }));
vi.mock("@/lib/app-links", async (importOriginal) => ({
...(await importOriginal<typeof import("@/lib/app-links")>()),
@@ -262,6 +268,7 @@ beforeEach(() => {
canUseConnectedApps: true, connectedAppsConfigured: true, connectedAppsEnabled: true, browserEnabled: true,
};
fixture.apps = { phase: "ready", apps: [], connectedSlugs: [] };
+ fixture.mcp = { servers: [], error: false };
fixture.places = {
cloud: [true, true, "Cloud desktop"], vm: [true, true, "Private desktop"], local: [true, true, "Your screen"], browser: [true, true, "Web pages only"],
};
@@ -388,8 +395,8 @@ describe("the bot panel in Simple mode", () => {
expect(sectionTarget("soul")).toMatchObject({ page: "settings", anchor: "instructions" });
});
- // App tool grants (PluginsPanel) and the working folder (the files pane) name a Simple page; MCP and tool
- // selection name none, so they land where Access does.
+ // App tool grants (PluginsPanel) and the working folder (the files pane) name a Simple page; MCP servers live on the
+ // apps page, and tool selection names none, so it lands where Access does.
it.each([["apps", "apps"], ["folder", "folder"], ["mcp", undefined], ["tools", undefined]] as const)("lands an Access link naming %s on %s", (page, landing) => {
try {
openBotSettings(fixture.dispatch, "access", { page });
@@ -757,6 +764,16 @@ describe("the Bot settings page", () => {
expect(rowValue(settingsPage(makeBot()), "apps")).toBe("Gmail, Slack");
});
+ it("lists the MCP servers the bot can use after its apps, and None yet when there are neither", () => {
+ fixture.mcp.servers = [{ name: "dodopayments-remote", enabled: true }, { name: "linear", enabled: true }, { name: "paused", enabled: false }];
+ expect(rowValue(settingsPage(makeBot()), "apps")).toBe("dodopayments-remote, linear");
+ expect(rowValue(settingsPage(makeBot({ mcpServers: ["linear"] })), "apps")).toBe("linear");
+ fixture.apps = { phase: "ready", connectedSlugs: ["gmail"], apps: [app("gmail", "write")] };
+ expect(rowValue(settingsPage(makeBot({ mcpServers: ["linear"] })), "apps")).toBe("Gmail, linear");
+ fixture.apps = { phase: "ready", apps: [], connectedSlugs: [] };
+ expect(rowValue(settingsPage(makeBot({ mcpServers: [] })), "apps")).toBe("None yet");
+ });
+
it("edits the bot's job: saved on blur, Enter leaves the field, Escape puts it back", () => {
const bot = makeBot();
const job = () => find(settingsPage(bot), "data-panel-job");
@@ -999,6 +1016,45 @@ describe("the drill-in pages", () => {
expect(switches(cannot.html)).toBe(0);
});
+ it("lists the MCP servers under the apps with a switch each, that writes the explicit list like Access", () => {
+ fixture.mcp.servers = [{ name: "dodopayments-remote", enabled: true }, { name: "linear", enabled: true }];
+ const rendered = body("apps");
+ expect(rendered.html).toContain("MCP servers");
+ expect(find(rendered, "aria-label", "Scout can use dodopayments-remote").props.checked).toBe(true);
+ click(find(rendered, "aria-label", "Scout can use dodopayments-remote"));
+ expect(patch).toHaveBeenLastCalledWith({ mcpServers: ["linear"] });
+
+ const narrowed = body("apps", makeBot({ mcpServers: ["linear"] }));
+ expect(find(narrowed, "aria-label", "Scout can use dodopayments-remote").props.checked).toBe(false);
+ click(find(narrowed, "aria-label", "Scout can use dodopayments-remote"));
+ expect(patch).toHaveBeenLastCalledWith({ mcpServers: ["linear", "dodopayments-remote"] });
+ });
+
+ it("shows a server that is off everywhere or for this bot as a disabled switch with why, and ignores it while busy", () => {
+ fixture.mcp.servers = [{ name: "paused", enabled: false }, { name: "linear", enabled: true, offFor: ["scout"] }];
+ const rendered = body("apps");
+ expect(find(rendered, "aria-label", "Scout can use paused").props).toMatchObject({ checked: false, disabled: true });
+ expect(rendered.html).toContain("Switched off in Apps");
+ expect(rendered.html).toContain("Off for Scout, because it doesn&#x27;t start for them.");
+ expect(find(rendered, "aria-label", "Scout can use linear").props.disabled).toBe(false);
+
+ const busy = body("apps", makeBot({ busy: true }));
+ expect(find(busy, "aria-label", "Scout can use linear").props.disabled).toBe(true);
+ click(find(busy, "aria-label", "Scout can use linear"));
+ expect(patch).not.toHaveBeenCalled();
+ });
+
+ it("draws no MCP card while loading or when the bot has no server, and says so when the list cannot load", () => {
+ fixture.mcp = { servers: null, error: false };
+ expect(body("apps").html).not.toContain("MCP servers");
+ fixture.mcp = { servers: [{ name: "theirs", enabled: true, bot: "other" }], error: false };
+ expect(body("apps").html).not.toContain("MCP servers");
+ fixture.mcp = { servers: null, error: true };
+ const failed = body("apps");
+ expect(failed.html).toContain("Could not refresh MCP servers.");
+ expect(switches(failed.html)).toBe(0);
+ });
+
it("lists routines with switches, adds one locked to this bot, and says to ask in chat; no logs page, no schedules link", () => {
const morning = routine();
fixture.derived.botRoutines = [morning];
diff --git a/src/components/bot-panel/SettingsPage.tsx b/src/components/bot-panel/SettingsPage.tsx
index f7ec5e6b3d..fea5fb9265 100644
--- a/src/components/bot-panel/SettingsPage.tsx
+++ b/src/components/bot-panel/SettingsPage.tsx
@@ -3,6 +3,7 @@ import { AppWindow, AudioLines, ChevronRight, FileText, ShieldCheck, Tag } from
import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
+import { mcpServersForBot, useMcpServers } from "@/lib/mcp-servers";
import { CALL_MODES, effectiveCallMode, setCallMode, useCallMode, type CallMode } from "@/lib/call-mode";
import { callCapabilityHelp } from "@/lib/call-capability";
import { firstSentence } from "@/lib/soul";
@@ -40,6 +41,7 @@ export function SettingsPage({ bot, derived, onOpen, editingInstructions = false
const { dispatch, flushBotPatches } = useStore();
const { capabilities, ready } = useDesktopCapabilities();
const apps = useBotApps(bot);
+ const { servers: allServers } = useMcpServers();
const approval = useThreadApproval(currentTaskBot(bot));
const storedCallMode = useCallMode();
const [jobDraft, setJobDraft] = useState<string | null>(null);
@@ -76,7 +78,10 @@ export function SettingsPage({ bot, derived, onOpen, editingInstructions = false
}));
const soulOpen = editingInstructions || Boolean(bot.soulDrift);
- const enabledApps = apps.apps.filter((app) => app.scope !== null).map((app) => app.label);
+ const enabledApps = [
+ ...apps.apps.filter((app) => app.scope !== null).map((app) => app.label),
+ ...(allServers ? mcpServersForBot(allServers, bot.mcpServers, bot.id).map((server) => server.name) : []),
+ ];
return (
<div data-panel-settings>
diff --git a/src/components/bot-panel/pages.tsx b/src/components/bot-panel/pages.tsx
index 1a6ddbfaba..56cc22f532 100644
--- a/src/components/bot-panel/pages.tsx
+++ b/src/components/bot-panel/pages.tsx
@@ -1,9 +1,10 @@
import { useState, type ReactNode } from "react";
-import { FolderOpen, Plus } from "lucide-react";
+import { FolderOpen, Plus, Server } from "lucide-react";
import { appSwitchPatch } from "@/lib/bot-app-access";
import { skillsLibraryEnabled } from "@/lib/feature-flags";
import { t } from "@/lib/i18n";
+import { mcpServersForBot, mcpServersOfBot, mcpSwitch, useMcpServers } from "@/lib/mcp-servers";
import { deleteMemoryDoc, MEMORY_INDEX, saveMemoryDoc, type MemoryDoc } from "@/lib/memory";
import { openExternalLink } from "@/lib/app-links";
import type { Routine } from "@/lib/routines";
@@ -23,7 +24,7 @@ import { useOpenComputer, WherePage } from "./ComputerTab";
import { SettingsPage } from "./SettingsPage";
import { panelMemoryNotes, withMemoryNote, withoutMemoryNote, type PanelMemoryNote } from "./memory-notes";
import type { SimplePageId } from "./page-registry";
-import { BotSwitch, buttonCls, Card, LinkRow, NoteRow, RadioRow, rowCls, SwitchRow, TextRow, TrashButton } from "./rows";
+import { BotSwitch, buttonCls, Card, LinkRow, NoteRow, RadioRow, RowIcon, rowCls, RowText, SwitchRow, TextRow, TrashButton } from "./rows";
import { useMemoryDoc } from "./use-memory-doc";
type Derived = ReturnType<typeof useBotSettingsDerived>;
@@ -44,12 +45,19 @@ function errorText(error: unknown, fallback: string): string {
export function AppsPage({ bot, derived }: PageContext) {
const { dispatch } = useStore();
const apps = useBotApps(bot);
+ const { servers: allServers, error: mcpError } = useMcpServers();
const { patch, canUseConnectedApps } = derived;
+ const servers = allServers ? mcpServersOfBot(allServers, bot.id) : [];
+ const mounted = new Set(mcpServersForBot(servers, bot.mcpServers, bot.id).map((server) => server.name));
const toggle = (app: BotApp) => {
const next = appSwitchPatch(bot, apps.connectedSlugs, app.slug, app.scope === null);
if (Object.keys(next).length > 0) patch(next);
};
+ const toggleServer = (name: string) => {
+ if (bot.busy || mcpError) return;
+ patch({ mcpServers: mcpSwitch(servers, bot.mcpServers, name) });
+ };
const note = !canUseConnectedApps
? t("botSettings.simple.appsCannot", { name: bot.name })
: apps.phase === "loading"
@@ -79,6 +87,28 @@ export function AppsPage({ bot, derived }: PageContext) {
</div>
))}
</Card>
+ {(servers.length > 0 || mcpError) && (
+ <Card label={t("connectors.tab.mcp")}>
+ {mcpError && <NoteRow>{t("botAccess.mcpRefreshError")}</NoteRow>}
+ {servers.map((server) => (
+ <div key={server.name} data-simple-mcp={server.name} className={rowCls}>
+ <RowIcon icon={Server} />
+ <RowText
+ title={<span className="block truncate">{server.name}</span>}
+ hint={!server.enabled ? t("botAccess.mcpDisabled") : server.offFor?.includes(bot.id) ? t("mcp.offFor", { bots: bot.name }) : undefined}
+ />
+ <BotSwitch
+ color={bot.color}
+ checked={mounted.has(server.name)}
+ aria-label={t("botSettings.simple.appToggle", { name: bot.name, app: server.name })}
+ disabled={!server.enabled || Boolean(bot.busy) || mcpError}
+ onClick={() => toggleServer(server.name)}
+ className="disabled:cursor-not-allowed"
+ />
+ </div>
+ ))}
+ </Card>
+ )}
<Card>
<LinkRow
data-panel-link="add-app"