Skip to main content
Glama

search-events

Search macOS Calendar events using keywords and specific calendar names for quick access to scheduled activities without OAuth setup.

Instructions

搜索事件

Input Schema

NameRequiredDescriptionDefault
calendarNo日历名称个人
queryYes搜索关键词

Input Schema (JSON Schema)

{ "additionalProperties": false, "properties": { "calendar": { "default": "个人", "description": "日历名称", "type": "string" }, "query": { "description": "搜索关键词", "type": "string" } }, "required": [ "query" ], "type": "object" }

Implementation Reference

  • Implements the 'search-events' tool handler. Uses AppleScript to query Calendar app for events matching the search query in summary or description, parses results, and returns formatted list.
    searchEvents(args) { const { query, calendar = "个人" } = args; const script = ` tell application "Calendar" set theCalendar to calendar "${calendar}" set allEvents to every event of theCalendar set matchingEvents to {} repeat with anEvent in allEvents if (summary of anEvent) contains "${query}" or (description of anEvent) contains "${query}" then set eventInfo to (summary of anEvent) & "|" & (start date of anEvent) & "|" & (end date of anEvent) & "|" & (description of anEvent) & "|" & (location of anEvent) set end of matchingEvents to eventInfo end if end repeat return matchingEvents 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} 中未找到包含 "${query}" 的事件` }] }; } 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} 中找到 ${events.split(',').length} 个匹配事件:\n\n${eventList}` }] }; } catch (error) { throw new Error(`搜索事件失败: ${error.message}`); } } }
  • Input schema definition for the 'search-events' tool in the tools list.
    { name: "search-events", description: "搜索事件", inputSchema: { type: "object", properties: { query: { type: "string", description: "搜索关键词" }, calendar: { type: "string", description: "日历名称", default: "个人" } }, required: ["query"], additionalProperties: false } }
  • Dispatch registration in the callTool switch statement that routes to the searchEvents handler.
    case "search-events": return this.searchEvents(args);
  • Implements the 'search-events' tool handler using the MCP SDK framework. Similar logic to other versions, executes AppleScript for event search.
    async searchEvents(args) { const { query, calendar = '个人' } = args; const script = ` tell application "Calendar" set theCalendar to calendar "${calendar}" set allEvents to every event of theCalendar set matchingEvents to {} repeat with anEvent in allEvents if (summary of anEvent) contains "${query}" or (description of anEvent) contains "${query}" then set eventInfo to (summary of anEvent) & "|" & (start date of anEvent) & "|" & (end date of anEvent) & "|" & (description of anEvent) & "|" & (location of anEvent) set end of matchingEvents to eventInfo end if end repeat return matchingEvents 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} 中未找到包含 "${query}" 的事件`, }, ], }; } 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} 中找到 ${events.split(',').length} 个匹配事件:\n\n${eventList}`, }, ], }; } catch (error) {
  • Implements the 'search-events' tool handler in version 1.0.0. Uses AppleScript to search events by keyword in summary or description.
    searchEvents(args) { const { query, calendar = "个人" } = args; const script = ` tell application "Calendar" set theCalendar to calendar "${calendar}" set allEvents to every event of theCalendar set matchingEvents to {} repeat with anEvent in allEvents if (summary of anEvent) contains "${query}" or (description of anEvent) contains "${query}" then set eventInfo to (summary of anEvent) & "|" & (start date of anEvent) & "|" & (end date of anEvent) & "|" & (description of anEvent) & "|" & (location of anEvent) set end of matchingEvents to eventInfo end if end repeat return matchingEvents 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} 中未找到包含 "${query}" 的事件` }] }; } 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} 中找到 ${events.split(',').length} 个匹配事件:\n\n${eventList}` }] }; } catch (error) { throw new Error(`搜索事件失败: ${error.message}`); } }

Other Tools

Related 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