Skip to main content
Glama
xybstone

macOS Calendar MCP Server

by xybstone

search-events

Search macOS Calendar events by keywords to find specific appointments, meetings, or reminders across your calendars.

Instructions

搜索事件

Input Schema

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

Implementation Reference

  • Implementation of the search-events tool handler. Searches for events in the specified calendar using AppleScript by checking if the query is 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}`);
      }
    }
  • Implementation of the search-events tool handler in the MCP SDK version. Uses AppleScript to search events matching the query in title or description within the calendar.
    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) {
        throw new Error(`搜索事件失败: ${error.message}`);
      }
    }
  • Implementation of the search-events tool handler in v2. Searches events using AppleScript query 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}`);
      }
    }
  • Input schema definition for the search-events tool in getTools().
    {
      name: "search-events",
      description: "搜索事件",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "搜索关键词"
          },
          calendar: {
            type: "string",
            description: "日历名称",
            default: "个人"
          }
        },
        required: ["query"],
        additionalProperties: false
      }
  • Registration of the search-events handler in the callTool switch statement.
    case "search-events":
      return this.searchEvents(args);
Behavior1/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. '搜索事件' gives no information about whether this is a read-only operation, what permissions might be required, whether it's paginated, what the return format looks like, or any rate limits. For a search tool with zero annotation coverage, this is completely inadequate.

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 extremely concise at just two characters ('搜索事件'), which is appropriately sized for what little information it conveys. There's no wasted text or unnecessary elaboration. However, this conciseness comes at the cost of being under-specified rather than truly efficient.

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 the complexity of a search operation with 2 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what constitutes an 'event', how search results are returned, what fields are searchable, or any behavioral characteristics. The description fails to compensate for the lack of structured metadata.

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%, so the schema already documents both parameters (query and calendar) with their descriptions. The tool description adds no additional meaning about parameters beyond what the schema provides. The baseline of 3 is appropriate when the schema does the heavy lifting, even though the description contributes nothing about parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '搜索事件' (search events) is a tautology that restates the tool name without adding specificity. It doesn't clarify what type of events, what scope, or how the search works. While it includes a verb ('搜索') and resource ('事件'), it lacks differentiation from sibling tools like 'list-today-events' or 'list-week-events'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/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. There are multiple sibling tools for event-related operations (list-today-events, list-week-events, delete-events-by-keyword), but the description offers no context about when this search tool is appropriate versus those listing tools or when it should be avoided.

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