Skip to content

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

MCP: tell the person when a server a bot adds is on for their other bots

Bugfixer 234ce47ecd3f5
diff --git a/server/routes/internal-mcp.test.ts b/server/routes/internal-mcp.test.ts
index 2a3a2644aa..2c3ed667cb 100644
--- a/server/routes/internal-mcp.test.ts
+++ b/server/routes/internal-mcp.test.ts
@@ -248,6 +248,41 @@ describe("internal mcp_server route, Full access", () => {
expect(lines).toEqual(["Added MCP server notes · Turned on · Test: 2 tools"]);
});
+ it("add of a server other bots get too tells the person which bots, and where to switch it off for one", async () => {
+ probeWith({ ok: true, tools: [{ name: "search_notes" }] });
+ const { post, lines } = fixture({ usedBy: { notes: ["Clive", "Mo"] } });
+ const { status, body } = await post({ action: "add", name: "notes", command: "notes-mcp" });
+ expect(status).toBe(201);
+ expect(body.text).toContain("It is on for your other bots too: Clive and Mo. Tell the person that, and that they can switch it off for one bot in that bot's settings, under Apps it can use.");
+ expect(lines).toEqual(["Added MCP server notes · Turned on · Test: 1 tool · Also on for Clive, Mo: switch it off for one in its settings, under Apps it can use"]);
+ });
+
+ it("add of a server no other bot gets says nothing about other bots", async () => {
+ probeWith({ ok: true, tools: [{ name: "search_notes" }] });
+ const { post, lines } = fixture();
+ const { body } = await post({ action: "add", name: "notes", command: "notes-mcp" });
+ expect(body.text).not.toContain("other bots");
+ expect(lines).toEqual(["Added MCP server notes · Turned on · Test: 1 tool"]);
+ });
+
+ it("enable of a server other bots get too tells the person which bots, and where to switch it off for one", async () => {
+ probeWith({ ok: true, tools: [{ name: "search" }] });
+ const { post, lines } = fixture({ servers: { linear: { ...linear, enabled: false } }, usedBy: { linear: ["Clive"] } });
+ const { status, body } = await post({ action: "enable", name: "linear" });
+ expect(status).toBe(200);
+ expect(body.text).toContain("It is on for your other bots too: Clive.");
+ expect(lines).toEqual(["Turned on MCP server linear · Test: 1 tool · Also on for Clive: switch it off for one in its settings, under Apps it can use"]);
+ });
+
+ it("enable of a server that was already on for everyone, joining only this bot's list, says nothing about other bots", async () => {
+ probeWith({ ok: true, tools: [{ name: "search" }] });
+ const { post, lines } = fixture({ servers: { linear }, mcpServers: [], usedBy: { linear: ["Clive"] } });
+ const { status, body } = await post({ action: "enable", name: "linear" });
+ expect(status).toBe(200);
+ expect(body.text).not.toContain("other bots");
+ expect(lines).toEqual(["Turned on MCP server linear · Test: 1 tool"]);
+ });
+
it("add of an OAuth server returns \"needs sign-in\" and tells the bot to call sign_in", async () => {
probeWith({ ok: false, error: probeModule.SIGN_IN_REQUIRED, auth: "required" });
const { post, stored, mcpOAuth, lines } = fixture();
diff --git a/server/routes/internal-mcp.ts b/server/routes/internal-mcp.ts
index ad9336591f..e4ffba37d5 100644
--- a/server/routes/internal-mcp.ts
+++ b/server/routes/internal-mcp.ts
@@ -9,6 +9,7 @@ import { MCP_CONFIG_BUSY, runsElsewhere, type McpConfig, type McpConfigRefusal }
import { MCP_KEY_EXPIRED, type McpApplied, type McpCardAction, type McpUpdateFields } from "../host/mcp-requests.ts";
import type { BotKept, BotMcpServerAdd } from "../mcp-bot-servers.ts";
import { BOT_STRIPPED_KEYS, botChangeLines, botListing, botMayChange, botServerTarget, isSecretRef, mcpOwner, mergeBotUpdate } from "../mcp-bot-rules.ts";
+import { nameList } from "../mcp-health.ts";
import type { McpAuthState, McpOAuthManager } from "../mcp-oauth.ts";
import type { McpProbeResult } from "../mcp-probe.ts";
import { publicMcpUrl, type HostLookup } from "../mcp-public-url.ts";
@@ -236,9 +237,10 @@ async function add(deps: Deps, name: string, fields: Record<string, unknown>, si
}
joinBotList(deps, name);
const outcome = await probe(deps, name, server, signal);
+ const others = sharedWith(deps.usedBy(name));
deps.decide(`Added MCP server ${name} and turned it on`, deps.fullAccess() ? "full-access" : "level");
- say(deps, { action: "add", name }, ["server.mcp.added", { name }], ["server.mcp.on"], outcome.line);
- return { status: 201, text: `Added MCP server ${name} and turned it on. ${outcome.text}${selection(deps, name)}${where} ${WHEN.live.arrive}` };
+ say(deps, { action: "add", name }, ["server.mcp.added", { name }], ["server.mcp.on"], outcome.line, ...others.lines);
+ return { status: 201, text: `Added MCP server ${name} and turned it on. ${outcome.text}${selection(deps, name)}${where}${others.text} ${WHEN.live.arrive}` };
}
/** The update merged onto the saved entry, its secretRefs redeemed but not spent until `commit`. */
@@ -293,9 +295,10 @@ async function enable(deps: Ctx, name: string, server: StoredMcpServer, signal:
if ("error" in on) return refused(on);
joinBotList(deps, name);
const outcome = await probe(deps, name, server, signal);
+ const others = sharedWith(server.enabled ? [] : deps.usedBy(name));
deps.decide(`Turned on MCP server ${name}`, "full-access");
- say(deps, { action: "enable", name }, ["server.mcp.turnedOn", { name }], outcome.line);
- return { status: 200, text: `Turned on MCP server ${name}. ${outcome.text}${selection(deps, name)} ${when(deps).arrive}` };
+ say(deps, { action: "enable", name }, ["server.mcp.turnedOn", { name }], outcome.line, ...others.lines);
+ return { status: 200, text: `Turned on MCP server ${name}. ${outcome.text}${selection(deps, name)}${others.text} ${when(deps).arrive}` };
}
function disable(deps: Deps, name: string): Outcome {
@@ -473,6 +476,14 @@ function selection(deps: Deps, name: string): string {
return deps.canUse(name) ? "" : ` Your tool selection leaves ${name} out. The person can change that in your settings.`;
}
+function sharedWith(others: readonly string[]): { text: string; lines: Line[] } {
+ if (!others.length) return { text: "", lines: [] };
+ return {
+ text: ` It is on for your other bots too: ${nameList(others)}. Tell the person that, and that they can switch it off for one bot in that bot's settings, under Apps it can use.`,
+ lines: [["server.mcp.alsoOn", { names: others.join(", ") }]],
+ };
+}
+
function folderText(deps: Deps, server: StoredMcpServer, moved: ReadonlyArray<{ to: string }>): string {
const elsewhere = server.runsOn ? ` It runs on ${server.runsOn.label}, the person's own computer, and its tools reach you through it while it is online.` : "";
if (isRemoteMcpServer(server)) return elsewhere;
diff --git a/src/locales/de.json b/src/locales/de.json
index 38422f3b53..f051700b24 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -140,6 +140,7 @@
"server.mcp.on": "Eingeschaltet",
"server.mcp.switchedOff": "Ausgeschaltet",
"server.mcp.keysCleared": "Gespeicherte Schlüssel gelöscht",
+ "server.mcp.alsoOn": "Auch an für {names}: für einen Bot in seinen Einstellungen unter „Apps it can use“ ausschalten",
"server.mcp.testTools.one": "Test: {count} Tool",
"server.mcp.testTools.many": "Test: {count} Tools",
"server.mcp.testSignIn": "Test: Anmeldung nötig",
diff --git a/src/locales/en.json b/src/locales/en.json
index df0e4cfd02..d73835a8b6 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -272,6 +272,7 @@
"server.mcp.on": "Turned on",
"server.mcp.switchedOff": "Switched off",
"server.mcp.keysCleared": "Saved keys cleared",
+ "server.mcp.alsoOn": "Also on for {names}: switch it off for one in its settings, under Apps it can use",
"server.mcp.testTools.one": "Test: {count} tool",
"server.mcp.testTools.many": "Test: {count} tools",
"server.mcp.testSignIn": "Test: needs sign-in",