Skip to main content
Glama

google_calendar_create_event

Add new events to Google Calendar by specifying title, start/end time, location, description, attendees, and recurrence rules using this integration tool.

Instructions

Create a new event in Google Calendar

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
attendeesNoList of email addresses to invite
calendarIdNoOptional: ID of calendar to use (defaults to primary if not specified)
colorIdNoColor identifier (1-11) for the event
descriptionNoDetailed description of the event
endYesEnd time of the event in ISO 8601 format (e.g. 2025-04-02T11:00:00-07:00)
locationNoPhysical location or address
recurrenceNoRFC5545 recurrence rule (e.g., 'RRULE:FREQ=WEEKLY;COUNT=10')
startYesStart time of the event in ISO 8601 format (e.g. 2025-04-02T10:00:00-07:00)
summaryYesThe title/summary of the event

Implementation Reference

  • The main handler function that executes the tool: validates arguments using isCreateEventArgs, destructures parameters, performs additional checks, calls the underlying GoogleCalendar.createEvent method, and returns a formatted response.
    export async function handleCalendarCreateEvent(
      args: any,
      googleCalendarInstance: GoogleCalendar
    ) {
      if (!isCreateEventArgs(args)) {
        throw new Error("Invalid arguments for google_calendar_create_event");
      }
    
      const {
        summary,
        start,
        end,
        calendarId,
        description,
        location,
        colorId,
        attendees,
        recurrence,
      } = args;
    
      if (!summary || !start || !end) throw new Error("Missing required arguments");
    
      const result = await googleCalendarInstance.createEvent(
        summary,
        start,
        end,
        calendarId,
        description,
        location,
        colorId,
        attendees,
        recurrence
      );
    
      return {
        content: [{ type: "text", text: result }],
        isError: false,
      };
    }
  • Input schema definition for the google_calendar_create_event tool, including name, description, properties, and required fields.
    export const CREATE_EVENT_TOOL: Tool = {
      name: "google_calendar_create_event",
      description: "Create a new event in Google Calendar",
      inputSchema: {
        type: "object",
        properties: {
          summary: {
            type: "string",
            description: "The title/summary of the event",
          },
          description: {
            type: "string",
            description: "Detailed description of the event",
          },
          location: {
            type: "string",
            description: "Physical location or address",
          },
          start: {
            type: "string",
            description:
              "Start time of the event in ISO 8601 format (e.g. 2025-04-02T10:00:00-07:00)",
          },
          end: {
            type: "string",
            description:
              "End time of the event in ISO 8601 format (e.g. 2025-04-02T11:00:00-07:00)",
          },
          colorId: {
            type: "string",
            description: "Color identifier (1-11) for the event",
          },
          attendees: {
            type: "array",
            items: { type: "string" },
            description: "List of email addresses to invite",
          },
          recurrence: {
            type: "string",
            description:
              "RFC5545 recurrence rule (e.g., 'RRULE:FREQ=WEEKLY;COUNT=10')",
          },
          calendarId: {
            type: "string",
            description:
              "Optional: ID of calendar to use (defaults to primary if not specified)",
          },
        },
        required: ["summary", "start", "end"],
      },
    };
  • Core implementation in GoogleCalendar class: constructs the event request body from parameters, calls Google Calendar API events.insert, handles optional fields like attendees and recurrence, and returns success message with event ID.
    async createEvent(
      summary: string,
      start: string,
      end: string,
      calendarId?: string,
      description?: string,
      location?: string,
      colorId?: string,
      attendees?: string[],
      recurrence?: string
    ) {
      try {
        const targetCalendarId = calendarId || this.defaultCalendarId;
    
        // Build the request body with required fields
        const requestBody: any = {
          summary,
          start: { dateTime: start },
          end: { dateTime: end },
        };
    
        // Add optional fields if provided
        if (description) requestBody.description = description;
        if (location) requestBody.location = location;
        if (colorId) requestBody.colorId = colorId;
    
        // Format attendees if provided
        if (attendees && attendees.length > 0) {
          requestBody.attendees = attendees.map((email) => ({ email }));
        }
    
        // Add recurrence rule if provided
        if (recurrence) {
          requestBody.recurrence = [recurrence];
        }
    
        const event = await this.calendar.events.insert({
          calendarId: targetCalendarId,
          requestBody,
          sendUpdates: attendees && attendees.length > 0 ? "all" : "none",
        });
    
        return `Event "${summary}" created with ID: ${event.data.id} in calendar: ${targetCalendarId}`;
      } catch (error) {
        throw new Error(
          `Failed to create event: ${
            error instanceof Error ? error.message : String(error)
          }`
        );
      }
    }
  • Type guard function for validating input arguments to the create event handler.
    export function isCreateEventArgs(args: any): args is {
      summary: string;
      start: string;
      end: string;
      calendarId?: string;
      description?: string;
      location?: string;
      colorId?: string;
      attendees?: string[];
      recurrence?: string;
    } {
      return (
        args &&
        typeof args.summary === "string" &&
        typeof args.start === "string" &&
        typeof args.end === "string" &&
        (args.calendarId === undefined || typeof args.calendarId === "string") &&
        (args.description === undefined || typeof args.description === "string") &&
        (args.location === undefined || typeof args.location === "string") &&
        (args.colorId === undefined || typeof args.colorId === "string") &&
        (args.recurrence === undefined || typeof args.recurrence === "string") &&
        (args.attendees === undefined || Array.isArray(args.attendees))
      );
    }
  • tools/index.ts:1-25 (registration)
    Central registration file that aggregates all tools including calendarTools (which contains google_calendar_create_event) into a single tools array for MCP registration.
    import { oauthTools } from "./oauth/index";
    import { calendarTools } from "./calendar/index";
    import { gmailTools } from "./gmail/index";
    import { driveTools } from "./drive/index";
    import { tasksTools } from "./tasks/index";
    
    const tools = [
      // OAuth tools
      ...oauthTools,
    
      // Calendar tools
      ...calendarTools,
    
      // Gmail tools
      ...gmailTools,
    
      // Google Drive tools
      ...driveTools,
    
      // Google Tasks tools
      ...tasksTools,
    ];
    
    export default tools;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vakharwalad23/google-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server