feat: add get_org_team_bookings and get_org_user_bookings MCP tools#103
feat: add get_org_team_bookings and get_org_user_bookings MCP tools#103joeauyeung wants to merge 2 commits into
Conversation
Two new read-only tools for org-level booking queries: - get_org_team_bookings: list all bookings for a team within an org (TEAM_ADMIN). Endpoint: /v2/organizations/:orgId/teams/:teamId/bookings - get_org_user_bookings: list all bookings for a specific org member (ORG_ADMIN). Endpoint: /v2/organizations/:orgId/users/:userId/bookings Both support the full booking filter set (status, attendeeEmail, attendeeName, eventType, date ranges, sorting, pagination). Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
🤖 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:
|
Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/mcp-server/src/tools/organizations/bookings.ts">
<violation number="1" location="apps/mcp-server/src/tools/organizations/bookings.ts:5">
P2: Substantial duplicate booking-filter logic was added instead of reusing a shared schema/query builder, increasing risk of drift between booking tools.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| import { calApi } from "../../utils/api-client.js"; | ||
| import { handleError, ok } from "../../utils/tool-helpers.js"; | ||
|
|
||
| const bookingFiltersSchema = { |
There was a problem hiding this comment.
P2: Substantial duplicate booking-filter logic was added instead of reusing a shared schema/query builder, increasing risk of drift between booking tools.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/mcp-server/src/tools/organizations/bookings.ts, line 5:
<comment>Substantial duplicate booking-filter logic was added instead of reusing a shared schema/query builder, increasing risk of drift between booking tools.</comment>
<file context>
@@ -0,0 +1,108 @@
+import { calApi } from "../../utils/api-client.js";
+import { handleError, ok } from "../../utils/tool-helpers.js";
+
+const bookingFiltersSchema = {
+ status: z.string().optional().describe("Comma-separated statuses: upcoming, recurring, past, cancelled, unconfirmed"),
+ attendeeEmail: z.string().email().optional().describe("Filter by attendee email"),
</file context>
volnei
left a comment
There was a problem hiding this comment.
Nit comment, but worth to fix
| skip: z.number().int().optional().describe("Results to skip (offset)"), | ||
| }; | ||
|
|
||
| interface BookingFilterParams { |
There was a problem hiding this comment.
Consider deriving this type from the schema instead of maintaining it separately:
const _bookingFiltersZodObject = z.object(bookingFiltersSchema);
type BookingFilterParams = z.infer<typeof _bookingFiltersZodObject>;This eliminates the duplicate and makes omissions impossible.
Summary
Adds two new read-only MCP tools for org-level booking queries:
get_org_team_bookings— lists all bookings for a team within an org (GET /v2/organizations/:orgId/teams/:teamId/bookings). RequiresTEAM_ADMINrole.get_org_user_bookings— lists all bookings for a specific org member (GET /v2/organizations/:orgId/users/:userId/bookings). RequiresORG_ADMINrole.Both tools share a
bookingFiltersSchema/buildBookingQueryParamshelper for the full filter set:status,attendeeEmail,attendeeName,eventTypeId,eventTypeIds, date ranges (afterStart,beforeEnd,afterCreatedAt,beforeCreatedAt,afterUpdatedAt,beforeUpdatedAt), sorting, and pagination.The
get_org_user_bookingstool additionally exposesteamId/teamsIdsfilters (meaningful when querying a user's bookings across teams), whileget_org_team_bookingsomits them (team is in the URL path).Companion PR to https://github.com/calcom/cal/pull/3208 which ensures the API endpoint accepts the full filter set.
Link to Devin session: https://app.devin.ai/sessions/0595f15c3b0c497d9f4ab3b202abfaa9
Requested by: @joeauyeung