Skip to main content
Glama

calendar-list-events

Retrieve calendar events with filters for time range, maximum results, and ordering to manage schedules effectively.

Instructions

List calendar events with optional filters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
calendarIdNoCalendar ID - Available options: 'primary' (Primary Calendar)primary
timeMinNoLower bound for event start time (ISO format)
timeMaxNoUpper bound for event start time (ISO format)
maxResultsNoMaximum number of events to return
singleEventsNoWhether to expand recurring events
orderByNoOrder of eventsstartTime

Implementation Reference

  • The handler function `listEvents` that executes the tool logic: authenticates to Google Calendar API, lists events with filters, formats output as markdown, handles errors.
    // List events function
    export async function listEvents(
      params: z.infer<ReturnType<typeof listEventsSchema>>
    ) {
      try {
        const auth = createCalendarAuth();
        const calendar = google.calendar({ version: "v3", auth });
    
        const listParams: any = {
          calendarId: params.calendarId,
          maxResults: params.maxResults,
          singleEvents: params.singleEvents,
          orderBy: params.orderBy,
        };
    
        if (params.timeMin) listParams.timeMin = params.timeMin;
        if (params.timeMax) listParams.timeMax = params.timeMax;
    
        // If no timeMin is specified, default to current time
        if (!params.timeMin) {
          listParams.timeMin = new Date().toISOString();
        }
    
        const response = await calendar.events.list(listParams);
    
        const events = response.data.items?.map((event) => ({
          id: event.id,
          summary: event.summary,
          description: event.description,
          location: event.location,
          start: event.start,
          end: event.end,
          attendees: event.attendees?.map((a) => ({
            email: a.email,
            responseStatus: a.responseStatus,
          })),
          htmlLink: event.htmlLink,
          status: event.status,
          created: event.created,
          updated: event.updated,
        }));
    
        return {
          content: [
            {
              type: "text" as const,
              text: formatEventListToMarkdown(events || [], events?.length || 0),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error listing events: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
        };
      }
    }
  • Zod schema defining input parameters and descriptions for the calendar-list-events tool.
    export const listEventsSchema = () =>
      z.object({
        calendarId: z
          .string()
          .default("primary")
          .describe(getCalendarDescription()),
        timeMin: z
          .string()
          .optional()
          .describe("Lower bound for event start time (ISO format)"),
        timeMax: z
          .string()
          .optional()
          .describe("Upper bound for event start time (ISO format)"),
        maxResults: z
          .number()
          .min(1)
          .max(250)
          .default(10)
          .describe("Maximum number of events to return"),
        singleEvents: z
          .boolean()
          .default(true)
          .describe("Whether to expand recurring events"),
        orderBy: z
          .enum(["startTime", "updated"])
          .default("startTime")
          .describe("Order of events"),
      });
  • src/index.ts:224-231 (registration)
    MCP server registration of the 'calendar-list-events' tool, linking name, description, schema, and handler.
    server.tool(
      "calendar-list-events",
      "List calendar events with optional filters",
      listEventsSchema().shape,
      async (params) => {
        return await listEvents(params);
      }
    );
  • Helper function to format the list of events into a readable Markdown output used by the handler.
    function formatEventListToMarkdown(events: any[], totalResults: number): string {
      if (!events.length) return "# No Upcoming Events\n\nNo events found in the specified time range.";
      
      let markdown = `# Upcoming Events (${totalResults})\n\n`;
      
      events.forEach((event, index) => {
        const startDate = event.start?.dateTime ? new Date(event.start.dateTime) : null;
        const endDate = event.end?.dateTime ? new Date(event.end.dateTime) : null;
        
        markdown += `## ${index + 1}. ${event.summary || 'Untitled Event'}\n`;
        
        if (startDate) {
          if (endDate && startDate.toDateString() === endDate.toDateString()) {
            // Same day event
            markdown += `When: ${startDate.toLocaleDateString()} ${startDate.toLocaleTimeString()} - ${endDate.toLocaleTimeString()}  \n`;
          } else {
            markdown += `Start: ${startDate.toLocaleString()}  \n`;
            if (endDate) markdown += `End: ${endDate.toLocaleString()}  \n`;
          }
        }
        
        if (event.location) markdown += `Location: ${event.location}  \n`;
        if (event.description) markdown += `Description: ${event.description}  \n`;
        if (event.attendees && event.attendees.length > 0) {
          markdown += `Attendees: ${event.attendees.length} people  \n`;
        }
        if (event.id) markdown += `ID: \`${event.id}\`  \n`;
        
        markdown += `\n---\n\n`;
      });
      
      return markdown;
    }
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 'optional filters' which hints at query capabilities, but doesn't describe pagination behavior, rate limits, authentication requirements, error conditions, or what happens with large result sets. For a list operation with 6 parameters, this leaves significant behavioral aspects undocumented.

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 extremely concise - a single 7-word sentence that efficiently communicates the core functionality. It's front-loaded with the essential information and contains no wasted words or redundant information.

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 list operation with 6 parameters and no output schema, the description is insufficient. It doesn't explain what information events contain, how results are structured, whether there's pagination, or what happens when filters return no results. Without annotations and with no output schema, the description should provide more context about the operation's behavior and results.

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 mentions 'optional filters' which aligns with the schema's filtering parameters (timeMin, timeMax, maxResults, etc.). However, with 100% schema description coverage, the schema already documents all parameters thoroughly. The description adds minimal value beyond what's in the schema - it doesn't explain filter interactions, precedence, or practical usage patterns.

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

Purpose3/5

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

The description 'List calendar events with optional filters' clearly states the verb ('List') and resource ('calendar events'), but it's somewhat vague about scope and doesn't differentiate from sibling tools like 'calendar-get-event' or 'calendar-list-calendars'. It specifies the action but lacks precision about what kind of listing this provides.

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. There are multiple calendar-related siblings (create-event, delete-event, get-event, list-calendars), but the description doesn't indicate this is for listing multiple events with filtering capabilities versus getting a single event or listing calendars.

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

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/CaptainCrouton89/maps-mcp'

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