Skip to main content
Glama
xybstone

macOS Calendar MCP Server

by xybstone

list-today-events

Retrieve today's scheduled events from macOS Calendar to view your daily agenda and manage time effectively.

Instructions

列出今天的事件

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
calendarNo日历名称个人

Implementation Reference

  • Main handler function for 'list-today-events' tool. Executes AppleScript to query today's events from macOS Calendar app and formats the output.
    async listTodayEvents(args) {
      const { calendar = '个人' } = args;
      
      const script = `
        tell application "Calendar"
          set theCalendar to calendar "${calendar}"
          set todayStart to (current date) - (time of (current date))
          set todayEnd to todayStart + (24 * hours) - 1
          
          set todayEvents to every event of theCalendar whose start date ≥ todayStart and start date ≤ todayEnd
          
          set eventList to {}
          repeat with anEvent in todayEvents
            set eventInfo to (summary of anEvent) & "|" & (start date of anEvent) & "|" & (end date of anEvent) & "|" & (description 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} - 今日无事件`,
              },
            ],
          };
        }
    
        const eventList = events.split(',').map(event => {
          const [title, start, end, desc, loc] = event.trim().split('|');
          return `📝 ${title}\n🕒 ${start} - ${end}${loc ? `\n📍 ${loc}` : ''}${desc ? `\n📄 ${desc}` : ''}`;
        }).join('\n\n');
    
        return {
          content: [
            {
              type: 'text',
              text: `📅 ${calendar} - 今日事件:\n\n${eventList}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`获取今日事件失败: ${error.message}`);
      }
    }
  • Input schema definition for the 'list-today-events' tool in the ListTools response.
    name: 'list-today-events',
    description: '列出今天的事件',
    inputSchema: {
      type: 'object',
      properties: {
        calendar: {
          type: 'string',
          description: '日历名称',
          default: '个人',
        },
      },
      additionalProperties: false,
    },
  • Tool registration in the switch statement within CallToolRequestSchema handler.
    case 'list-today-events':
      return await this.listTodayEvents(args);
  • Handler function for 'list-today-events' in v2 implementation.
    listTodayEvents(args) {
      const { calendar = "个人" } = args;
      
      const script = `
        tell application "Calendar"
          set theCalendar to calendar "${calendar}"
          set todayStart to (current date) - (time of (current date))
          set todayEnd to todayStart + (24 * hours) - 1
          
          set todayEvents to every event of theCalendar whose start date ≥ todayStart and start date ≤ todayEnd
          
          set eventList to {}
          repeat with anEvent in todayEvents
            set eventInfo to (summary of anEvent) & "|" & (start date of anEvent) & "|" & (end date of anEvent) & "|" & (description 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} - 今日无事件`
            }]
          };
        }
    
        const eventList = events.split(',').map(event => {
          const [title, start, end, desc, loc] = event.trim().split('|');
          return `📝 ${title}\n🕒 ${start} - ${end}${loc ? `\n📍 ${loc}` : ''}${desc ? `\n📄 ${desc}` : ''}`;
        }).join('\n\n');
    
        return {
          content: [{
            type: "text",
            text: `📅 ${calendar} - 今日事件:\n\n${eventList}`
          }]
        };
      } catch (error) {
        throw new Error(`获取今日事件失败: ${error.message}`);
      }
    }
  • Handler function for 'list-today-events' in v1 implementation.
    listTodayEvents(args) {
      const { calendar = "个人" } = args;
      
      const script = `
        tell application "Calendar"
          set theCalendar to calendar "${calendar}"
          set todayStart to (current date) - (time of (current date))
          set todayEnd to todayStart + (24 * hours) - 1
          
          set todayEvents to every event of theCalendar whose start date ≥ todayStart and start date ≤ todayEnd
          
          set eventList to {}
          repeat with anEvent in todayEvents
            set eventInfo to (summary of anEvent) & "|" & (start date of anEvent) & "|" & (end date of anEvent) & "|" & (description 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} - 今日无事件`
            }]
          };
        }
    
        const eventList = events.split(',').map(event => {
          const [title, start, end, desc, loc] = event.trim().split('|');
          return `📝 ${title}\n🕒 ${start} - ${end}${loc ? `\n📍 ${loc}` : ''}${desc ? `\n📄 ${desc}` : ''}`;
        }).join('\n\n');
    
        return {
          content: [{
            type: "text",
            text: `📅 ${calendar} - 今日事件:\n\n${eventList}`
          }]
        };
      } catch (error) {
        throw new Error(`获取今日事件失败: ${error.message}`);
      }
    }

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