Skip to main content
Glama

calendar-list-calendars

Retrieve a list of all available calendars from the MCP server, with configurable results limit for managing calendar data.

Instructions

List all available calendars

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
maxResultsNoMaximum number of calendars to return

Implementation Reference

  • Implementation of the listCalendars tool handler. Fetches calendars from Google Calendar API using calendarList.list, maps the data, formats as Markdown using formatCalendarsToMarkdown, and returns structured content or error.
    export async function listCalendars( params: z.infer<ReturnType<typeof listCalendarsSchema>> ) { try { const auth = createCalendarAuth(); const calendar = google.calendar({ version: "v3", auth }); const response = await calendar.calendarList.list({ maxResults: params.maxResults, }); const calendars = response.data.items?.map((cal) => ({ id: cal.id, summary: cal.summary, description: cal.description, timeZone: cal.timeZone, accessRole: cal.accessRole, primary: cal.primary, backgroundColor: cal.backgroundColor, foregroundColor: cal.foregroundColor, })); return { content: [ { type: "text" as const, text: formatCalendarsToMarkdown(calendars || []), }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: `Error listing calendars: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } }
  • Zod schema defining the input parameters for the calendar-list-calendars tool, including optional maxResults.
    export const listCalendarsSchema = () => z.object({ maxResults: z .number() .min(1) .max(250) .default(10) .describe("Maximum number of calendars to return"), });
  • src/index.ts:260-267 (registration)
    Registration of the 'calendar-list-calendars' tool on the MCP server, linking to listCalendars handler and listCalendarsSchema.
    server.tool( "calendar-list-calendars", "List all available calendars", listCalendarsSchema().shape, async (params) => { return await listCalendars(params); } );
  • Helper function to format the list of calendars into a nicely structured Markdown response used by the listCalendars handler.
    function formatCalendarsToMarkdown(calendars: any[]): string { if (!calendars.length) return "No calendars found."; let markdown = `# Available Calendars (${calendars.length})\n\n`; calendars.forEach((cal, index) => { markdown += `## ${index + 1}. ${cal.summary || cal.id}\n`; markdown += `ID: \`${cal.id}\` \n`; if (cal.description) markdown += `Description: ${cal.description} \n`; if (cal.timeZone) markdown += `Time Zone: ${cal.timeZone} \n`; if (cal.accessRole) markdown += `Access: ${cal.accessRole} \n`; if (cal.primary) markdown += `Primary: Yes ⭐ \n`; markdown += `\n`; }); return markdown; }

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