in src/utils/zodToMCPSchema.ts [28:44]
export function zodToMCPShape(schema: z.ZodTypeAny): { result: MCPSchemaShape, keys: string[] } {
if (!isZodObject(schema)) {
throw new Error("MCP tools require an object schema at the top level");
}
const shape = schema.shape;
const result: MCPSchemaShape = {};
for (const [key, value] of Object.entries(shape)) {
result[key] = isZodOptional(value as any) ? (value as any).unwrap() : value;
}
return {
result,
keys: Object.keys(result)
};
}