Skip to content

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

Saved MCP tool approvals find their tool again on every engine

milind-sonife586cfbb6fd
diff --git a/docs/approval-levels.md b/docs/approval-levels.md
index 2da0e3a59e..4662697343 100644
--- a/docs/approval-levels.md
+++ b/docs/approval-levels.md
@@ -5,7 +5,7 @@ when that provider resumes an existing native thread. You can also change one
while the bot is working (see below). Each level is one of the
provider's own permission modes, passed through. A native tool request that
reaches you is one the provider left for you. OpenMausBot only answers from an
-explicit grant: Full Access, a saved exact command or MCP read-shaped tool,
+explicit grant: Full Access, a saved exact command or MCP tool that sends nothing,
the narrow built-in web-search allowance under Approve for me, or a bot reading
its own files. In Full Access, OMB also applies its own configuration tools
without another approval.
@@ -211,17 +211,22 @@ another server, and a bridge into a VM or a Boat is new each turn) for the
rest of the conversation, in memory until the server restarts. Another bot in
the same room asks again.
-For a read-shaped tool from a configured custom MCP server, the card also
-offers **Always allow**. This is an explicit standing grant for that exact bot,
-provider instance, MCP server, tool name, and current server configuration. A
+For an MCP tool that sends nothing, from a configured custom MCP server or one
+of OpenMausBot's own bridges (apps, browser, data, email, the phone app's
+tools), the card also offers **Always allow**, on Claude, ACP agents and API
+models alike. This is an explicit standing grant for that exact bot,
+provider instance, MCP server, tool name, and current server configuration;
+an own bridge is named, never the token it is started with for one turn. A
different tool still asks; editing the server command, arguments, variables,
URL or headers invalidates the grant. A key kept in the Vault is part of that
configuration by its reference, not its value, so giving the Vault item a new
value keeps the grant, and so does restarting the server. Switching the bot to
Full access leaves its grants saved, unused, for when it goes back to Ask. It
-is not offered for create/update/delete
-tools, computer control, a sandbox change, an unconfigured server, or a guest's
-turn. A custom MCP server controls its own tool names, so only remember tools
+is not offered for a tool that sends a message, posts or moves money, for
+control of a computer or a phone (the computer tools, a USB phone, a shared
+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
revocable in the bot's Access settings; removing one there takes it from every
@@ -243,10 +248,10 @@ mode is unavailable to the session, starts in Manual without an error. On
Claude Code 2.1.266 that is the case for Claude Haiku 4.5 and Sonnet 4.5,
and for any organization that set `disableAutoMode`. In that session the bot
asks before each action unless you have explicitly remembered that exact MCP
-read tool. The Claude driver reads the mode the session actually runs in from
+tool. The Claude driver reads the mode the session actually runs in from
the CLI's `init` frame; when Approve for me was requested and the session runs
Manual, the chat shows one notice per session naming the model. Choose a model
-the reviewer supports, remember the MCP reads you trust, or use Full access to
+the reviewer supports, remember the MCP tools you trust, or use Full access to
stop the prompts.
### Changing a bot's engine
diff --git a/server/auto-approve.ts b/server/auto-approve.ts
index 494979c845..763b4f81fb 100644
--- a/server/auto-approve.ts
+++ b/server/auto-approve.ts
@@ -1,6 +1,6 @@
// Nothing here decides whether an action is safe: each level is the provider's own permission mode passed through, and a
// request reaching this process is one the provider left for a person. The app's own grants are Full access, the person's
-// exact saved commands and remembered MCP read tools, Approve for me's web search, and a bot's plain reads of its own files
+// exact saved commands and remembered MCP tools that send nothing, Approve for me's web search, and a bot's plain reads of its own files
// at every level (own-file-reads.ts). A bot's question always reaches a human.
import { supportsApprovalMode, type ApprovalMode } from "../shared/approval-mode.ts";
@@ -98,7 +98,7 @@ export function autoVerdict(
requiresExplicitApproval?: boolean;
/** Exact bot/provider/folder/command match against the person's saved rules. */
commandAllowed?: boolean;
- /** Exact provider/server/tool/config match against a person's saved MCP read grant. */
+ /** Exact provider/server/tool/config match against a person's saved MCP tool grant. */
toolAllowed?: boolean;
/** The request only reads the bot's own files: its SOUL.md, skills, memory and conversation folders. */
ownFilesRead?: boolean;
diff --git a/server/drivers/acp/acp.test.ts b/server/drivers/acp/acp.test.ts
index efaf3de621..d676bdecff 100644
--- a/server/drivers/acp/acp.test.ts
+++ b/server/drivers/acp/acp.test.ts
@@ -1612,6 +1612,31 @@ describe("ACP turns (fake CLI)", () => {
expect(done).toMatchObject({ ok: true });
});
+ it.each(["mcp__brain-project__recall", "mcp__composio__gmail_search_emails"])("preserves MCP identity on ACP permission requests: %s", async (name) => {
+ process.env.FAKE_ACP_PERMISSION_TOOL_CALL = JSON.stringify({ kind: "other", title: name, rawInput: {} });
+ await create(GrokAgentDriver, "permission");
+ await instance.adapter.sendTurn({ threadId: "t-mcp-identity", text: "go", cwd: scratch });
+ const opened = await recorder.until((event) => event.type === "request.opened");
+ expect(opened).toMatchObject({ tool: name, requestType: "permission" });
+ expect(opened).toHaveProperty("command", undefined);
+ await instance.adapter.respondToRequest("t-mcp-identity", opened.requestId!, { behavior: "deny" });
+ await recorder.until((event) => event.type === "turn.completed");
+ });
+
+ it.each([
+ { kind: "execute", title: "mcp__browser__navigate;[email protected]$IFS//x.example" },
+ { kind: "edit", title: "mcp__browser__navigate" },
+ { kind: "other", title: "mcp__browser__navigate (with a note)" },
+ ])("never takes a title that only looks like an MCP name as one: $kind $title", async (toolCall) => {
+ process.env.FAKE_ACP_PERMISSION_TOOL_CALL = JSON.stringify({ ...toolCall, rawInput: {} });
+ await create(GrokAgentDriver, "permission");
+ await instance.adapter.sendTurn({ threadId: "t-mcp-lookalike", text: "go", cwd: scratch });
+ const opened = await recorder.until((event) => event.type === "request.opened");
+ expect(opened.type === "request.opened" && opened.tool.startsWith("mcp__")).toBe(false);
+ await instance.adapter.respondToRequest("t-mcp-lookalike", opened.requestId!, { behavior: "deny" });
+ await recorder.until((event) => event.type === "turn.completed");
+ });
+
it.each([
{ name: "full raw command", toolCall: { kind: "execute", rawInput: { command: `printf ' ${"complete input ".repeat(30)}'\n pwd ` } }, descriptor: true },
{ name: "title without raw input", toolCall: { kind: "execute", title: "echo display only" }, descriptor: false },
diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.ts
index db1745539c..8c02a60a55 100644
--- a/server/drivers/acp/core.ts
+++ b/server/drivers/acp/core.ts
@@ -703,7 +703,8 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>
return send({ jsonrpc: "2.0", id: msg.id, result: { outcome: { outcome: "selected", optionId: allow } } });
}
}
- const tool = kind === "execute" ? "shell" : kind === "edit" ? "edit" : kind || "tool";
+ const mcpTitle = !isQuestion && !/^(?:execute|edit|delete|move)$/.test(kind) && typeof toolCall.title === "string" && /^mcp__[\w-]+__[\w.-]+$/.test(toolCall.title) ? toolCall.title : undefined; // an MCP call keeps its name, so a saved grant finds it
+ const tool = mcpTitle ?? (kind === "execute" ? "shell" : kind === "edit" ? "edit" : kind || "tool");
const isShellCommand = !isQuestion && kind === "execute" && !/^mcp(?:__|[.:])/i.test(String(toolCall.title ?? ""));
const rawSummary = String(toolCall.rawInput?.command ?? toolCall.title ?? tool);
const summary = rawSummary.slice(0, isQuestion ? MAX_QUESTION_TEXT : 200);
@@ -771,8 +772,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>
emit({ ...base(threadId, current.turnId), type: "runtime.error", message: DENY_TIMEOUT_NOTE });
finish("deny", "timeout");
}, 15 * 60_000);
- timer.unref?.();
- current.asks.set(requestId, finish);
+ timer.unref?.(); current.asks.set(requestId, finish);
emit({
...base(threadId, current.turnId),
type: "request.opened",
diff --git a/server/drivers/chat-mcp-tools.test.ts b/server/drivers/chat-mcp-tools.test.ts
index 97ac634da6..be5eef32a9 100644
--- a/server/drivers/chat-mcp-tools.test.ts
+++ b/server/drivers/chat-mcp-tools.test.ts
@@ -863,8 +863,8 @@ describe("Chat MCP approvals by server", () => {
sessions.push(session);
expect(session.definitions.map((tool) => tool.function.name).sort()).toEqual(["agents_write", "audit_write", "computer_write"]);
expect(session.view("agents_write", { value: "x" })).toEqual({ title: "agents_write", input: { value: "x" }, ask: false });
- expect(session.view("audit_write", { value: "x" })).toEqual({ title: "audit_write", input: { value: "x" }, ask: true, grant: grantFor("audit", "write") });
- expect(session.view("computer_write", { value: "x" })).toEqual({ title: "computer_write", input: { value: "x" }, ask: true });
+ expect(session.view("audit_write", { value: "x" })).toEqual({ title: "audit_write", permissionTool: "mcp__audit__write", input: { value: "x" }, ask: true, grant: grantFor("audit", "write") });
+ expect(session.view("computer_write", { value: "x" })).toEqual({ title: "computer_write", permissionTool: "mcp__computer__write", input: { value: "x" }, ask: true });
});
it("ties an allow to the server as launched: the same server keeps it, a changed one under the same name does not", async () => {
@@ -911,7 +911,7 @@ describe("Chat MCP tool directory", () => {
expect(JSON.parse(search.text).matches[0].name).toBe("payments_list");
expect(session.view("whop_search_tools", { query: "list payments" })).toEqual({ title: "whop_search_tools", input: { query: "list payments" }, ask: false });
const args = { name: "payments_list", arguments: { company_id: "biz_1" } };
- expect(session.view("whop_call_tool", args)).toEqual({ title: "whop_payments_list", input: { company_id: "biz_1" }, ask: true, grant: grantFor("whop", "payments_list") });
+ expect(session.view("whop_call_tool", args)).toEqual({ title: "whop_payments_list", permissionTool: "mcp__whop__payments_list", input: { company_id: "biz_1" }, ask: true, grant: grantFor("whop", "payments_list") });
await expect(session.execute("whop_call_tool", args, controller.signal)).resolves.toMatchObject({ ok: true, text: "remote execution recorded" });
expect(remote.calls).toEqual([{ name: "payments_list", arguments: { company_id: "biz_1" } }]);
const nameless = await session.execute("whop_call_tool", { arguments: {} }, controller.signal);
@@ -948,7 +948,7 @@ describe("Chat MCP tool directory", () => {
const session = await mountChatTools({ custom: { whop: { type: "http", url: remote.url, headers: {} } } }, controller.signal);
sessions.push(session);
expect(session.definitions.map((tool) => tool.function.name)).toEqual(whopLikeCatalog(5).map((tool) => `whop_${tool.name.replace("-", "_")}`));
- expect(session.view("whop_payments_list", { company_id: "biz_1" })).toEqual({ title: "whop_payments_list", input: { company_id: "biz_1" }, ask: true, grant: grantFor("whop", "payments_list") });
+ expect(session.view("whop_payments_list", { company_id: "biz_1" })).toEqual({ title: "whop_payments_list", permissionTool: "mcp__whop__payments_list", input: { company_id: "biz_1" }, ask: true, grant: grantFor("whop", "payments_list") });
} finally { await remote.close(); }
});
});
@@ -1086,7 +1086,7 @@ describe("Chat MCP servers past the tool limit", () => {
await expect(session.execute("mcp_describe_tool", { name: "audit_write" }, signal)).resolves.toMatchObject({ ok: true, text: expect.stringContaining('"required":["value"]') });
const call = { name: "audit_write", arguments: { value: "through search" } };
- expect(session.view("mcp_call_tool", call)).toEqual({ title: "audit_write", input: { value: "through search" }, ask: true, grant: grantFor("audit", "write") });
+ expect(session.view("mcp_call_tool", call)).toEqual({ title: "audit_write", permissionTool: "mcp__audit__write", input: { value: "through search" }, ask: true, grant: grantFor("audit", "write") });
const misfit = { name: "audit_write", arguments: { value: 7 } };
expect(session.view("mcp_call_tool", misfit).ask).toBe(false);
const refused = await session.execute("mcp_call_tool", misfit, signal);
diff --git a/server/drivers/chat-mcp-tools.ts b/server/drivers/chat-mcp-tools.ts
index fad86db025..d317a087e5 100644
--- a/server/drivers/chat-mcp-tools.ts
+++ b/server/drivers/chat-mcp-tools.ts
@@ -41,7 +41,7 @@ export interface ChatToolDefinition {
export interface ChatToolResult { text: string; ok: boolean; images?: ChatImagePart[] }
/** How a call is shown and granted. A grant names the exact tool on the server as launched; the
* person's own computer never gets a session-wide one. */
-export interface ChatToolCallView { title: string; input: Record<string, unknown>; ask: boolean; grant?: string }
+export interface ChatToolCallView { title: string; /** mcp__<server>__<tool>: the name a saved grant knows it by. */ permissionTool?: string; input: Record<string, unknown>; ask: boolean; grant?: string }
/** A dispatched operation may already have taken effect: never retry it through a new round. */
export class ChatToolSessionError extends Error {}
export interface SkippedChatMcpServer { server: string; reason: string }
@@ -840,9 +840,9 @@ export async function mountChatTools(integrations: SendTurnInput["integrations"]
const viewOf = (tool: RegisteredTool, args: Record<string, unknown>, title: string): ChatToolCallView => {
const runs = target(tool, args);
if (runs === undefined || tool.agents) return { title, input: args, ask: false };
- const grant = !tool.hostComputer ? JSON.stringify([tool.server, tool.launch, runs]) : undefined;
- if (!tool.searched || tool.name !== CALL_TOOL) return { title, input: args, ask: true, ...(grant ? { grant } : {}) };
- return { title: chatToolName(tool.server, runs), input: object(args.arguments) ? args.arguments : {}, ask: true, ...(grant ? { grant } : {}) };
+ const grant = !tool.hostComputer ? JSON.stringify([tool.server, tool.launch, runs]) : undefined, permissionTool = `mcp__${tool.server}__${runs}`;
+ if (!tool.searched || tool.name !== CALL_TOOL) return { title, permissionTool, input: args, ask: true, ...(grant ? { grant } : {}) };
+ return { title: chatToolName(tool.server, runs), permissionTool, input: object(args.arguments) ? args.arguments : {}, ask: true, ...(grant ? { grant } : {}) };
};
const view = (name: string, args: Record<string, unknown>): ChatToolCallView => {
if (name === standIn?.definition.function.name) return { title: name, input: args, ask: false };
diff --git a/server/drivers/openai-chat-safety-floor.test.ts b/server/drivers/openai-chat-safety-floor.test.ts
index 6c89f3b5e0..61ea2cf333 100644
--- a/server/drivers/openai-chat-safety-floor.test.ts
+++ b/server/drivers/openai-chat-safety-floor.test.ts
@@ -195,7 +195,7 @@ describe("the safety floor in the chat runtime", () => {
const f = await fixture([WIPE]);
await f.start({ approvalMode: "ask" });
const card = await f.recorder.until((event) => event.type === "request.opened");
- expect(card).toMatchObject({ requestType: "permission", tool: "shell_exec" });
+ expect(card).toMatchObject({ requestType: "permission", tool: "mcp__shell__exec" });
expect(f.handed()).toEqual([]);
expect(await f.instance.adapter.respondToRequest(f.threadId, card.requestId!, { behavior: "allow" })).toBe("allowed-once");
expect(await f.completed()).toMatchObject({ ok: true });
@@ -209,7 +209,7 @@ describe("the safety floor in the chat runtime", () => {
const f = await fixture(["ls", WIPE, "pwd"]);
await f.start({ approvalMode: "ask" });
const card = await f.recorder.until((event) => event.type === "request.opened");
- expect(card).toMatchObject({ tool: "shell_exec", allowSession: true });
+ expect(card).toMatchObject({ tool: "mcp__shell__exec", allowSession: true });
await f.instance.adapter.respondToRequest(f.threadId, card.requestId!, { behavior: "allow", always: true });
await f.completed();
// one card for the whole turn: the grant covered the rest, except the wipe
diff --git a/server/drivers/openai-chat-tools.test.ts b/server/drivers/openai-chat-tools.test.ts
index 9b85ffd88f..501ec37d3d 100644
--- a/server/drivers/openai-chat-tools.test.ts
+++ b/server/drivers/openai-chat-tools.test.ts
@@ -370,7 +370,7 @@ describe("a searched MCP catalog", () => {
});
await f.start({ integrations: { custom: { whop: { type: "http", url: remote.url, headers: {} } } } });
const opened = await f.recorder.until((event) => event.type === "request.opened");
- expect(opened).toMatchObject({ requestType: "permission", tool: "whop_payments_list", summary: expect.stringContaining("biz_1") });
+ expect(opened).toMatchObject({ requestType: "permission", tool: "mcp__whop__payments_list", summary: expect.stringContaining("biz_1") });
expect(remote.calls).toEqual([]);
await f.instance.adapter.respondToRequest(f.threadId, opened.requestId!, { behavior: "allow" });
expect(await f.completed()).toMatchObject({ ok: true });
@@ -397,7 +397,7 @@ describe("approvals that follow the other engines", () => {
await settledServer("audit");
auditReady.resolve();
const opened = await f.recorder.until((event) => event.type === "request.opened");
- expect(opened).toMatchObject({ requestType: "permission", tool: "audit_write" });
+ expect(opened).toMatchObject({ requestType: "permission", tool: "mcp__audit__write" });
expect(f.requests[1].tools?.map((tool) => tool.function.name)).toContain("audit_write");
expect(f.effects()).toEqual([{ name: "peer", value: "sent" }]);
await f.instance.adapter.respondToRequest(f.threadId, opened.requestId!, { behavior: "allow" });
@@ -421,7 +421,7 @@ describe("approvals that follow the other engines", () => {
const opened = () => f.recorder.events.filter((event) => event.type === "request.opened");
await f.start();
const first = await f.recorder.until((event) => event.type === "request.opened");
- expect(first).toMatchObject({ tool: "audit_write", allowSession: true });
+ expect(first).toMatchObject({ tool: "mcp__audit__write", allowSession: true });
expect(await f.instance.adapter.respondToRequest(f.threadId, first.requestId!, { behavior: "allow", always: true })).toBe("allowed-once");
expect(await f.completed()).toMatchObject({ ok: true });
expect(opened()).toHaveLength(1);
@@ -430,7 +430,7 @@ describe("approvals that follow the other engines", () => {
f.recorder.events.splice(0);
await f.start();
const other = await f.recorder.until((event) => event.type === "request.opened");
- expect(other).toMatchObject({ tool: "audit_fail", allowSession: true });
+ expect(other).toMatchObject({ tool: "mcp__audit__fail", allowSession: true });
expect(f.effects().map((effect) => effect.name)).toEqual(["one", "two", "three"]);
await f.instance.adapter.respondToRequest(f.threadId, other.requestId!, { behavior: "deny" });
await f.completed();
@@ -438,10 +438,10 @@ describe("approvals that follow the other engines", () => {
f.recorder.events.splice(0);
await f.start({ guestConfined: true });
const guest = await f.recorder.until((event) => event.type === "request.opened");
- expect(guest).toMatchObject({ tool: "audit_write", allowSession: false });
+ expect(guest).toMatchObject({ tool: "mcp__audit__write", allowSession: false });
expect(await f.instance.adapter.respondToRequest(f.threadId, guest.requestId!, { behavior: "allow", always: true })).toBe("allowed-once");
const again = await f.recorder.until((event) => event.type === "request.opened" && event.requestId !== guest.requestId);
- expect(again).toMatchObject({ tool: "audit_write", allowSession: false });
+ expect(again).toMatchObject({ tool: "mcp__audit__write", allowSession: false });
await f.instance.adapter.respondToRequest(f.threadId, again.requestId!, { behavior: "deny" });
await f.completed();
expect(f.effects().map((effect) => effect.name)).toEqual(["one", "two", "three", "guest"]);
@@ -449,7 +449,7 @@ describe("approvals that follow the other engines", () => {
f.recorder.events.splice(0);
await f.instance.adapter.sendTurn({ threadId: randomUUID(), text: "Store it here too.", model: "fixture-model", integrations: f.integrations });
const elsewhere = await f.recorder.until((event) => event.type === "request.opened");
- expect(elsewhere).toMatchObject({ tool: "audit_write" });
+ expect(elsewhere).toMatchObject({ tool: "mcp__audit__write" });
await f.instance.adapter.respondToRequest(elsewhere.threadId, elsewhere.requestId!, { behavior: "deny" });
await f.completed();
expect(f.effects().map((effect) => effect.name)).toEqual(["one", "two", "three", "guest"]);
@@ -479,7 +479,7 @@ describe("whose allow \"Always allow this session\" keeps", () => {
f.recorder.events.splice(0);
await f.start({ botId: "clive" });
const roommate = await f.recorder.until((event) => event.type === "request.opened");
- expect(roommate).toMatchObject({ tool: "audit_write", allowSession: true });
+ expect(roommate).toMatchObject({ tool: "mcp__audit__write", allowSession: true });
await f.instance.adapter.respondToRequest(f.threadId, roommate.requestId!, { behavior: "deny" });
await f.completed();
@@ -493,7 +493,7 @@ describe("whose allow \"Always allow this session\" keeps", () => {
f.recorder.events.splice(0);
await f.start({ botId: "mira", integrations: { custom: { audit: { ...audit, env: { ...audit.env, AUDIT_PROFILE: "other" } } } } });
const changed = await f.recorder.until((event) => event.type === "request.opened");
- expect(changed).toMatchObject({ tool: "audit_write", allowSession: true });
+ expect(changed).toMatchObject({ tool: "mcp__audit__write", allowSession: true });
await f.instance.adapter.respondToRequest(f.threadId, changed.requestId!, { behavior: "deny" });
await f.completed();
expect(f.effects().map((effect) => effect.name)).toEqual(["mira", "mira2"]);
diff --git a/server/drivers/openai-chat.ts b/server/drivers/openai-chat.ts
index f1b8218230..6aef286429 100644
--- a/server/drivers/openai-chat.ts
+++ b/server/drivers/openai-chat.ts
@@ -839,7 +839,7 @@ export function createOpenAIChatRuntime<Config>(options: RuntimeOptions<Config>)
const full = (turn.approvalModeNow?.() ?? turn.approvalMode) === "full";
const floored = approval.floored({ full, threadId: turn.threadId, botId: turn.botId, shown, summary: shownPreview });
const allowed = !floored && (full || !shown.ask
- || await approval.ask(shown.title, shownPreview ?? "This tool has no arguments.", shown.grant));
+ || await approval.ask(shown.permissionTool ?? shown.title, shownPreview ?? "This tool has no arguments.", shown.grant));
abort.signal.throwIfAborted();
emit({ ...base(turn.threadId, turnId), type: "item.started", itemType: "tool", itemId: call.id,
title: shown.title, ...(shownPreview ? { input: shownPreview } : {}),
diff --git a/server/index.test.ts b/server/index.test.ts
index 9d430157b1..0e39eb4fb3 100644
--- a/server/index.test.ts
+++ b/server/index.test.ts
@@ -9239,7 +9239,7 @@ describe("harness HTTP API", () => {
await api("PUT", "/api/config", { rooms: { turnTimeoutMinutes: 5 } });
});
- it("cards asks when Claude's reviewer never started and remembers an exact configured MCP read", async () => {
+ it("cards asks when Claude's reviewer never started and remembers exact non-send MCP tools", async () => {
// Haiku 4.5: the CLI takes `auto` but runs Manual and asks about everything.
const bot = (await api("POST", "/api/bots", { name: "Quill" })).body.bot;
const conns: Socket[] = [];
@@ -9334,10 +9334,26 @@ describe("harness HTTP API", () => {
const linearWrite = raise("ask-linear-create", "create KAT issue", { team: "KAT" }, "mcp__linear__create_issue");
await expect.poll(async () => (await messages()).find((m) => m.card?.subtitle === "create KAT issue")?.card?.title).toBe("Approval needed");
const writeCard = (await messages()).find((m) => m.card?.subtitle === "create KAT issue")!.card!;
- expect(writeCard.allowKey).toBeUndefined();
+ expect(writeCard.allowKey).toMatch(/^provider-tool:claude:linear:create_issue:/);
expect((await api("POST", `/api/bots/${bot.id}/respond`, { requestId: writeCard.requestId, behavior: "deny" })).status).toBe(200);
await expect(linearWrite).resolves.toMatchObject({ behavior: "deny" });
+ const batchTool = "mcp__composio__COMPOSIO_MULTI_EXECUTE_TOOL";
+ const firstBatch = raise("ask-batch-1", "read mail batch", { tools: [{ tool_slug: "GMAIL_FETCH_EMAILS", arguments: {} }] }, batchTool);
+ await expect.poll(async () => (await messages()).find(m => m.card?.subtitle === "read mail batch")?.card?.allowKey).toBeTruthy();
+ const batchCard = (await messages()).find(m => m.card?.subtitle === "read mail batch")!.card!;
+ expect((await api("POST", `/api/bots/${bot.id}/always-allow`, { threadId: bot.threadId, allowKey: batchCard.allowKey })).status).toBe(200);
+ expect((await api("POST", `/api/bots/${bot.id}/respond`, { requestId: batchCard.requestId, behavior: "allow" })).status).toBe(200);
+ await expect(firstBatch).resolves.toMatchObject({ behavior: "allow" });
+ await expect(raise("ask-batch-2", "read mail batch again", {}, batchTool)).resolves.toMatchObject({ behavior: "allow" });
+ expect((await messages()).some(m => m.card?.subtitle === "read mail batch again")).toBe(false);
+ const send = raise("ask-send-after-grant", "send mail still asks", {}, "mcp__composio__GMAIL_SEND_EMAIL");
+ await expect.poll(async () => (await messages()).find(m => m.card?.subtitle === "send mail still asks")?.card).toBeTruthy();
+ const sendCard = (await messages()).find(m => m.card?.subtitle === "send mail still asks")!.card!;
+ expect(sendCard.allowKey).toBeUndefined();
+ expect((await api("POST", `/api/bots/${bot.id}/respond`, { requestId: sendCard.requestId, behavior: "deny" })).status).toBe(200);
+ await expect(send).resolves.toMatchObject({ behavior: "deny" });
+
const widen = raise("ask-widen", "ls /", { dangerouslyDisableSandbox: true });
await expect.poll(async () => (await messages()).find((m) => m.card?.subtitle === "ls /")?.card?.title).toBe("Approval needed");
const widenCard = (await messages()).find((m) => m.card?.subtitle === "ls /")!.card!;
diff --git a/server/index.ts b/server/index.ts
index 2785c558d7..88a9132f3a 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 } from "./provider-tool-allow.ts";
+import { providerMcpTool, providerToolAllowKey, providerToolConfig } from "./provider-tool-allow.ts";
import type { CommandAllowlistCandidate, CommandAllowlistResponse } from "../shared/command-allowlist.ts";
import { claudeAccountInfo } from "./claude-accounts.ts";
import {
@@ -6438,7 +6438,7 @@ bus.subscribe((event: RuntimeEvent) => {
case "request.opened": {
// A structured ask is a question whatever channel carried it, and no approval mode answers a question for the person (at Full access one nobody is there for is not asked).
const permission = event.requestType === "permission" && !event.questions?.length;
- // The provider's own mode already ran; only Full access, an exact saved command or an exact remembered MCP read tool answers here.
+ // The provider's own mode already ran; only Full access, an exact saved command or an exact remembered MCP tool that sends nothing answers here.
const asker = bot ?? (speaker ? store.bot(speaker.botId) : undefined);
if (asker && proactive.fence.answers(event, asker, pushMessage)) break;
const unattended = permission && asker && event.requestId ? isUnattended(asker.id, event.threadId) : false;
@@ -6454,12 +6454,12 @@ bus.subscribe((event: RuntimeEvent) => {
const command = permission && asker && event.requestId && !event.requiresExplicitApproval && event.command && !guestDriven
? commandAllowlistCandidate({ ...event.command, providerInstanceId: event.providerInstanceId ?? asker.modelSelection.instanceId })
: null;
- // Bound to provider and server config, so a switch or edit invalidates the grant; built-in or spoofed server names never get a durable key.
+ // Bound to provider and server config, so a switch or edit invalidates the grant; a built-in bridge is named, never its turn token, and a local-computer ask is never remembered.
const providerInstanceId = asker ? event.providerInstanceId ?? asker.modelSelection.instanceId : "";
- const providerTool = permission && asker && event.requestId && !event.requiresExplicitApproval && !guestDriven
+ const providerTool = permission && asker && event.requestId && !event.requiresExplicitApproval && !guestDriven && event.approvalScope !== "local-computer"
? providerMcpTool(event.tool)
: null;
- const configuredMcp = providerTool && asker ? engineMcpServers(asker)[providerTool.server] : undefined;
+ const configuredMcp = providerTool && asker ? providerToolConfig(providerTool.server, engineMcpServers(asker)) : undefined;
const toolAllowKey = configuredMcp === undefined
? null
: providerToolAllowKey(providerInstanceId, event.tool, configuredMcp);
diff --git a/server/provider-tool-allow.test.ts b/server/provider-tool-allow.test.ts
index 0069c14685..f56ed3b96f 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 } from "./provider-tool-allow.ts";
+import { providerMcpTool, providerToolAllowKey, providerToolConfig } from "./provider-tool-allow.ts";
describe("provider MCP tool grants", () => {
it("parses the server and exact tool from provider-facing names", () => {
@@ -10,13 +10,36 @@ describe("provider MCP tool grants", () => {
expect(providerMcpTool("mcp____list_issues")).toBeNull();
});
- it("creates durable keys only for exact read tools", () => {
+ it("creates durable keys for exact tools that send nothing and drive no computer or phone", () => {
const config = { type: "http", url: "https://linear.example/mcp", headers: { Authorization: "secret" } };
expect(providerToolAllowKey("claude", "mcp__linear__list_issues", config))
.toMatch(/^provider-tool:claude:linear:list_issues:[a-f0-9]{16}$/);
- expect(providerToolAllowKey("claude", "mcp__linear__save_issue", config)).toBeNull();
+ expect(providerToolAllowKey("claude", "mcp__linear__save_issue", config)).toMatch(/^provider-tool:claude:linear:save_issue:[a-f0-9]{16}$/);
+ expect(providerToolAllowKey("claude", "mcp__gmail__send_email", config)).toBeNull();
+ expect(providerToolAllowKey("claude", "mcp__linear__create_comment", config)).toBeNull();
+ expect(providerToolAllowKey("claude", "mcp__telnyx__invoke_api_endpoint", config)).toBeNull();
expect(providerToolAllowKey("claude", "mcp__computer__click", config)).toBeNull();
+ expect(providerToolAllowKey("claude", "mcp__phone__tap", { builtin: "phone" })).toBeNull();
+ expect(providerToolAllowKey("codex", "mcp__openmausbot_phone__tap_text", config)).toBeNull();
+ expect(providerToolAllowKey("claude", "mcp__agents__shared_computer", { builtin: "agents" })).toBeNull();
+ expect(providerToolAllowKey("claude", "mcp__agents__list_bots", { builtin: "agents" })).toMatch(/^provider-tool:claude:agents:list_bots:/);
expect(providerToolAllowKey("", "mcp__linear__list_issues", config)).toBeNull();
+ expect(providerToolAllowKey("claude", "mcp__linear__list_issues", undefined)).toBeNull();
+ });
+
+ it("names a built-in bridge, never its turn token, and nothing for a server neither configured nor built in", () => {
+ expect(providerToolConfig("composio", {})).toEqual({ builtin: "composio" });
+ expect(providerToolConfig("own_apps", {})).toEqual({ builtin: "own_apps" });
+ expect(providerToolConfig("phone", {})).toBeUndefined();
+ expect(providerToolConfig("computer", {})).toBeUndefined();
+ expect(providerToolConfig("unmounted", {})).toBeUndefined();
+ const linear = { url: "https://linear.example/mcp" };
+ expect(providerToolConfig("linear", { linear })).toBe(linear);
+ const tool = "mcp__composio__COMPOSIO_MULTI_EXECUTE_TOOL";
+ const first = providerToolAllowKey("kimi", tool, providerToolConfig("composio", {}));
+ expect(first).toMatch(/^provider-tool:kimi:composio:COMPOSIO_MULTI_EXECUTE_TOOL:/);
+ expect(providerToolAllowKey("kimi", tool, providerToolConfig("composio", {}))).toBe(first);
+ expect(providerToolAllowKey("kimi", "mcp__composio__GMAIL_SEND_EMAIL", providerToolConfig("composio", {}))).toBeNull();
});
it("invalidates a key when the configured server changes", () => {
diff --git a/server/provider-tool-allow.ts b/server/provider-tool-allow.ts
index 8457c85c3c..d925ee8295 100644
--- a/server/provider-tool-allow.ts
+++ b/server/provider-tool-allow.ts
@@ -1,7 +1,20 @@
// The grant key binds approval to the instance, the exact MCP server/tool and that server's config, so editing the server invalidates it.
import { createHash } from "node:crypto";
-import { isReadOnlyTool } from "../shared/outbound.ts";
+import { isOutboundTool } from "../shared/outbound.ts";
+
+/** The app's own bridges: their launch carries a token for one turn, so a grant names the bridge instead. */
+const BUILTIN_SERVERS: ReadonlySet<string> = new Set(["composio", "own_apps", "agents", "browser", "data", "device", "email", "dweb"]);
+/** Tools that drive a computer or a phone: each use is asked, never remembered. */
+const CONTROLS_A_DEVICE: ReadonlySet<string> = new Set(["computer", "phone", "openmausbot_phone"]);
+const CONTROL_TOOLS: ReadonlySet<string> = new Set(["agents:shared_computer"]);
+
+/** What a grant on `server` is tied to: the server as configured, a built-in bridge by its name, or nothing for a server
+ * neither configured nor built in. */
+export function providerToolConfig(server: string, configured: Record<string, unknown>): unknown {
+ if (Object.hasOwn(configured, server)) return configured[server];
+ return BUILTIN_SERVERS.has(server) ? { builtin: server } : undefined;
+}
export interface ProviderMcpTool {
server: string;
@@ -16,13 +29,15 @@ export function providerMcpTool(name: string): ProviderMcpTool | null {
return { server: parts[1], tool: parts.slice(2).join("__") };
}
+/** A durable key for any exact tool that sends nothing and drives no computer or phone; null for everything else. */
export function providerToolAllowKey(
providerInstanceId: string,
name: string,
serverConfig: unknown,
): string | null {
const parsed = providerMcpTool(name);
- if (!parsed || !providerInstanceId || !isReadOnlyTool(name)) return null;
+ if (!parsed || !providerInstanceId || serverConfig === undefined || isOutboundTool(name)) return null;
+ if (CONTROLS_A_DEVICE.has(parsed.server) || CONTROL_TOOLS.has(`${parsed.server}:${parsed.tool}`)) return null;
const fingerprint = createHash("sha256").update(JSON.stringify(serverConfig)).digest("hex").slice(0, 16);
return `provider-tool:${providerInstanceId}:${parsed.server}:${parsed.tool}:${fingerprint}`;
}