Skip to content

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

fix(mcp): mount the person's own MCP servers ahead of composio (#4119)

CI fixtureeb453871372f
diff --git a/server/drivers/antigravity-native-cli.test.ts b/server/drivers/antigravity-native-cli.test.ts
index aa4458ba4c..e082b8ebb1 100644
--- a/server/drivers/antigravity-native-cli.test.ts
+++ b/server/drivers/antigravity-native-cli.test.ts
@@ -502,7 +502,7 @@ describe.skipIf(WINDOWS)("a native CLI set as the engine's own path", () => {
expect(await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId)).toMatchObject({ ok: true });
// Under a schema profile (the native CLI carries the Gemini engine's) the person's stdio server goes through the MCP gate.
const sent = JSON.parse(readFileSync(`${fake.dump}.mcp.json`, "utf8")) as Array<{ name: string; type?: string; url?: string; command?: string; args?: string[]; env?: Array<{ name: string; value: string }> }>;
- expect(sent.map((server) => server.name)).toEqual(["agents", "composio", "browser", "notes"]);
+ expect(sent.map((server) => server.name)).toEqual(["agents", "browser", "notes", "composio"]);
const byName = Object.fromEntries(sent.map((server) => [server.name, server])) as Record<string, { command?: string; args?: string[]; env?: Array<{ name: string; value: string }> }>;
if (own === "url") {
expect(byName.agents).toMatchObject({ type: "http", url: `${harness}/api/internal/mcp-http/agents` });
diff --git a/server/drivers/turn-mcp.test.ts b/server/drivers/turn-mcp.test.ts
index 6aff6f26c9..2b1c346dee 100644
--- a/server/drivers/turn-mcp.test.ts
+++ b/server/drivers/turn-mcp.test.ts
@@ -25,6 +25,12 @@ const turn = (extra: Partial<SendTurnInput> = {}): SendTurnInput => ({
...extra,
} as SendTurnInput);
+const composio = { command: "/usr/local/bin/node", args: ["/app/dist-server/connector-proxy.js"], env: { OMB_CONNECTOR_TOKEN: "apps-capability" } };
+const withApps = (extra: Partial<SendTurnInput> = {}) => {
+ const base = turn(extra);
+ return { ...base, integrations: { ...base.integrations, composio } } as SendTurnInput;
+};
+
describe("OpenMausBot's own MCP servers for an engine that reaches servers by URL", () => {
it("turns each own proxy into this server's endpoint with the same capability, and leaves the person's servers as they are", () => {
const servers = acpMcpServers(turn(), { http: true });
@@ -125,6 +131,37 @@ describe("the MCP servers of a turn whose model takes a limited number of tools"
});
});
+describe("where the connected-apps bridges mount", () => {
+ const env = (server: ReturnType<typeof acpMcpServers>[number]) =>
+ Object.fromEntries(("env" in server ? server.env : []).map(({ name, value }) => [name, value]));
+ const header = (server: ReturnType<typeof acpMcpServers>[number], name: string) =>
+ ("headers" in server ? server.headers : []).find((entry) => entry.name === name)?.value;
+ const agentsTools = agentsToolList(turn().integrations!.agents!.env).listed.length;
+
+ it("mounts the person's own servers ahead of composio and own apps, which come last as the fallback", () => {
+ const base = withApps();
+ const servers = acpMcpServers({ ...base, integrations: { ...base.integrations!, composioOwn: composio } } as SendTurnInput);
+ expect(servers.map((server) => server.name)).toEqual(["agents", "browser", "data", "notes", "composio", "own_apps"]);
+ });
+
+ it("a tool budget keeps the person's own server over the composio pack", () => {
+ const servers = acpMcpServers(withApps(), { http: true, toolBudget: agentsTools + 3 });
+ expect(servers.map((server) => server.name)).toEqual(["agents", "browser", "data", "notes", "composio"]);
+ expect([header(servers[1]!, TOOL_LIMIT_HEADER), header(servers[2]!, TOOL_LIMIT_HEADER)]).toEqual(["1", "1"]);
+ expect(env(servers[3]!)[TOOL_LIMIT_ENV]).toBe("1");
+ expect(env(servers[4]!)[TOOL_LIMIT_ENV]).toBe("0");
+ });
+
+ it("a name collision still keeps the composio bridge over a server of the person's with the same name", () => {
+ const base = turn();
+ const servers = acpMcpServers({ ...base, integrations: { ...base.integrations!, composio,
+ custom: { ...base.integrations!.custom!, composio: { command: "npx", args: ["-y", "my-own-composio"], env: {} } } } } as SendTurnInput);
+ const named = servers.filter((server) => server.name === "composio");
+ expect(named).toHaveLength(1);
+ expect((named[0] as { args: string[] }).args).toEqual(composio.args);
+ });
+});
+
describe("the MCP servers of a turn whose model reads text only", () => {
const env = (server: ReturnType<typeof acpMcpServers>[number]) =>
Object.fromEntries(("env" in server ? server.env : []).map(({ name, value }) => [name, value]));
diff --git a/server/drivers/turn-mcp.ts b/server/drivers/turn-mcp.ts
index 44a298cb86..17fc7e7aa4 100644
--- a/server/drivers/turn-mcp.ts
+++ b/server/drivers/turn-mcp.ts
@@ -31,17 +31,17 @@ export function turnStdioMcpServers(turn: SendTurnInput, options: { schemaProfil
if (server) servers.push({ name, command: server.command, args: server.args, env: server.env ?? {} });
};
add("agents", turn.integrations?.agents);
- add("composio", turn.integrations?.composio);
- add(OWN_APPS_SERVER, turn.integrations?.composioOwn);
add("browser", turn.integrations?.browser);
add("data", turn.integrations?.data);
add("email", turn.integrations?.email);
add("device", turn.integrations?.device);
// Cua connections expose Cua Driver's own MCP server; a cloud turn runs on its boat, so none is mounted.
add("computer", turn.integrations?.localComputer);
- // User servers after the built-ins: a residual name collision keeps the built-in.
+ // The person's own servers before the connected-apps aggregation: an engine lists tools in mount order, so a dedicated
+ // server's tools come ahead of composio's pack, and a tool budget's remainder reaches them first. A residual name
+ // collision still keeps the built-in, the aggregation included.
for (const [name, server] of Object.entries(turn.integrations?.custom ?? {})) {
- if (servers.some((existing) => existing.name === name)) continue;
+ if (servers.some((existing) => existing.name === name) || name === "composio" || name === OWN_APPS_SERVER) continue;
const apps = appMountFor(name, turn);
if (apps && !("url" in server)) observedCommands.set(name, apps);
const stdio = "url" in server ? mcpStdioServer(server, { nodeEnv: { ELECTRON_RUN_AS_NODE: "1" }, ...(apps ? { apps } : {}) })
@@ -51,6 +51,9 @@ export function turnStdioMcpServers(turn: SendTurnInput, options: { schemaProfil
if (!stdio) continue;
servers.push({ name, command: stdio.command, args: stdio.args ?? [], env: stdio.env ?? {} });
}
+ // Composio and own apps after the person's servers: the fallback when no dedicated server covers a call.
+ add("composio", turn.integrations?.composio);
+ add(OWN_APPS_SERVER, turn.integrations?.composioOwn);
const profiled = (server: TurnStdioMcpServer) =>
schemaProfile ? { ...server, env: { ...server.env, [TOOL_SCHEMA_PROFILE_ENV]: schemaProfile } } : server;
const fitted = turn.toolScope === undefined ? servers.map(profiled) : servers.filter((server) => canUseMcpServer(turn.toolScope, server.name)).map((server) => {