Skip to main content
Glama
xybstone

macOS Calendar MCP Server

by xybstone

list-week-events

Retrieve calendar events for a specified week from macOS Calendar. Provide the week start date to view scheduled appointments and meetings.

Instructions

列出指定周的事件

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
weekStartYes周开始日期,格式:YYYY-MM-DD
calendarNo日历名称工作

Implementation Reference

  • Main handler function for 'list-week-events' tool. Parses weekStart, formats dates, executes AppleScript to query Calendar app for events in the week, formats and returns the list.
    async listWeekEvents(args) {
      const { weekStart, calendar = '工作' } = args;
      
      const startDate = new Date(weekStart);
      const endDate = new Date(startDate);
      endDate.setDate(startDate.getDate() + 7);
      
      const formattedStart = this.formatDateForAppleScript(weekStart + ' 00:00');
      const formattedEnd = this.formatDateForAppleScript(endDate.toISOString().split('T')[0] + ' 00:00');
      
      const script = `
        tell application "Calendar"
          set theCalendar to calendar "${calendar}"
          set weekStart to date "${formattedStart}"
          set weekEnd to date "${formattedEnd}"
          
          set weekEvents to every event of theCalendar whose start date ≥ weekStart and start date < weekEnd
          
          set eventList to {}
          repeat with anEvent in weekEvents
            set eventInfo to (summary of anEvent) & "|" & (start date of anEvent) & "|" & (end date of anEvent) & "|" & (location of anEvent)
            set end of eventList to eventInfo
          end repeat
          
          return eventList as string
        end tell
      `;
    
      try {
        const result = execSync(`osascript -e '${script}'`, { encoding: 'utf8' });
        const events = result.trim();
        
        if (!events || events === '""') {
          return {
            content: [
              {
                type: 'text',
                text: `📅 ${calendar} - ${weekStart}这周无事件`,
              },
            ],
          };
        }
    
        const eventList = events.split(',').map(event => {
          const [title, start, end, loc] = event.trim().split('|');
          return `📝 ${title}\n🕒 ${start} - ${end}${loc ? `\n📍 ${loc}` : ''}`;
        }).join('\n\n');
    
        return {
          content: [
            {
              type: 'text',
              text: `📅 ${calendar} - ${weekStart}这周的事件:\n\n${eventList}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`获取周事件失败: ${error.message}`);
      }
    }
  • Input schema definition for the 'list-week-events' tool, defining parameters weekStart (required) and calendar (optional).
    name: 'list-week-events',
    description: '列出指定周的事件',
    inputSchema: {
      type: 'object',
      properties: {
        weekStart: {
          type: 'string',
          description: '周开始日期,格式:YYYY-MM-DD',
        },
        calendar: {
          type: 'string',
          description: '日历名称',
          default: '工作',
        },
      },
      required: ['weekStart'],
      additionalProperties: false,
    },
  • Main handler function for 'list-week-events' tool in v2 implementation. Similar to sdk version, uses AppleScript to fetch weekly events.
    // 列出指定周的事件
    listWeekEvents(args) {
      const { weekStart, calendar = "工作" } = args;
      
      const startDate = new Date(weekStart);
      const endDate = new Date(startDate);
      endDate.setDate(startDate.getDate() + 7);
      
      const formattedStart = this.formatDateForAppleScript(weekStart + " 00:00");
      const formattedEnd = this.formatDateForAppleScript(endDate.toISOString().split('T')[0] + " 00:00");
      
      const script = `
        tell application "Calendar"
          set theCalendar to calendar "${calendar}"
          set weekStart to date "${formattedStart}"
          set weekEnd to date "${formattedEnd}"
          
          set weekEvents to every event of theCalendar whose start date ≥ weekStart and start date < weekEnd
          
          set eventList to {}
          repeat with anEvent in weekEvents
            set eventInfo to (summary of anEvent) & "|" & (start date of anEvent) & "|" & (end date of anEvent) & "|" & (location of anEvent)
            set end of eventList to eventInfo
          end repeat
          
          return eventList as string
        end tell
      `;
    
      try {
        const result = execSync(`osascript -e '${script}'`, { encoding: 'utf8' });
        const events = result.trim();
        
        if (!events || events === '""') {
          return {
            content: [{
              type: "text",
              text: `📅 ${calendar} - ${weekStart}这周无事件`
            }]
          };
        }
    
        const eventList = events.split(',').map(event => {
          const [title, start, end, loc] = event.trim().split('|');
          return `📝 ${title}\n🕒 ${start} - ${end}${loc ? `\n📍 ${loc}` : ''}`;
        }).join('\n\n');
    
        return {
          content: [{
            type: "text",
            text: `📅 ${calendar} - ${weekStart}这周的事件:\n\n${eventList}`
          }]
        };
      } catch (error) {
        throw new Error(`获取周事件失败: ${error.message}`);
      }
    }
  • Input schema for 'list-week-events' tool in v2, specifying weekStart as required string and optional calendar.
      name: "list-week-events",
      description: "列出指定周的事件",
      inputSchema: {
        type: "object",
        properties: {
          weekStart: {
            type: "string",
            description: "周开始日期,格式:YYYY-MM-DD"
          },
          calendar: {
            type: "string",
            description: "日历名称",
            default: "工作"
          }
        },
        required: ["weekStart"],
        additionalProperties: false
      }
    },
  • Registration/dispatch in the switch statement for CallToolRequestSchema handler, routing to listWeekEvents.
    case 'list-week-events':
      return await this.listWeekEvents(args);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action (list events) but doesn't describe traits like read-only vs. destructive (implied read-only from 'list'), authentication needs, rate limits, pagination, or return format. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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, efficient sentence in Chinese ('列出指定周的事件') that directly states the tool's purpose with zero waste. It's appropriately sized and front-loaded, making it easy to parse quickly without unnecessary elaboration.

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 no annotations and no output schema, the description is incomplete for a tool with 2 parameters. It doesn't explain return values (e.g., event details, format), error handling, or behavioral constraints. While the schema covers parameters well, the overall context lacks necessary information for safe and effective use, especially for a listing 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 clear descriptions for both parameters: 'weekStart' (week start date in YYYY-MM-DD format) and 'calendar' (calendar name, default '工作'). The description adds no additional meaning beyond the schema, such as explaining how 'weekStart' defines the week range or what '工作' means. Baseline 3 is appropriate since the 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 '列出指定周的事件' (List events for a specified week) clearly states the verb (list) and resource (events) with a temporal scope (specified week). It distinguishes from siblings like 'list-today-events' (today-specific) and 'search-events' (general search), but doesn't explicitly differentiate from 'list-calendars' (different resource). 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. It doesn't mention siblings like 'list-today-events' for today's events or 'search-events' for broader queries, nor does it specify prerequisites or exclusions. Usage is implied by the name and description alone, with no explicit context.

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