fix: correct MCP tool schemas against Cal.com API v2 spec#74
fix: correct MCP tool schemas against Cal.com API v2 spec#74sahitya-chandra merged 1 commit intomainfrom
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
- schedules: availability uses 'days' array not 'day' string (ScheduleAvailabilityInput_2024_06_11) - schedules: override startTime/endTime are required per spec, not optional - event-types: bookingLimitsCount uses day/week/month/year keys (not PER_DAY etc.) - event-types: bookingWindow typed with businessDays/calendarDays/range enum - event-types: destinationCalendar typed with integration + externalId fields - event-types: recurrence description corrects 'count' to 'occurrences' - bookings: allowConflicts/allowBookingOutOfBounds descriptions clarify host-only behavior
7a1ddf4 to
96c8021
Compare
| bookingWindow: z.object({ | ||
| type: z.enum(["businessDays", "calendarDays", "range"]).describe("Window type"), | ||
| value: z.union([z.number(), z.array(z.string())]).describe("Number of days (for businessDays/calendarDays) or date range array ['2030-09-05', '2030-09-09'] (for range)"), | ||
| rolling: z.boolean().optional().describe("If true the window rolls forward keeping 'value' days available. Only for businessDays/calendarDays."), | ||
| }).optional().describe("Limit how far in the future this event can be booked."), |
There was a problem hiding this comment.
🔴 bookingWindow schema rejects { disabled: true }, breaking ability to remove booking window restrictions
The bookingWindow field in both createEventTypeSchema and updateEventTypeSchema was changed from z.record(z.unknown()) (which accepted any object, including { disabled: true }) to a z.object with type and value as required fields. According to the OpenAPI spec (docs/api-reference/v2/openapi.json), bookingWindow accepts a oneOf that includes Disabled_2024_06_14 (i.e. { disabled: true }) to reset/remove a previously configured booking window. With the new strict schema, passing { disabled: true } will fail zod validation because required fields type and value are missing. This is a regression — users can no longer disable booking windows through the MCP tool. The mobile app actively uses this pattern at apps/mobile/components/event-type-detail/utils/buildPartialUpdatePayload.ts:641.
Prompt for agents
The bookingWindow field in both createEventTypeSchema and updateEventTypeSchema now uses z.object with required type and value fields, which makes it impossible to pass { disabled: true } to reset/remove a booking window. The Cal.com API v2 spec uses a oneOf that includes the Disabled_2024_06_14 variant ({ disabled: true }) alongside the BusinessDays/CalendarDays/Range window variants.
To fix this, the zod schema should use z.union (or z.discriminatedUnion) to accept either the current window object OR a disabled object. For example:
bookingWindow: z.union([
z.object({
type: z.enum(["businessDays", "calendarDays", "range"]),
value: z.union([z.number(), z.array(z.string())]),
rolling: z.boolean().optional(),
}),
z.object({ disabled: z.literal(true) }),
]).optional()
This needs to be applied in both createEventTypeSchema (around line 105) and updateEventTypeSchema (around line 220) in apps/mcp-server/src/tools/event-types.ts. The corresponding TypeScript type annotations for the params of createEventType and updateEventType functions should also be updated to include the disabled variant.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Audited all MCP tool schemas against the Cal.com API v2 OpenAPI spec (
calcom/cal) and fixed every confirmed mismatch:schedules.ts
availabilityslots: Changedday(singular string) →days(array of day-name strings) to matchScheduleAvailabilityInput_2024_06_11. This was causing 400 errors on every schedule create/update with availability.overrides: MadestartTimeandendTimerequired (spec:required: ["date", "startTime", "endTime"]). To mark a date unavailable, set both to"00:00".event-types.ts
bookingLimitsCount: Replacedz.record()withPER_DAY/PER_WEEKdescription → typedz.object({ day, week, month, year })matchingBookingLimitsCount_2024_06_14.bookingWindow: Replacedz.record()→ typedz.object({ type: enum["businessDays"|"calendarDays"|"range"], value, rolling })matchingBookingWindow_2024_06_14.destinationCalendar: Replacedz.record()→ typedz.object({ integration, externalId })matchingDestinationCalendar_2024_06_14.recurrencedescription: Corrected example fieldcount→occurrences(matchingRecurrence_2024_06_14).bookings.ts
allowConflicts/allowBookingOutOfBoundsdescriptions: Clarified these are host-only and ignored for non-hosts.Verification
calcom/calsource types (packages/platform/types/)