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
| Name | Required | Description | Default |
|---|---|---|---|
| events | Yes | 事件列表 | |
| calendar | No | 目标日历 | 工作 |
Implementation Reference
- macos-calendar-mcp-sdk.js:352-394 (handler)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')}`, }, ], }; }
- macos-calendar-mcp-sdk.js:80-109 (schema)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, },
- macos-calendar-mcp-v2.js:294-330 (handler)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')}` }] }; }
- macos-calendar-mcp-v2.js:77-105 (schema)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 }
- macos-calendar-mcp-sdk.js:233-252 (registration)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}`); }