Skip to content

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

fix(mcp): leave the output limit unset when a gate passes whole payloads

AdityaUmale6e0015560ab1
diff --git a/server/mcp-gate-config.test.ts b/server/mcp-gate-config.test.ts
index 92eb3c727c..618926fd2b 100644
--- a/server/mcp-gate-config.test.ts
+++ b/server/mcp-gate-config.test.ts
@@ -198,4 +198,10 @@ describe("untrimmed bot servers", () => {
expect(limit({}, { docs: remote, whole: remote }, { whole: 0 })).toBeUndefined();
expect(limit({}, { whole: gated, docs: remote }, { whole: 0 })).toBe(String(UNGATED_MCP_OUTPUT_TOKENS));
});
+
+ it("leaves it unset when a gate passes whole payloads through (a budget of 0)", () => {
+ const whole = { ...gated, env: { OMB_GATE_BUDGET: "0" } };
+ expect(limit({}, { whole, docs: remote })).toBeUndefined();
+ expect(limit({}, { docs: remote, whole })).toBeUndefined();
+ });
});
diff --git a/server/mcp-gate-config.ts b/server/mcp-gate-config.ts
index 307a7dc62c..53791ab5b0 100644
--- a/server/mcp-gate-config.ts
+++ b/server/mcp-gate-config.ts
@@ -75,7 +75,13 @@ export function limitUngatedOutput(
let untrimmed = false;
for (const name of owned) {
const server = Object.hasOwn(mounted, name) ? mounted[name] as { env?: Record<string, string> } | undefined : undefined;
- if (!server || server.env?.OMB_GATE_BUDGET) continue;
+ if (!server) continue;
+ // A gate trims on its own budget; one set to 0 passes whole payloads through, so it needs the limit unset too.
+ const gateBudget = server.env?.OMB_GATE_BUDGET;
+ if (gateBudget !== undefined) {
+ if (Number(gateBudget) <= 0) return;
+ continue;
+ }
if (serverResultBudget(name, perServer, env) <= 0) return;
untrimmed = true;
}