Skip to content

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

fix(grok): say where to turn tool selection off when Grok has its own MCP servers

AdityaUmale639a680d684e
diff --git a/server/drivers/acp/acp.test.ts b/server/drivers/acp/acp.test.ts
index b97d061aff..8044bddbe8 100644
--- a/server/drivers/acp/acp.test.ts
+++ b/server/drivers/acp/acp.test.ts
@@ -1450,6 +1450,21 @@ describe("ACP turns (fake CLI)", () => {
});
});
+ it("tells the person where to turn tool selection off when Grok has its own MCP server", async () => {
+ process.env.FAKE_ACP_GROK_NATIVE_MCP = "github";
+ try {
+ await create(GrokAgentDriver);
+ await instance.adapter.sendTurn({ threadId: "t-grok-native-mcp", text: "go", toolScope: { allow: ["native:*"] } });
+ expect(await recorder.until((event) => event.type === "turn.completed")).toMatchObject({ ok: false });
+ expect(recorder.events.find((event) => event.type === "runtime.error")).toMatchObject({
+ message: "Grok has an MCP connection outside the bot's selection. Remove the MCP servers from Grok's own settings, "
+ + "or set Tool selection back to all tools in this bot's settings (Access). No prompt was sent.",
+ });
+ } finally {
+ delete process.env.FAKE_ACP_GROK_NATIVE_MCP;
+ }
+ });
+
it("keeps a tool selection's gate in front of the connector", async () => {
const strict = await startFakeHttpMcp({ strictInitialize: "http-400", tools: [{ name: "report", inputSchema: { type: "object" } }, { name: "campaigns", inputSchema: { type: "object" } }] });
try {
diff --git a/server/drivers/acp/grok.ts b/server/drivers/acp/grok.ts
index a1f41d2460..487f63c5f0 100644
--- a/server/drivers/acp/grok.ts
+++ b/server/drivers/acp/grok.ts
@@ -438,7 +438,8 @@ const support: AcpSupport = {
if (!Array.isArray(catalog?.servers)) throw new Error("Grok could not confirm its MCP catalog. No prompt was sent.");
for (const server of catalog.servers) {
if (server?.session?.enabled === false) continue;
- if (!available.has(server?.name)) throw new Error("Grok has an MCP connection outside the bot's selection. Disable native MCP connections before using tool selection. No prompt was sent.");
+ if (!available.has(server?.name)) throw new Error("Grok has an MCP connection outside the bot's selection. Remove the MCP servers from Grok's own settings, "
+ + "or set Tool selection back to all tools in this bot's settings (Access). No prompt was sent.");
if (Array.isArray(server?.session?.tools) && server.session.tools.some((tool: { name?: unknown }) => typeof tool.name !== "string" || !allowsTool(turn.toolScope, { kind: "mcp", server: server.name, name: tool.name }))) {
throw new Error("Grok could not enforce the selected MCP catalog. No prompt was sent.");
}
diff --git a/server/testing/fake-acp-cli.ts b/server/testing/fake-acp-cli.ts
index 04e5663403..28ecb718d3 100755
--- a/server/testing/fake-acp-cli.ts
+++ b/server/testing/fake-acp-cli.ts
@@ -25,6 +25,7 @@
// grok 1.0.25's initialize, or FAKE_ACP_MCP_HANDSHAKE; FAKE_ACP_MCP_SCHEMA_BYTES=1 adds each schema's length)
// | lend-question (list_shared_computers around a question)
// | list-peers (list_bots through the agents MCP; keeps the first agents server it is offered, like Hermes)
+// FAKE_ACP_GROK_NATIVE_MCP _x.ai/mcp/list also reports these comma-separated native servers, as from Grok's own config
// FAKE_ACP_MCP_TRANSPORTS remote MCP transports advertised in initialize, e.g. "http,sse"
// FAKE_ACP_PERMISSION_OPTIONS JSON options override in permission mode
// FAKE_ACP_DUMP path for {argv, env}; with FAKE_ACP_MODES or FAKE_ACP_MODELS also <dump>.prompts.jsonl
@@ -729,7 +730,8 @@ function handle(msg: any) {
result(msg.id, {});
break;
case "_x.ai/mcp/list":
- result(msg.id, { result: { servers: [], sessionMcpResolved: true } });
+ result(msg.id, { result: { servers: (process.env.FAKE_ACP_GROK_NATIVE_MCP ?? "").split(",").filter(Boolean)
+ .map((name) => ({ name, session: { enabled: true, status: "ready" } })), sessionMcpResolved: true } });
break;
case "session/new": {
if (failRpc(msg)) break;