Skip to content

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

MCP: count servers on a lent computer in who else gets a server

Bugfixer 2c62c139786df
diff --git a/server/host/mcp-chat.ts b/server/host/mcp-chat.ts
index bf73bcbe12..365ff89a02 100644
--- a/server/host/mcp-chat.ts
+++ b/server/host/mcp-chat.ts
@@ -44,7 +44,7 @@ export interface McpChatDeps {
publicOrigins(): ReadonlyArray<string | null | undefined>;
threadVisible(auth: RequestAuth, threadId: string): boolean;
/** MCP servers that run on a computer lent here. Built after this module, so read when used. */
- lending?(): Pick<LentMcp, "place" | "principal">;
+ lending?(): Pick<LentMcp, "place" | "principal" | "given">;
}
const mcpServerUrl = (server: object) => ("url" in server && typeof server.url === "string" ? server.url : undefined);
@@ -108,7 +108,11 @@ export function createMcpChat(deps: McpChatDeps) {
decide: (summary, applied) => appendDecision(DATA_DIR, { threadId, botId: sender.id, botName: sender.name, tool: "mcp_server", summary, decision: "auto-approved", source: applied }),
activity: (label, call) => showMcpActivity(store, { threadId, turnId: liveTurnByThread.get(threadId), ...(from ? { from } : {}) }, call, label),
language: () => threadLanguage(threadId),
- usedBy: (name) => store.bots.filter((bot) => bot.id !== sender.id && !bot.hidden && mcpServersHost.given(bot).includes(name) && canUseMcpServer(bot.toolScope, name)).map((bot) => bot.name),
+ usedBy: (name) => {
+ const lent = deps.lending?.();
+ const given = (bot: BotRecord) => mcpServersHost.given(bot).includes(name) || Boolean(lent?.given(bot).includes(name));
+ return store.bots.filter((bot) => bot.id !== sender.id && !bot.hidden && given(bot) && canUseMcpServer(bot.toolScope, name)).map((bot) => bot.name);
+ },
requestApproval: ({ action, name, subtitle, targetHash, fields }) => mcpRequests.propose({ action, name, botId: sender.id, threadId, targetHash }, subtitle, fields, from),
requestSignIn: (name, server) => mcpSignInCards.request({ bot: sender, threadId, ...(from ? { from } : {}) }, name, server),
...lentDeps(sender, threadId, generation),
diff --git a/server/lent-mcp.test.ts b/server/lent-mcp.test.ts
index e6990a9c6a..e0344781cd 100644
--- a/server/lent-mcp.test.ts
+++ b/server/lent-mcp.test.ts
@@ -130,6 +130,7 @@ describe("a server that runs on the person's computer, in a turn", () => {
expect(lent.mounts({ id: "kiwi" }, TURN)).toEqual({});
expect(minted).toEqual([]);
expect(lent.lines({ id: "kiwi" }, TURN).get("local")).toBe("local runs on Ada's Mac. Someone else wrote in this conversation, so it can't use your Mac. Start a new conversation to use it.");
+ expect(lent.given({ id: "kiwi" }).sort(), "still set for the bot, so a change to one reaches it").toEqual(["local", "notes"]);
});
it("only the bot's own servers: off, another bot's, left out of its list or its tool selection are never mounted", () => {
@@ -137,6 +138,7 @@ describe("a server that runs on the person's computer, in a turn", () => {
const bot = { id: "kiwi", mcpServers: ["local", "off", "theirs", "here", "unselected"], toolScope: { deny: ["mcp:unselected:*"] } };
const { lent } = fixture({ servers, online: { terminal: true } });
expect(Object.keys(lent.mounts(bot, TURN))).toEqual(["local"]);
+ expect(lent.given(bot)).toEqual(["local"]);
});
});
diff --git a/server/lent-mcp.ts b/server/lent-mcp.ts
index 052bcd1ee7..722f3b1096 100644
--- a/server/lent-mcp.ts
+++ b/server/lent-mcp.ts
@@ -223,6 +223,9 @@ export function createLentMcp(deps: LentMcpDeps) {
return {
principal: (turn: Turn): string | null => deps.principal(turn),
+ /** The bot's servers that run on another computer, reachable now or not: who a change to one reaches. */
+ given: (bot: Bot): string[] => Object.keys(servers(bot)),
+
/** A turn's servers that run on a lent computer it may use now, as servers at this server's address. One it can't
* reach is left out, and lines() says why. */
mounts(bot: Bot, turn: Turn): Record<string, McpServerSpec> {