Skip to content

Commit 5469993

Browse files
committed
fix: add boolean union type support for FastMCP optional booleans
1 parent bcba0dc commit 5469993

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

client/src/utils/schemaUtils.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ export function normalizeUnionType(schema: JsonSchemaType): JsonSchemaType {
160160
return { ...schema, type: "string", anyOf: undefined };
161161
}
162162

163+
// Handle anyOf with boolean and null (FastMCP pattern)
164+
if (
165+
schema.anyOf &&
166+
schema.anyOf.some((t) => (t as JsonSchemaType).type === "boolean") &&
167+
schema.anyOf.some((t) => (t as JsonSchemaType).type === "null")
168+
) {
169+
return { ...schema, type: "boolean", anyOf: undefined };
170+
}
171+
163172
// Handle array type with string and null
164173
if (
165174
Array.isArray(schema.type) &&
@@ -169,6 +178,15 @@ export function normalizeUnionType(schema: JsonSchemaType): JsonSchemaType {
169178
return { ...schema, type: "string" };
170179
}
171180

181+
// Handle array type with boolean and null
182+
if (
183+
Array.isArray(schema.type) &&
184+
schema.type.includes("boolean") &&
185+
schema.type.includes("null")
186+
) {
187+
return { ...schema, type: "boolean" };
188+
}
189+
172190
return schema;
173191
}
174192

0 commit comments

Comments
 (0)