Skip to main content
Glama
xybstone

macOS Calendar MCP Server

by xybstone

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}`);
    }
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. '创建' (create) implies a write/mutation operation, but it doesn't disclose behavioral traits such as permissions required, whether events are created synchronously/asynchronously, error handling for partial failures, or rate limits. For a batch mutation tool, this is a significant gap in transparency.

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?

The description is a single phrase '批量创建事件' (batch create events), which is extremely concise and front-loaded with the core action. Every word earns its place, with no wasted text or redundancy.

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?

Given the complexity of a batch creation tool with no annotations and no output schema, the description is incomplete. It lacks information on behavioral aspects (e.g., mutation effects, error handling), usage context relative to siblings, and expected outputs. The agent must rely heavily on the schema and inference, which is insufficient for safe operation.

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%, with parameters 'events' and 'calendar' documented in the schema. The description adds no additional meaning beyond the schema, such as explaining the structure of events or the significance of the calendar parameter. Baseline 3 is appropriate as the schema handles parameter documentation adequately.

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 '批量创建事件' (batch create events) clearly states the verb (create) and resource (events) with the batch operation modifier. It distinguishes from the sibling 'create-event' by specifying batch capability, though it doesn't explicitly contrast them. The purpose is specific and actionable.

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?

The description provides no guidance on when to use this tool versus alternatives like 'create-event' for single events or other event-related tools. There's no mention of prerequisites, constraints, or comparative context with siblings, leaving the agent to infer usage scenarios.

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