delete-events-by-keyword
Remove calendar events by matching keywords to clean up your macOS Calendar. Specify a keyword to delete matching events from a selected calendar.
Instructions
根据关键词删除事件
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keyword | Yes | 要删除的事件关键词 | |
| calendar | No | 日历名称 | 工作 |
| confirm | No | 确认删除 |
Implementation Reference
- macos-calendar-mcp-sdk.js:396-442 (handler)Handler function that implements the delete-events-by-keyword tool. Parses arguments, checks confirmation, executes AppleScript to delete matching events from the specified calendar, and returns the count of deleted events.async deleteEventsByKeyword(args) { const { keyword, calendar = '工作', confirm = false } = args; if (!confirm) { return { content: [ { type: 'text', text: `⚠️ 请确认删除操作!\n将删除日历"${calendar}"中包含关键词"${keyword}"的所有事件。\n要执行删除,请设置 confirm: true`, }, ], }; } const script = ` tell application "Calendar" set theCalendar to calendar "${calendar}" set allEvents to every event of theCalendar set deletedCount to 0 repeat with anEvent in reverse of allEvents if (summary of anEvent) contains "${keyword}" then delete anEvent set deletedCount to deletedCount + 1 end if end repeat return deletedCount end tell `; try { const result = execSync(`osascript -e '${script}'`, { encoding: 'utf8' }); const deletedCount = parseInt(result.trim()) || 0; return { content: [ { type: 'text', text: `🗑️ 删除完成!\n删除了 ${deletedCount} 个包含"${keyword}"的事件`, }, ], }; } catch (error) { throw new Error(`删除事件失败: ${error.message}`); } }
- macos-calendar-mcp-sdk.js:111-135 (schema)Input schema definition for the delete-events-by-keyword tool in the listTools response.{ name: 'delete-events-by-keyword', description: '根据关键词删除事件', inputSchema: { type: 'object', properties: { keyword: { type: 'string', description: '要删除的事件关键词', }, calendar: { type: 'string', description: '日历名称', default: '工作', }, confirm: { type: 'boolean', description: '确认删除', default: false, }, }, required: ['keyword'], additionalProperties: false, }, },
- macos-calendar-mcp-v2.js:332-375 (handler)Handler function that implements the delete-events-by-keyword tool. Parses arguments, checks confirmation, executes AppleScript to delete matching events, and returns the deletion count.// 根据关键词删除事件 deleteEventsByKeyword(args) { const { keyword, calendar = "工作", confirm = false } = args; if (!confirm) { return { content: [{ type: "text", text: `⚠️ 请确认删除操作!\n将删除日历"${calendar}"中包含关键词"${keyword}"的所有事件。\n要执行删除,请设置 confirm: true` }] }; } const script = ` tell application "Calendar" set theCalendar to calendar "${calendar}" set allEvents to every event of theCalendar set deletedCount to 0 repeat with anEvent in reverse of allEvents if (summary of anEvent) contains "${keyword}" then delete anEvent set deletedCount to deletedCount + 1 end if end repeat return deletedCount end tell `; try { const result = execSync(`osascript -e '${script}'`, { encoding: 'utf8' }); const deletedCount = parseInt(result.trim()) || 0; return { content: [{ type: "text", text: `🗑️ 删除完成!\n删除了 ${deletedCount} 个包含"${keyword}"的事件` }] }; } catch (error) { throw new Error(`删除事件失败: ${error.message}`); } }
- macos-calendar-mcp-v2.js:107-131 (schema)Input schema for delete-events-by-keyword tool returned by getTools method.{ name: "delete-events-by-keyword", description: "根据关键词删除事件", inputSchema: { type: "object", properties: { keyword: { type: "string", description: "要删除的事件关键词" }, calendar: { type: "string", description: "日历名称", default: "工作" }, confirm: { type: "boolean", description: "确认删除", default: false } }, required: ["keyword", "confirm"], additionalProperties: false } },
- macos-calendar-mcp-sdk.js:233-252 (registration)Switch statement in CallToolRequestSchema handler registering the delete-events-by-keyword tool.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}`); }