calcom_add_appointment
Schedule new meetings or appointments in Cal.com calendar by providing event type, time details, and attendee information.
Instructions
Creates a new appointment in Cal.com calendar. Use this for scheduling new meetings or appointments. Requires event type ID, start time, end time, name, email, and optional notes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| eventTypeId | Yes | The Cal.com event type ID | |
| startTime | Yes | Start time in ISO format (YYYY-MM-DDTHH:mm:ss.sssZ) | |
| endTime | Yes | End time in ISO format (YYYY-MM-DDTHH:mm:ss.sssZ) | |
| name | Yes | Attendee's name | |
| Yes | Attendee's email | ||
| notes | No | Optional notes for the appointment |
Implementation Reference
- index.ts:259-293 (handler)The core function that executes the tool logic: validates inputs indirectly via caller, checks rate limit, makes POST request to Cal.com /bookings API to create appointment, and returns success message with details.async function addAppointment( eventTypeId: number, startTime: string, endTime: string, name: string, email: string, notes?: string ) { checkRateLimit(); try { const response = await calComApiClient.post('/bookings', { eventTypeId, start: new Date(startTime).toISOString(), end: new Date(endTime).toISOString(), name, email, notes, }); const booking = response.data; return `Appointment created successfully! Booking ID: ${booking.id} Event Type: ${booking.eventTypeId} Start Time: ${booking.startTime} End Time: ${booking.endTime} Attendee: ${name} (${email}) ${notes ? `Notes: ${notes}` : ""}`; } catch (error: any) { if (axios.isAxiosError(error)) { throw new Error(`Failed to create appointment: ${error.response?.data?.message || error.message}`); } throw new Error(`Failed to create appointment: ${String(error)}`); } }
- index.ts:12-48 (registration)Tool registration: defines name, description, and input schema. This Tool object is returned in listTools and used for dispatching.const ADD_APPOINTMENT_TOOL: Tool = { name: "calcom_add_appointment", description: "Creates a new appointment in Cal.com calendar. " + "Use this for scheduling new meetings or appointments. " + "Requires event type ID, start time, end time, name, email, and optional notes. ", inputSchema: { type: "object", properties: { eventTypeId: { type: "number", description: "The Cal.com event type ID" }, startTime: { type: "string", description: "Start time in ISO format (YYYY-MM-DDTHH:mm:ss.sssZ)" }, endTime: { type: "string", description: "End time in ISO format (YYYY-MM-DDTHH:mm:ss.sssZ)" }, name: { type: "string", description: "Attendee's name" }, email: { type: "string", description: "Attendee's email" }, notes: { type: "string", description: "Optional notes for the appointment", } }, required: ["eventTypeId", "startTime", "endTime", "name", "email"], }, };
- index.ts:204-221 (schema)Runtime schema validator: type guard function to check if arguments match the expected input shape before calling the handler.function isCalComAddAppointmentArgs(args: unknown): args is { eventTypeId: number; startTime: string; endTime: string; name: string; email: string; notes?: string; } { return ( typeof args === "object" && args !== null && "eventTypeId" in args && "startTime" in args && "endTime" in args && "name" in args && "email" in args ); }
- index.ts:397-407 (handler)Dispatch handler in CallToolRequestSchema: matches tool name, validates args using schema guard, calls addAppointment, formats response.case "calcom_add_appointment": { if (!isCalComAddAppointmentArgs(args)) { throw new Error("Invalid arguments for calcom_add_appointment"); } const { eventTypeId, startTime, endTime, name, email, notes } = args; const result = await addAppointment(eventTypeId, startTime, endTime, name, email, notes); return { content: [{ type: "text", text: result }], isError: false, }; }