Skip to main content
Glama

get_calendar_events

Retrieve calendar events from personal or school calendars with date range filtering and predefined period options.

Instructions

Get calendar events with advanced options

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
calendar_typeNoType of calendar to retrieve (personal or school)personal
from_dateNoStart date in YYYY-MM-DD format (optional). If only from_date is provided, it will be treated as a single day.
to_dateNoEnd date in YYYY-MM-DD format (optional). Must be at least 1 day after from_date when both are provided.
periodNoPredefined period (optional, overrides from/to dates). Use "today" for single day queries.

Implementation Reference

  • src/server.ts:261-292 (registration)
    Tool registration and input schema definition for get_calendar_events in the ListToolsRequestSchema handler.
    {
      name: "get_calendar_events",
      description: "Get calendar events with advanced options",
      inputSchema: {
        type: "object",
        properties: {
          calendar_type: {
            type: "string",
            enum: ["personal", "school"],
            description:
              "Type of calendar to retrieve (personal or school)",
            default: "personal",
          },
          from_date: {
            type: "string",
            description:
              "Start date in YYYY-MM-DD format (optional). If only from_date is provided, it will be treated as a single day.",
          },
          to_date: {
            type: "string",
            description:
              "End date in YYYY-MM-DD format (optional). Must be at least 1 day after from_date when both are provided.",
          },
          period: {
            type: "string",
            enum: ["today", "week", "month"],
            description:
              'Predefined period (optional, overrides from/to dates). Use "today" for single day queries.',
          },
        },
      },
    },
  • The core handler logic for executing the get_calendar_events tool. Parses arguments, determines calendar type and date range using helper methods on the API instance, fetches the schedule data, and formats the response.
    case "get_calendar_events":
      try {
        const { calendar_type, from_date, to_date, period } = args as {
          calendar_type?: string;
          from_date?: string;
          to_date?: string;
          period?: string;
        };
    
        // Determine calendar type
        const calendarType =
          calendar_type === "school"
            ? CalendarType.SCHOOL
            : CalendarType.PERSONAL;
    
        // Determine date range
        let dateRange;
        if (period) {
          switch (period) {
            case "today": {
              const today = new Date();
              dateRange = this.api.createSingleDayRange(today);
              break;
            }
            case "week":
              dateRange = this.api.createWeekDateRange();
              break;
            case "month":
              dateRange = this.api.createMonthDateRange();
              break;
            default:
              throw new Error(`Invalid period: ${period}`);
          }
        } else if (from_date && to_date) {
          dateRange = this.api.createDateRange(from_date, to_date);
        } else if (from_date) {
          // Single day range
          dateRange = this.api.createSingleDayRange(from_date);
        }
        // If no date parameters, use default (current week)
    
        const schedule = await this.api.getSchedule(
          calendarType,
          dateRange,
        );
    
        return {
          content: [
            {
              type: "text",
              text: `[DATE] Calendar Events (${calendar_type || "personal"})${
                dateRange
                  ? ` from ${dateRange.from.toDateString()} to ${dateRange.to.toDateString()}`
                  : " (current week)"
              }\n\n${JSON.stringify(schedule, null, 2)}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error: ${error instanceof Error ? error.message : "Unknown error"}\n\nTo authenticate:\n1. Login to N Lobby in your browser\n2. Open Developer Tools (F12)\n3. Go to Application/Storage tab\n4. Copy cookies and use the set_cookies tool\n5. Use health_check to verify connection`,
            },
          ],
        };
      }

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/minagishl/nlobby-mcp'

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