Skip to main content
Glama

delete-events-by-keyword

Remove calendar events in macOS Calendar by specifying a keyword. Directly integrates with the macOS Calendar app, enabling quick deletion without OAuth setup.

Instructions

根据关键词删除事件

Input Schema

NameRequiredDescriptionDefault
calendarNo日历名称工作
confirmNo确认删除
keywordYes要删除的事件关键词

Input Schema (JSON Schema)

{ "additionalProperties": false, "properties": { "calendar": { "default": "工作", "description": "日历名称", "type": "string" }, "confirm": { "default": false, "description": "确认删除", "type": "boolean" }, "keyword": { "description": "要删除的事件关键词", "type": "string" } }, "required": [ "keyword" ], "type": "object" }

Implementation Reference

  • Handler function that implements the delete-events-by-keyword tool. It destructures args for keyword, calendar, and confirm flag. If not confirmed, returns warning. Otherwise, constructs AppleScript to iterate over events in reverse, delete those whose summary contains the keyword, count deletions, execute via osascript, and return success message with count.
    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}`); } }
  • Handler function implementing delete-events-by-keyword tool in v2 version. Similar to sdk version: checks confirm, generates AppleScript to delete matching events by keyword in summary, executes and returns 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}`); } }
  • Input schema definition for the delete-events-by-keyword tool, defining parameters keyword (required string), calendar (optional string default '工作'), confirm (optional boolean default false). Part of the tools list returned by ListToolsRequestHandler.
    { 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, }, },
  • Input schema for delete-events-by-keyword in v2, similar but requires both 'keyword' and 'confirm'.
    { 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 }
  • Registration/dispatch case in the CallToolRequestHandler switch statement that routes calls to the deleteEventsByKeyword handler.
    case 'delete-events-by-keyword': return await this.deleteEventsByKeyword(args);

Other Tools

Related Tools

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