Skip to main content
Glama
xybstone

macOS Calendar MCP Server

by xybstone

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
NameRequiredDescriptionDefault
keywordYes要删除的事件关键词
calendarNo日历名称工作
confirmNo确认删除

Implementation Reference

  • 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}`);
      }
    }
  • 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,
      },
    },
  • 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}`);
      }
    }
  • 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
      }
    },
  • 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}`);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states '删除' (delete) which implies a destructive mutation, but lacks details on permissions needed, whether deletions are permanent/reversible, rate limits, or what happens if no events match the keyword. For a destructive tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely concise with a single sentence that directly states the tool's purpose. No wasted words or unnecessary elaboration, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive mutation tool with no annotations and no output schema, the description is incomplete. It doesn't cover behavioral aspects like safety (e.g., confirmation via 'confirm' parameter), error handling, or return values, leaving significant gaps for agent understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters (keyword, calendar, confirm). The description adds no additional meaning beyond implying keyword-based filtering, matching the baseline score when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '根据关键词删除事件' (Delete events by keyword) clearly states the action (delete) and target resource (events) with a specific mechanism (by keyword). It distinguishes from siblings like create-event or list-events, though it doesn't explicitly differentiate from other deletion tools (none listed).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like search-events or other deletion methods. The description implies usage for keyword-based deletion but doesn't mention prerequisites, exclusions, or comparison with sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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