create_event
Add a new event to Google Calendar by specifying title, start/end times, location, attendees, and recurrence rules. Integrates with AI assistants using the Google Calendar MCP Server.
Instructions
Create a new event in Google Calendar
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| attendees | No | List of attendees | |
| calendarId | No | Calendar ID (default: 'primary') | primary |
| description | No | Event description | |
| end | Yes | ||
| location | No | Event location | |
| recurrence | No | Recurrence rules (RRULE format) | |
| start | Yes | ||
| summary | Yes | Event title/summary |
Input Schema (JSON Schema)
{
"properties": {
"attendees": {
"description": "List of attendees",
"items": {
"properties": {
"displayName": {
"type": "string"
},
"email": {
"type": "string"
}
},
"required": [
"email"
],
"type": "object"
},
"type": "array"
},
"calendarId": {
"default": "primary",
"description": "Calendar ID (default: 'primary')",
"type": "string"
},
"description": {
"description": "Event description",
"type": "string"
},
"end": {
"properties": {
"dateTime": {
"description": "End date and time (RFC3339 timestamp)",
"type": "string"
},
"timeZone": {
"description": "Time zone (e.g., 'America/New_York')",
"type": "string"
}
},
"required": [
"dateTime"
],
"type": "object"
},
"location": {
"description": "Event location",
"type": "string"
},
"recurrence": {
"description": "Recurrence rules (RRULE format)",
"items": {
"type": "string"
},
"type": "array"
},
"start": {
"properties": {
"dateTime": {
"description": "Start date and time (RFC3339 timestamp)",
"type": "string"
},
"timeZone": {
"description": "Time zone (e.g., 'America/New_York')",
"type": "string"
}
},
"required": [
"dateTime"
],
"type": "object"
},
"summary": {
"description": "Event title/summary",
"type": "string"
}
},
"required": [
"summary",
"start",
"end"
],
"type": "object"
}
Implementation Reference
- src/index.ts:378-421 (handler)The main handler function that implements the create_event tool logic. It constructs an event object from the validated args 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 and validation for the create_event tool.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:151-222 (registration)The tool registration object defining the name, description, and input schema for 'create_event', included in the tools array returned by ListTools.{ 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:538-540 (registration)Registration of the ListTools handler which returns the array of tools including create_event.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
- src/index.ts:551-553 (helper)Dispatch case in the CallToolRequest handler that validates args with the schema and calls the create_event handler.case "create_event": { const validatedArgs = CreateEventArgsSchema.parse(args); return await handleCreateEvent(validatedArgs);