create_event
Add new events to Google Calendar by specifying title, time, location, attendees, and recurrence rules.
Instructions
Create a new event in Google Calendar
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| calendarId | No | Calendar ID (default: 'primary') | primary |
| summary | Yes | Event title/summary | |
| description | No | Event description | |
| start | Yes | ||
| end | Yes | ||
| location | No | Event location | |
| attendees | No | List of attendees | |
| recurrence | No | Recurrence rules (RRULE format) |
Implementation Reference
- src/index.ts:378-421 (handler)The main handler function for the 'create_event' tool. It constructs an event object from the validated arguments and uses the Google Calendar API to insert the new event, returning success or error response.async function handleCreateEvent(args: z.infer<typeof CreateEventArgsSchema>) { try { const event = { summary: args.summary, description: args.description, start: args.start, end: args.end, location: args.location, attendees: args.attendees, recurrence: args.recurrence, }; const response = await calendar.events.insert({ calendarId: args.calendarId, requestBody: event, }); return { content: [ { type: "text", text: JSON.stringify({ success: true, event: response.data, message: `Event "${args.summary}" created successfully`, }, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: error instanceof Error ? error.message : "Unknown error", }, null, 2), }, ], isError: true, }; } }
- src/index.ts:47-65 (schema)Zod schema defining the input parameters for the 'create_event' tool, used for validation before calling the handler.const CreateEventArgsSchema = z.object({ calendarId: z.string().optional().default("primary"), summary: z.string(), description: z.string().optional(), start: z.object({ dateTime: z.string(), timeZone: z.string().optional(), }), end: z.object({ dateTime: z.string(), timeZone: z.string().optional(), }), location: z.string().optional(), attendees: z.array(z.object({ email: z.string(), displayName: z.string().optional(), })).optional(), recurrence: z.array(z.string()).optional(), });
- src/index.ts:152-222 (registration)Tool registration in the tools array, defining the name, description, and input schema for 'create_event' returned by ListToolsRequestHandler.name: "create_event", description: "Create a new event in Google Calendar", inputSchema: { type: "object", properties: { calendarId: { type: "string", description: "Calendar ID (default: 'primary')", default: "primary", }, summary: { type: "string", description: "Event title/summary", }, description: { type: "string", description: "Event description", }, start: { type: "object", properties: { dateTime: { type: "string", description: "Start date and time (RFC3339 timestamp)", }, timeZone: { type: "string", description: "Time zone (e.g., 'America/New_York')", }, }, required: ["dateTime"], }, end: { type: "object", properties: { dateTime: { type: "string", description: "End date and time (RFC3339 timestamp)", }, timeZone: { type: "string", description: "Time zone (e.g., 'America/New_York')", }, }, required: ["dateTime"], }, location: { type: "string", description: "Event location", }, attendees: { type: "array", items: { type: "object", properties: { email: { type: "string" }, displayName: { type: "string" }, }, required: ["email"], }, description: "List of attendees", }, recurrence: { type: "array", items: { type: "string" }, description: "Recurrence rules (RRULE format)", }, }, required: ["summary", "start", "end"], }, },
- src/index.ts:551-554 (registration)Dispatch case in the CallToolRequestHandler switch statement that validates arguments using the schema and calls the handleCreateEvent function.case "create_event": { const validatedArgs = CreateEventArgsSchema.parse(args); return await handleCreateEvent(validatedArgs); }