Skip to main content
Glama

Google Calendar MCP

import { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; import { OAuth2Client } from "google-auth-library"; import { CreateEventInput } from "../../tools/registry.js"; import { BaseToolHandler } from "./BaseToolHandler.js"; import { calendar_v3 } from 'googleapis'; import { formatEventWithDetails } from "../utils.js"; import { createTimeObject } from "../utils/datetime.js"; export class CreateEventHandler extends BaseToolHandler { async runTool(args: any, oauth2Client: OAuth2Client): Promise<CallToolResult> { const validArgs = args as CreateEventInput; const event = await this.createEvent(oauth2Client, validArgs); const eventDetails = formatEventWithDetails(event, validArgs.calendarId); const text = `Event created successfully!\n\n${eventDetails}`; return { content: [{ type: "text", text: text }] }; } private async createEvent( client: OAuth2Client, args: CreateEventInput ): Promise<calendar_v3.Schema$Event> { try { const calendar = this.getCalendar(client); // Use provided timezone or calendar's default timezone const timezone = args.timeZone || await this.getCalendarTimezone(client, args.calendarId); const requestBody: calendar_v3.Schema$Event = { summary: args.summary, description: args.description, start: createTimeObject(args.start, timezone), end: createTimeObject(args.end, timezone), attendees: args.attendees, location: args.location, colorId: args.colorId, reminders: args.reminders, recurrence: args.recurrence, }; const response = await calendar.events.insert({ calendarId: args.calendarId, requestBody: requestBody, }); if (!response.data) throw new Error('Failed to create event, no data returned'); return response.data; } catch (error) { throw this.handleGoogleApiError(error); } } }

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/nspady/google-calendar-mcp'

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