Skip to content

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

A saved MCP tool grant answers in every conversation of its bot

milind-soni8e4558847383
diff --git a/docs/approval-levels.md b/docs/approval-levels.md
index 4662697343..c4e9daceca 100644
--- a/docs/approval-levels.md
+++ b/docs/approval-levels.md
@@ -228,7 +228,8 @@ computer), a sandbox change, an action the provider marks as needing explicit
approval, an unconfigured server, or a guest's turn. A remembered apps batch
or workbench call still holds each send inside it for its own approval. A custom MCP server controls its own tool names, so only remember tools
from a server you trust. The grant applies to the bot's current and future
-conversations, including newly delegated work. Saved entries are visible and
+conversations, including newly delegated work and a conversation opened before
+the grant was saved or set back to Ask since. Saved entries are visible and
revocable in the bot's Access settings; removing one there takes it from every
conversation of the bot at once, a running turn included.
diff --git a/server/index.ts b/server/index.ts
index 88a9132f3a..00f883bb4a 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -52,7 +52,7 @@ import { RoomMemberLock } from "./room-member-lock.ts";
import { approvalHeldNote, approvalHeldReason, approvalModeForOrigin, autoVerdict, deliverFullAccessApproval, undeliveredApprovalTool } from "./auto-approve.ts"; import { readsOwnFiles } from "./own-file-reads.ts";
import { bindSafetyFloor, denyAtSafetyFloor, heldAtSafetyFloor, safetyFloorOn } from "./safety-floor-gate.ts";
import { CommandAllowlistStore, commandAllowlistCandidate } from "./command-allowlist.ts";
-import { providerMcpTool, providerToolAllowKey, providerToolConfig } from "./provider-tool-allow.ts";
+import { providerMcpTool, providerToolAllowKey, providerToolConfig, savedToolGrant } from "./provider-tool-allow.ts";
import type { CommandAllowlistCandidate, CommandAllowlistResponse } from "../shared/command-allowlist.ts";
import { claudeAccountInfo } from "./claude-accounts.ts";
import {
@@ -6467,7 +6467,7 @@ bus.subscribe((event: RuntimeEvent) => {
? heldAtSafetyFloor(event, autoVerdict(effectiveApprovalMode, event.tool, {
requiresExplicitApproval: event.requiresExplicitApproval,
commandAllowed: Boolean(command && commandAllowlist.matches(asker.id, command)),
- toolAllowed: Boolean(toolAllowKey && asker.alwaysAllow?.includes(toolAllowKey)), ownFilesRead: !guestDriven && readsOwnFiles(DATA_DIR, asker.id, event), // never in a guest's turn: the folder holds its owner's memory
+ toolAllowed: savedToolGrant(toolAllowKey, asker.alwaysAllow, store.bot(asker.id)?.alwaysAllow), ownFilesRead: !guestDriven && readsOwnFiles(DATA_DIR, asker.id, event), // never in a guest's turn: the folder holds its owner's memory
}))
: null;
// Claude accepts --permission-mode auto for any model but silently starts in Manual where auto is unavailable (Haiku 4.5, Sonnet 4.5, an org that disabled it).
diff --git a/server/provider-tool-allow.test.ts b/server/provider-tool-allow.test.ts
index f56ed3b96f..89d8cb6d75 100644
--- a/server/provider-tool-allow.test.ts
+++ b/server/provider-tool-allow.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
-import { providerMcpTool, providerToolAllowKey, providerToolConfig } from "./provider-tool-allow.ts";
+import { providerMcpTool, providerToolAllowKey, providerToolConfig, savedToolGrant } from "./provider-tool-allow.ts";
describe("provider MCP tool grants", () => {
it("parses the server and exact tool from provider-facing names", () => {
@@ -47,4 +47,24 @@ describe("provider MCP tool grants", () => {
const second = providerToolAllowKey("claude", "mcp__linear__list_issues", { url: "https://two.example/mcp" });
expect(first).not.toBe(second);
});
+
+ it("finds a grant in the thread's list or its bot's, and nothing for a tool with no key", () => {
+ const key = providerToolAllowKey("claude", "mcp__linear__save_issue", { url: "https://linear.example/mcp" })!;
+ expect(savedToolGrant(key, [], [key])).toBe(true);
+ expect(savedToolGrant(key, [key], undefined)).toBe(true);
+ expect(savedToolGrant(key, [], [])).toBe(false);
+ expect(savedToolGrant(key.replace(":save_issue:", ":delete_issue:"), [key], [key])).toBe(false);
+ expect(savedToolGrant(null, [key], [key])).toBe(false);
+ });
+
+ it("keeps a saved grant on the bot when a thread starts with an empty list of its own", async () => {
+ const { Store } = await import("./store.ts");
+ const store = new Store(() => ({ instanceId: "fixture", model: "fixture" }));
+ const bot = store.createBot({ name: "Saved grants fixture" });
+ const key = providerToolAllowKey("fixture", "mcp__composio__COMPOSIO_MULTI_EXECUTE_TOOL", providerToolConfig("composio", {}))!;
+ store.patchBot(bot.id, { alwaysAllow: [key] });
+ const task = store.createTask(bot.id, "Later Ask thread", false, undefined, undefined, "ask");
+ expect(task?.alwaysAllow).toEqual([]);
+ expect(savedToolGrant(key, task?.alwaysAllow, store.bot(bot.id)?.alwaysAllow)).toBe(true);
+ });
});
diff --git a/server/provider-tool-allow.ts b/server/provider-tool-allow.ts
index d925ee8295..1f0f594d3d 100644
--- a/server/provider-tool-allow.ts
+++ b/server/provider-tool-allow.ts
@@ -41,3 +41,10 @@ export function providerToolAllowKey(
const fingerprint = createHash("sha256").update(JSON.stringify(serverConfig)).digest("hex").slice(0, 16);
return `provider-tool:${providerInstanceId}:${parsed.server}:${parsed.tool}:${fingerprint}`;
}
+
+/** Whether `key` is saved for this turn: in the thread's own list, or in its bot's, which Settings → Access shows. A
+ * grant reaches every conversation of the bot, one opened before it was saved and one whose own list was reset alike;
+ * removing it there takes it from both. */
+export function savedToolGrant(key: string | null, ...lists: Array<readonly string[] | undefined>): boolean {
+ return key !== null && lists.some((list) => list?.includes(key) === true);
+}