Skip to main content
Glama

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);

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