Skip to content

feat: add get_org_team_bookings and get_org_user_bookings MCP tools#103

Draft
joeauyeung wants to merge 2 commits into
mainfrom
devin/1780516114-add-org-booking-tools
Draft

feat: add get_org_team_bookings and get_org_user_bookings MCP tools#103
joeauyeung wants to merge 2 commits into
mainfrom
devin/1780516114-add-org-booking-tools

Conversation

@joeauyeung
Copy link
Copy Markdown
Contributor

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). Requires TEAM_ADMIN role.
  • get_org_user_bookings — lists all bookings for a specific org member (GET /v2/organizations/:orgId/users/:userId/bookings). Requires ORG_ADMIN role.

Both tools share a bookingFiltersSchema / buildBookingQueryParams helper 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_bookings tool additionally exposes teamId/teamsIds filters (meaningful when querying a user's bookings across teams), while get_org_team_bookings omits 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

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-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
cal-companion-mcp Ignored Ignored Jun 4, 2026 12:56am

Request Review

@joeauyeung joeauyeung marked this pull request as ready for review June 5, 2026 02:44
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Contributor

@volnei volnei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit comment, but worth to fix

skip: z.number().int().optional().describe("Results to skip (offset)"),
};

interface BookingFilterParams {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot marked this pull request as draft June 5, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants