@devries-cameron20 / t3code-1 / commits / 9504f65989
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): MCP tools no longer advertise non-string enums that Gemini rejects (#37031)

Julius Marminge committed Nov 14, 2026 at 19:30 UTC 9504f65989dca301bb893ebb2e1e1137964663d0
3 files changed +22 -1
apps/server/src/mcp/advertisedJsonSchema.test.ts
+16
@@ -3,6 +3,7 @@ import * as Schema from "effect/Schema";
3 import { Tool } from "effect/ai";
4
5 import { advertisedJsonSchema } from "./advertisedJsonSchema.ts";
6 +import { ThemeToolkit } from "./toolkits/theme/tools.ts";
7
8 it("drops JSON noise, merges tagged unions, and keeps null where it is required", () => {
9 const Every = Schema.Struct({ ms: Schema.Int });
@@ -43,3 +44,18 @@ it("drops JSON noise, merges tagged unions, and keeps null where it is required"
44 required: ["beforeRunId", "every"],
45 });
46 });
47 +
48 +it("advertises only string enum values, which Gemini requires", () => {
49 + const enumValues: Array<unknown> = [];
50 + const collect = (node: unknown): void => {
51 + if (Array.isArray(node)) return node.forEach(collect);
52 + if (typeof node !== "object" || node === null) return;
53 + for (const [key, value] of Object.entries(node)) {
54 + if (key === "enum" && Array.isArray(value)) enumValues.push(...value);
55 + else collect(value);
56 + }
57 + };
58 + collect(advertisedJsonSchema(ThemeToolkit.tools.t3_theme_set));
59 +
60 + expect(enumValues.filter((value) => typeof value !== "string")).toEqual([]);
61 +});
apps/server/src/mcp/advertisedJsonSchema.ts
+5
@@ -21,6 +21,10 @@ const SAFE_INTEGER_BOUNDS: Record<string, number> = {
21 minimum: Number.MIN_SAFE_INTEGER,
22 };
23
24 +// Gemini rejects function declarations whose enums hold anything but strings.
25 +const isNonStringEnum = (key: string, value: Json) =>
26 + key === "enum" && Array.isArray(value) && value.some((item) => typeof item !== "string");
27 +
28 const tagOf = (branch: JsonObject, key: string): Json => {
29 const property = Predicate.isObject(branch.properties) ? branch.properties[key] : undefined;
30 return Predicate.isObject(property) && Array.isArray(property.enum) && property.enum.length === 1
@@ -75,6 +79,7 @@ const compact = (schema: Json, optional: boolean): Json => {
79 for (const [key, value] of Object.entries(schema)) {
80 if (key === "additionalProperties" && value === true) continue;
81 if (SAFE_INTEGER_BOUNDS[key] === value) continue;
82 + if (isNonStringEnum(key, value)) continue;
83 result[key] =
84 key === "properties" && Predicate.isObject(value)
85 ? Object.fromEntries(
apps/server/src/provider/agentContextBudget.json
+1 -1
@@ -1,5 +1,5 @@
1 {
2 "claudeSystemAppendBytes": 5930,
3 "codexAdditionalContextBytes": 7324,
4 - "mcpToolListJsonBytes": 49749
4 + "mcpToolListJsonBytes": 49738
5 }