Skip to main content
Glama
erickva

Google Calendar - No deletion

by erickva

meeting_suggestion

Identifies and suggests available meeting slots within the next 30 days based on working hours, meeting length, and specified calendar IDs, excluding bank holidays and weekends.

Instructions

Suggest available meeting slots within the next 30 days

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bankHolidaysNoList of bank holiday dates in YYYY-MM-DD format
calendarIdsNoList of Google Calendar IDs (default: ["primary"])
daysToSearchNoNumber of days to find slots for (default: 3)
meetingLengthMinutesNoMeeting length in minutes (default: 60)
slotsPerDayNoNumber of slots per day to suggest (default: 1)
timezoneNoTimezone for scheduling (default: America/Sao_Paulo)
workingHoursEndNoEnd of working hours (24h format, default: 17)
workingHoursStartNoStart of working hours (24h format, default: 9)

Implementation Reference

  • Primary handler function implementing the meeting_suggestion tool. Queries Google Calendar freebusy API for availability across specified calendars and date range, filters for working hours (excluding weekends and bank holidays), computes free slots using the findFreeSlots helper, and returns suggested meeting times.
    private async handleMeetingSuggestion(args: any) {
      try {
        const meetingLength = args?.meetingLengthMinutes || 60;
        const workStartHour = args?.workingHoursStart || 9;
        const workEndHour = args?.workingHoursEnd || 17;
        const timezone = args?.timezone || 'America/Sao_Paulo';
        const slotsPerDay = args?.slotsPerDay || 1;
        const daysToSearch = args?.daysToSearch || 3;
        const maxDaysToLookAhead = args?.maxDaysToLookAhead || 30; // New parameter with default
        const bankHolidays = args?.bankHolidays || [];
        const calendarIds = args?.calendarIds || ['primary'];
        
        // Corrected timezone-aware logic using Luxon
        const suggestions: any[] = [];
        let daysWithSlotsFound = 0; // Track days with slots
    
        let startDate;
        if (args?.startDate) {
          startDate = DateTime.fromISO(args.startDate, { zone: timezone }).startOf('day');
        } else {
          // Default to tomorrow in the specified timezone
          startDate = DateTime.now().setZone(timezone).plus({ days: 1 }).startOf('day');
        }
    
        const endDate = startDate.plus({ days: maxDaysToLookAhead }).endOf('day');
    
        const busyResponse = await this.calendar.freebusy.query({
          requestBody: {
            timeMin: startDate.toISO(),
            timeMax: endDate.toISO(),
            timeZone: timezone,
            items: calendarIds.map((id: string) => ({ id })),
          },
        });
    
        console.log("##########################################################################\n");
        console.log("##########################################################################\n");
        console.log("##########################################################################\n");
        console.log("Freebusy Response:", JSON.stringify(busyResponse.data, null, 2));
    
        const busySlots = calendarIds.flatMap(
          (id: string) => busyResponse.data.calendars?.[id]?.busy || []
        ).filter((slot: { start?: string; end?: string }): slot is { start: string; end: string } => !!slot.start && !!slot.end);
    
          let dayPointer = startDate; // Luxon DateTime
          while (daysWithSlotsFound < daysToSearch && dayPointer < endDate) {
          const dayOfWeek = dayPointer.weekday;        
          const formattedDate = dayPointer.toISODate();
          if (dayOfWeek < 6 && !bankHolidays.includes(formattedDate)) {
            // Ensure dayPointer is a DateTime object in your timezone
            
            let dayStart = dayPointer.set({ hour: workStartHour, minute: 0, second: 0, millisecond: 0 });
            let dayEnd = dayPointer.set({ hour: workEndHour, minute: 0, second: 0, millisecond: 0 });
    
            // Now explicitly pass native Dates to your findFreeSlots
            const freeSlots = this.findFreeSlots(
              busySlots,
              dayStart.toJSDate(),
              dayEnd.toJSDate(),
              meetingLength
            );
    
    
            console.log("###### Busy slots received####################################################################\n");
            console.log('Busy slots received:', busySlots);
            console.log("###### FREE slots received####################################################################\n");
            console.log('Free slots calculated:', freeSlots);
    
            // Collect up to `slotsPerDay` slots for this day
            let slotsAddedToday = 0;
            for (const slot of freeSlots) {
              if (slotsAddedToday >= slotsPerDay) break;
              suggestions.push({
                start: DateTime.fromJSDate(slot.start).setZone(timezone).toISO(),
                end: DateTime.fromJSDate(slot.end).setZone(timezone).toISO(),
              });
              slotsAddedToday++;
            }
            
            daysWithSlotsFound++;  // counts this day as processed
          }
    
          dayPointer = dayPointer.plus({ days: 1 });
        }
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(suggestions, null, 2),
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: 'text',
              text: `Error suggesting meetings: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema for the meeting_suggestion tool, defining parameters such as calendars, duration, working hours, timezone, number of slots, search duration, and holidays.
    inputSchema: {
      type: 'object',
      properties: {
        calendarIds: { type: 'array', items: { type: 'string' }, description: 'List of Google Calendar IDs (default: ["primary"])',},
        meetingLengthMinutes: { type: 'number', description: 'Meeting length in minutes (default: 60)' },
        workingHoursStart: { type: 'number', description: 'Start of working hours (24h format, default: 9)' },
        workingHoursEnd: { type: 'number', description: 'End of working hours (24h format, default: 17)' },
        timezone: { type: 'string', description: 'Timezone for scheduling (default: America/Sao_Paulo)' },
        slotsPerDay: { type: 'number', description: 'Number of slots per day to suggest (default: 1)' },
        daysToSearch: { type: 'number', description: 'Number of days to find slots for (default: 3)' },
        bankHolidays: { type: 'array', items: { type: 'string' }, description: 'List of bank holiday dates in YYYY-MM-DD format' },
      },
    },
  • src/index.ts:208-224 (registration)
    Registration of the meeting_suggestion tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    {
      name: 'meeting_suggestion',
      description: 'Suggest available meeting slots within the next 30 days',
      inputSchema: {
        type: 'object',
        properties: {
          calendarIds: { type: 'array', items: { type: 'string' }, description: 'List of Google Calendar IDs (default: ["primary"])',},
          meetingLengthMinutes: { type: 'number', description: 'Meeting length in minutes (default: 60)' },
          workingHoursStart: { type: 'number', description: 'Start of working hours (24h format, default: 9)' },
          workingHoursEnd: { type: 'number', description: 'End of working hours (24h format, default: 17)' },
          timezone: { type: 'string', description: 'Timezone for scheduling (default: America/Sao_Paulo)' },
          slotsPerDay: { type: 'number', description: 'Number of slots per day to suggest (default: 1)' },
          daysToSearch: { type: 'number', description: 'Number of days to find slots for (default: 3)' },
          bankHolidays: { type: 'array', items: { type: 'string' }, description: 'List of bank holiday dates in YYYY-MM-DD format' },
        },
      },
    }
  • src/index.ts:242-243 (registration)
    Dispatch case in the CallToolRequestSchema handler that routes calls to the meeting_suggestion tool to its handler function.
    case 'meeting_suggestion':
      return await this.handleMeetingSuggestion(request.params.arguments);
  • Helper function that calculates free time slots within a given workday by identifying gaps between sorted busy periods, ensuring slots are at least the required meeting length.
    private findFreeSlots(
      busySlots: Array<{ start: string; end: string }>,
      dayStart: Date,
      dayEnd: Date,
      meetingLengthMinutes: number
    ): Array<{ start: Date; end: Date }> {
      const freeSlots: Array<{ start: Date; end: Date }> = [];
      let pointer = new Date(dayStart);
    
      // Sort busy slots
      const sortedBusySlots = busySlots
        .filter((slot) => new Date(slot.start) < dayEnd && new Date(slot.end) > dayStart)
        .sort((a, b) => new Date(a.start).getTime() - new Date(b.start).getTime());
    
      for (const busy of sortedBusySlots) {
        const busyStart = new Date(busy.start);
        const busyEnd = new Date(busy.end);
    
        // While loop to add multiple slots before busyStart
        while ((busyStart.getTime() - pointer.getTime()) >= (meetingLengthMinutes * 60000)) {
          freeSlots.push({
            start: new Date(pointer),
            end: new Date(pointer.getTime() + meetingLengthMinutes * 60000),
          });
          pointer.setTime(pointer.getTime() + meetingLengthMinutes * 60000);
        }
    
        // Move pointer to after the busy slot if pointer overlaps busy
        if (pointer < busyEnd) pointer = new Date(busyEnd);
      }
    
      // After last busy slot: fill remaining time until dayEnd
      while ((dayEnd.getTime() - pointer.getTime()) >= (meetingLengthMinutes * 60000)) {
        freeSlots.push({
          start: new Date(pointer),
          end: new Date(pointer.getTime() + meetingLengthMinutes * 60000),
        });
        pointer.setTime(pointer.getTime() + meetingLengthMinutes * 60000);
      }
    
      return freeSlots;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the 30-day constraint but doesn't explain what 'suggest' entails (e.g., how slots are determined, whether it considers existing events, authentication needs, rate limits, or what the output looks like). For a tool with 8 parameters and no annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point with zero wasted words. It's appropriately sized and front-loaded with the core functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 8 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain the suggestion algorithm, how parameters interact, what the return format is, or error conditions. The 30-day mention provides some context but doesn't compensate for the missing behavioral and output information.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description doesn't add any parameter-specific information beyond what's already in the schema (which has 100% coverage). It mentions 'within the next 30 days' which relates to the time scope but doesn't clarify how this interacts with parameters like 'daysToSearch'. Baseline 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Suggest available meeting slots within the next 30 days' - a specific verb ('suggest') and resource ('meeting slots') with a time constraint. However, it doesn't differentiate from sibling tools like 'create_event' or 'list_events' which handle different calendar operations, so it doesn't fully distinguish itself.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'create_event' for scheduling meetings or 'list_events' for viewing existing ones, nor does it specify prerequisites or contextual constraints for slot suggestion.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related 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/erickva/google-workspace-mcp-server-no-calendar-deletetion'

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