list-today-events
Retrieve today's scheduled events from macOS Calendar to view your daily agenda and manage time effectively.
Instructions
列出今天的事件
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list-today-events"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| calendar | No | 日历名称 | 个人 |
Implementation Reference
- macos-calendar-mcp-sdk.js:444-496 (handler)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}`); } } - macos-calendar-mcp-sdk.js:137-149 (schema)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, }, - macos-calendar-mcp-sdk.js:242-243 (registration)Tool registration in the switch statement within CallToolRequestSchema handler.
case 'list-today-events': return await this.listTodayEvents(args); - macos-calendar-mcp-v2.js:378-426 (handler)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}`); } } - macos-calendar-mcp.js:203-251 (handler)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}`); } }