Skip to main content
Glama

google_calendar_get_events

Retrieve upcoming Google Calendar events by specifying a limit, calendar ID, time range, search term, or inclusion of deleted events.

Instructions

Retrieve upcoming events from Google Calendar

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
calendarIdNoOptional: ID of calendar to use (defaults to primary if not specified)
limitNoMaximum number of events to return
qNoFree text search term for events
showDeletedNoWhether to include deleted events
timeMaxNoEnd date/time in ISO format
timeMinNoStart date/time in ISO format (defaults to now)

Implementation Reference

  • The main handler function for the google_calendar_get_events tool, which validates arguments and calls the GoogleCalendar instance to retrieve events.
    export async function handleCalendarGetEvents(
      args: any,
      googleCalendarInstance: GoogleCalendar
    ) {
      if (!isGetEventsArgs(args)) {
        throw new Error("Invalid arguments for google_calendar_get_events");
      }
      const { limit, calendarId, timeMin, timeMax, q, showDeleted } = args;
      const result = await googleCalendarInstance.getEvents(
        limit || 10,
        calendarId,
        timeMin,
        timeMax,
        q,
        showDeleted
      );
      return {
        content: [{ type: "text", text: result }],
        isError: false,
      };
    }
  • Tool schema definition for google_calendar_get_events, specifying input parameters and descriptions.
    export const GET_EVENTS_TOOL: Tool = {
      name: "google_calendar_get_events",
      description: "Retrieve upcoming events from Google Calendar",
      inputSchema: {
        type: "object",
        properties: {
          limit: {
            type: "number",
            description: "Maximum number of events to return",
          },
          calendarId: {
            type: "string",
            description:
              "Optional: ID of calendar to use (defaults to primary if not specified)",
          },
          timeMin: {
            type: "string",
            description: "Start date/time in ISO format (defaults to now)",
          },
          timeMax: {
            type: "string",
            description: "End date/time in ISO format",
          },
          q: {
            type: "string",
            description: "Free text search term for events",
          },
          showDeleted: {
            type: "boolean",
            description: "Whether to include deleted events",
          },
        },
      },
    };
  • Registration of the tool in the server switch statement, dispatching to the handler function.
    case "google_calendar_get_events":
      return await calendarHandlers.handleCalendarGetEvents(
        args,
        googleCalendarInstance
      );
  • Type guard function for validating arguments to google_calendar_get_events.
    export function isGetEventsArgs(args: any): args is {
      limit?: number;
      calendarId?: string;
      timeMin?: string;
      timeMax?: string;
      q?: string;
      showDeleted?: boolean;
    } {
      return (
        args &&
        (args.limit === undefined || typeof args.limit === "number") &&
        (args.calendarId === undefined || typeof args.calendarId === "string") &&
        (args.timeMin === undefined || typeof args.timeMin === "string") &&
        (args.timeMax === undefined || typeof args.timeMax === "string") &&
        (args.q === undefined || typeof args.q === "string") &&
        (args.showDeleted === undefined || typeof args.showDeleted === "boolean")
      );
    }

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