Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(approvals): read an MCP tool's name past a server name that has underscores
DeryFerd64bdbcdf461d
diff --git a/server/auto-approve.test.ts b/server/auto-approve.test.tsindex e52d982a50..d50185b6c1 100644--- a/server/auto-approve.test.ts+++ b/server/auto-approve.test.ts@@ -219,3 +219,17 @@ describe("delegatedApprovalMode", () => {expect(delegatedApprovalMode({ ...base, senderMode: "auto", recipientDriverKind: "codex" })).toBe("auto");});});++describe("an MCP tool's bare name", () => {+ // Server names routinely carry underscores (mcp__claude_ai_Gmail__send_message), so the prefix has to be+ // read past one, or the grants below never see the tool they are meant to decide about.+ it("is read past a server name that itself has underscores", () => {+ expect(autoVerdict("auto", "mcp__brave__web_search").source).toBe("web-search");+ expect(autoVerdict("auto", "mcp__brave_search__web_search").source).toBe("web-search");+ });++ it("keeps the ask-a-person guard ahead of Full access, whatever the server is called", () => {+ expect(autoVerdict("full", "AskUserQuestion").approve).toBeNull();+ expect(autoVerdict("full", "mcp__my_agent__ask_user").approve).toBeNull();+ });+});diff --git a/server/auto-approve.ts b/server/auto-approve.tsindex 8027fb3ab5..5390aa39af 100644--- a/server/auto-approve.ts+++ b/server/auto-approve.ts@@ -67,8 +67,11 @@ const ASKS_A_PERSON = new Set(["askuserquestion", "ask_user"]);// Approve for me allows these names and nothing wider: a page fetch and every other tool stay a prompt.const WEB_SEARCH = new Set(["websearch", "web_search", "web-search", "search_web"]);+/** The tool's own name without its MCP server prefix. The server segment may itself contain `_`, which the+ * matching below relies on: a request like `mcp__claude_ai_Gmail__send_message` must read as `send_message`, or+ * the grants and the ask-a-person guard never see the tool they are meant to decide about. */function bareToolName(tool: string): string {- return tool.replace(/^mcp__[^_]+__/, "").toLowerCase();+ return tool.replace(/^mcp__.+?__/, "").toLowerCase();}/** The decision log's "which rule": `full-access` and `command-allowlist` are user grants, `web-search` Approve for me's own,