Skip to main content
Glama

create-batch-events

Add multiple events to macOS Calendar at once by specifying titles, dates, and optional details for each entry.

Instructions

批量创建事件

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
eventsYes事件列表
calendarNo目标日历工作

Implementation Reference

  • Main handler function that processes batch of events, formats dates using helper methods, generates and executes AppleScript for each event creation in the macOS Calendar app, collects results, and returns formatted success/failure summary.
    async createBatchEvents(args) { const { events, calendar = '工作' } = args; const results = []; let successCount = 0; let failCount = 0; for (const event of events) { try { const startInfo = this.formatDateForAppleScript(event.startDate); const endInfo = this.formatDateForAppleScript(event.endDate); const startTimeScript = this.generateTimeScript(startInfo, 'startTime'); const endTimeScript = this.generateTimeScript(endInfo, 'endTime'); const script = ` tell application "Calendar" set theCalendar to calendar "${calendar}" ${startTimeScript} ${endTimeScript} make new event at end of events of theCalendar with properties {summary:"${event.title}", start date:startTime, end date:endTime, description:"${event.description || ''}", location:"${event.location || ''}"} end tell `; execSync(`osascript -e '${script}'`, { encoding: 'utf8' }); results.push(`✅ ${event.title} - ${event.startDate}`); successCount++; } catch (error) { results.push(`❌ ${event.title} - 失败: ${error.message}`); failCount++; } } return { content: [ { type: 'text', text: `📊 批量创建结果:\n成功: ${successCount}个\n失败: ${failCount}个\n\n详细结果:\n${results.join('\n')}`, }, ], }; }
  • Input schema definition for the create-batch-events tool, specifying array of events with required title, startDate, endDate, optional description/location, and optional calendar.
    { name: 'create-batch-events', description: '批量创建事件', inputSchema: { type: 'object', properties: { events: { type: 'array', items: { type: 'object', properties: { title: { type: 'string' }, startDate: { type: 'string' }, endDate: { type: 'string' }, description: { type: 'string', default: '' }, location: { type: 'string', default: '' }, }, required: ['title', 'startDate', 'endDate'], }, description: '事件列表', }, calendar: { type: 'string', description: '目标日历', default: '工作', }, }, required: ['events'], additionalProperties: false, },
  • Handler function for batch event creation, loops through events, formats dates, executes AppleScript via osascript for each, tracks success/failures, returns summary.
    createBatchEvents(args) { const { events, calendar = "工作" } = args; const results = []; let successCount = 0; let failCount = 0; for (const event of events) { try { const formattedStart = this.formatDateForAppleScript(event.startDate); const formattedEnd = this.formatDateForAppleScript(event.endDate); const script = ` tell application "Calendar" set theCalendar to calendar "${calendar}" set startDate to date "${formattedStart}" set endDate to date "${formattedEnd}" make new event at end of events of theCalendar with properties {summary:"${event.title}", start date:startDate, end date:endDate, description:"${event.description || ''}", location:"${event.location || ''}"} end tell `; execSync(`osascript -e '${script}'`, { encoding: 'utf8' }); results.push(`✅ ${event.title} - ${event.startDate}`); successCount++; } catch (error) { results.push(`❌ ${event.title} - 失败: ${error.message}`); failCount++; } } return { content: [{ type: "text", text: `📊 批量创建结果:\n成功: ${successCount}个\n失败: ${failCount}个\n\n详细结果:\n${results.join('\n')}` }] }; }
  • Tool schema defining input for create-batch-events: required events array (each with title, startDate, endDate), optional calendar.
    name: "create-batch-events", description: "批量创建事件", inputSchema: { type: "object", properties: { events: { type: "array", items: { type: "object", properties: { title: { type: "string" }, startDate: { type: "string" }, endDate: { type: "string" }, description: { type: "string", default: "" }, location: { type: "string", default: "" } }, required: ["title", "startDate", "endDate"] }, description: "事件列表" }, calendar: { type: "string", description: "目标日历", default: "工作" } }, required: ["events"], additionalProperties: false }
  • Tool dispatch switch statement in CallToolRequestSchema handler that routes 'create-batch-events' to its handler function.
    switch (name) { case 'list-calendars': return await this.listCalendars(); case 'create-event': return await this.createEvent(args); case 'create-batch-events': return await this.createBatchEvents(args); case 'delete-events-by-keyword': return await this.deleteEventsByKeyword(args); case 'list-today-events': return await this.listTodayEvents(args); case 'list-week-events': return await this.listWeekEvents(args); case 'search-events': return await this.searchEvents(args); case 'fix-event-times': return await this.fixEventTimes(args); default: throw new Error(`Unknown tool: ${name}`); }

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/xybstone/macos-calendar-mcp'

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