Skip to main content
Glama

calendar_create_event

Create new calendar events on macOS by specifying title, start/end times, and optional details like calendar name and notes.

Instructions

Create new calendar event

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesEvent title/summary
start_datetimeYesStart date and time (YYYY-MM-DD HH:MM format)
end_datetimeYesEnd date and time (YYYY-MM-DD HH:MM format)
calendarNoTarget calendar name (optional, defaults to "Calendar")
notesNoEvent notes/description (optional)

Implementation Reference

  • Handler for 'calendar_create_event' tool. Validates input parameters, parses start and end datetimes from 'YYYY-MM-DD HH:MM' format, constructs and executes an AppleScript command via osascript to create a new event in the specified calendar (default 'Calendar'), sets optional notes, and returns success message or error.
    case 'calendar_create_event':
      try {
        const title = (args?.title as string) || '';
        const startDateTime = (args?.start_datetime as string) || '';
        const endDateTime = (args?.end_datetime as string) || '';
        const calendar = (args?.calendar as string) || 'Calendar';
        const notes = (args?.notes as string) || '';
        
        if (!title || !startDateTime || !endDateTime) {
          return {
            content: [
              {
                type: 'text',
                text: 'Error: title, start_datetime, and end_datetime are required',
              },
            ],
          };
        }
    
        // Helper to parse "YYYY-MM-DD HH:MM" and return components
        const parseDate = (dateStr: string) => {
          const parts = dateStr.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})$/);
          if (!parts) return null;
          return {
            year: parseInt(parts[1]),
            month: parseInt(parts[2]),
            day: parseInt(parts[3]),
            hours: parseInt(parts[4]),
            minutes: parseInt(parts[5])
          };
        };
    
        const start = parseDate(startDateTime);
        const end = parseDate(endDateTime);
    
        if (!start || !end) {
          return {
            content: [
              {
                type: 'text',
                text: 'Error: Dates must be in format YYYY-MM-DD HH:MM',
              },
            ],
          };
        }
        
        const command = `osascript -e 'on run argv
          set calendarName to item 1 of argv
          set eventTitle to item 2 of argv
          set eventNotes to item 3 of argv
          
          -- Parse Start Date Components
          set startYear to (item 4 of argv) as integer
          set startMonth to (item 5 of argv) as integer
          set startDay to (item 6 of argv) as integer
          set startHour to (item 7 of argv) as integer
          set startMinute to (item 8 of argv) as integer
          
          -- Parse End Date Components
          set endYear to (item 9 of argv) as integer
          set endMonth to (item 10 of argv) as integer
          set endDay to (item 11 of argv) as integer
          set endHour to (item 12 of argv) as integer
          set endMinute to (item 13 of argv) as integer
    
          tell application "Calendar"
            set targetCalendar to calendar calendarName
            
            -- Construct Start Date
            set startDate to current date
            set year of startDate to startYear
            set month of startDate to startMonth
            set day of startDate to startDay
            set time of startDate to (startHour * 3600 + startMinute * 60)
            
            -- Construct End Date
            set endDate to current date
            set year of endDate to endYear
            set month of endDate to endMonth
            set day of endDate to endDay
            set time of endDate to (endHour * 3600 + endMinute * 60)
            
            set newEvent to make new event in targetCalendar with properties {summary:eventTitle, start date:startDate, end date:endDate}
            if eventNotes is not "" then
              set description of newEvent to eventNotes
            end if
            return "Event created: " & summary of newEvent & " in calendar: " & title of targetCalendar
          end tell
        end run' -- "${calendar}" "${title}" "${notes}" ${start.year} ${start.month} ${start.day} ${start.hours} ${start.minutes} ${end.year} ${end.month} ${end.day} ${end.hours} ${end.minutes}`;
        
        const { stdout, stderr } = await execAsync(command);
        
        if (stderr.trim()) {
          return {
            content: [
              {
                type: 'text',
                text: `Error creating event: ${stderr.trim()}`,
              },
            ],
          };
        }
        
        return {
          content: [
            {
              type: 'text',
              text: stdout.trim(),
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: 'text',
              text: `Error executing event creation command: ${error.message}`,
            },
          ],
        };
      }
  • Schema definition for the 'calendar_create_event' tool in the ListTools response, specifying input parameters, descriptions, types, and required fields.
    name: 'calendar_create_event',
    description: 'Create new calendar event',
    inputSchema: {
      type: 'object',
      properties: {
        title: {
          type: 'string',
          description: 'Event title/summary',
        },
        start_datetime: {
          type: 'string',
          description: 'Start date and time (YYYY-MM-DD HH:MM format)',
        },
        end_datetime: {
          type: 'string',
          description: 'End date and time (YYYY-MM-DD HH:MM format)',
        },
        calendar: {
          type: 'string',
          description: 'Target calendar name (optional, defaults to "Calendar")',
        },
        notes: {
          type: 'string',
          description: 'Event notes/description (optional)',
        },
      },
      required: ['title', 'start_datetime', 'end_datetime'],
    },
  • src/index.ts:27-256 (registration)
    The tool is registered by including its definition in the tools array returned by the ListToolsRequestHandler.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: 'discover_apps',
            description: 'Discover AppleScript capabilities of a macOS application',
            inputSchema: {
              type: 'object',
              properties: {
                app_name: {
                  type: 'string',
                  description: 'Name of the macOS application to discover',
                },
                method: {
                  type: 'string',
                  description: 'Discovery method: basic, dictionary, properties, system_events, comprehensive',
                },
                destination: {
                  type: 'string',
                  description: 'Directory path to save discovery results',
                },
              },
              required: ['app_name', 'method', 'destination'],
            },
          },
          {
            name: 'finder_get_selection',
            description: 'Get currently selected files/folders in Finder',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'finder_get_current_folder',
            description: 'Get path of currently viewed folder in frontmost Finder window',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'mail_get_accounts',
            description: 'Get list of all Mail account names',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'mail_get_inbox_count',
            description: 'Get unread message count in inbox',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'mail_get_total_inbox_count',
            description: 'Get total message count in inbox',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'contacts_search_people',
            description: 'Search for people by name in Contacts',
            inputSchema: {
              type: 'object',
              properties: {
                search_term: {
                  type: 'string',
                  description: 'Name or part of name to search for',
                },
              },
              required: ['search_term'],
            },
          },
          {
            name: 'contacts_get_person_info',
            description: 'Get detailed information for a specific person',
            inputSchema: {
              type: 'object',
              properties: {
                person_name: {
                  type: 'string',
                  description: 'Full name of the person to get info for',
                },
              },
              required: ['person_name'],
            },
          },
          {
            name: 'reminders_get_lists',
            description: 'Get all reminder lists with reminder counts',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'reminders_get_incomplete_reminders',
            description: 'Get incomplete reminders across all lists',
            inputSchema: {
              type: 'object',
              properties: {
                limit: {
                  type: 'number',
                  description: 'Maximum number of reminders to return (default: 10)',
                },
              },
            },
          },
          {
            name: 'notes_get_folders',
            description: 'Get all note folders with note counts',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'notes_get_recent_notes',
            description: 'Get recently modified notes',
            inputSchema: {
              type: 'object',
              properties: {
                limit: {
                  type: 'number',
                  description: 'Maximum number of notes to return (default: 10)',
                },
              },
            },
          },
          {
            name: 'notes_search_notes',
            description: 'Search notes by title or content',
            inputSchema: {
              type: 'object',
              properties: {
                query: {
                  type: 'string',
                  description: 'Search query for note title or content',
                },
              },
              required: ['query'],
            },
          },
          {
            name: 'notes_create_note',
            description: 'Create new note with title and content',
            inputSchema: {
              type: 'object',
              properties: {
                title: {
                  type: 'string',
                  description: 'Note title',
                },
                content: {
                  type: 'string',
                  description: 'Note content/body',
                },
                folder: {
                  type: 'string',
                  description: 'Target folder name (optional, defaults to "Notes")',
                },
              },
              required: ['title', 'content'],
            },
          },
          {
            name: 'textedit_get_documents',
            description: 'Get list of open TextEdit documents',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'textedit_create_document',
            description: 'Create new TextEdit document with optional content',
            inputSchema: {
              type: 'object',
              properties: {
                content: {
                  type: 'string',
                  description: 'Optional initial content for the document',
                },
              },
            },
          },
          {
            name: 'calendar_get_calendars',
            description: 'Get all calendars with event counts',
            inputSchema: {
              type: 'object',
              properties: {},
            },
          },
          {
            name: 'calendar_create_event',
            description: 'Create new calendar event',
            inputSchema: {
              type: 'object',
              properties: {
                title: {
                  type: 'string',
                  description: 'Event title/summary',
                },
                start_datetime: {
                  type: 'string',
                  description: 'Start date and time (YYYY-MM-DD HH:MM format)',
                },
                end_datetime: {
                  type: 'string',
                  description: 'End date and time (YYYY-MM-DD HH:MM format)',
                },
                calendar: {
                  type: 'string',
                  description: 'Target calendar name (optional, defaults to "Calendar")',
                },
                notes: {
                  type: 'string',
                  description: 'Event notes/description (optional)',
                },
              },
              required: ['title', 'start_datetime', 'end_datetime'],
            },
          },

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/samicokar/mcp-mac'

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