Skip to main content
Glama
jcontini

macOS Contacts MCP

by jcontini

search_contacts

Search macOS Contacts by name, organization, or notes to quickly find contact information.

Instructions

Search for contacts by name, organization, or notes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoSearch term to match against name, organization, or notes
limitNoMaximum number of results to return

Implementation Reference

  • The handler function that implements the core logic of the 'search_contacts' tool. It uses AppleScript to query the macOS Contacts application for contacts matching the given query (primarily by name), or returns recent contacts if no query is provided. Returns a structured result with contact names.
      private async searchContacts(args: any): Promise<any> {
        const { query, limit = 20 } = args;
    
        try {
          if (query) {
            // Use built-in search instead of manual loops
            const script = `tell application "Contacts" to return name of people whose name contains "${query}"`;
            const result = this.executeAppleScript(script);
            const names = result.split(', ').slice(0, limit);
            
            const contacts = names.map(name => ({
              name: name.trim(),
              organization: '', // Basic search only returns names for speed
            }));
    
            return {
              success: true,
              count: contacts.length,
              contacts,
            };
          } else {
            // Get first N contacts - simpler approach
            const script = `tell application "Contacts"
      set contactList to {}
      set allPeople to people
      repeat with i from 1 to ${Math.min(limit, 10)}
        if i > (count of allPeople) then exit repeat
        set aPerson to item i of allPeople
        set end of contactList to name of aPerson
      end repeat
      return contactList
    end tell`;
            
            const result = this.executeAppleScript(script);
            const names = result ? result.split(', ').slice(0, limit) : [];
            
            const contacts = names.map(name => ({
              name: name.trim(),
              organization: '', // Basic search only returns names for speed
            }));
    
            return {
              success: true,
              count: contacts.length,
              contacts,
            };
          }
        } catch (error) {
          throw new Error(`Search failed: ${error}`);
        }
      }
  • The input schema definition for the 'search_contacts' tool, specifying the expected parameters: query (string) and optional limit (integer, default 20). Part of the tool specification returned by ListTools.
    inputSchema: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: 'Search term to match against name, organization, or notes',
        },
        limit: {
          type: 'integer',
          description: 'Maximum number of results to return',
          default: 20,
        },
      },
    },
  • src/index.ts:216-218 (registration)
    The switch case in the CallToolRequestHandler that registers and routes calls to the 'search_contacts' tool to its handler method.
    case 'search_contacts':
      result = await this.searchContacts(args);
      break;
Behavior2/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. It states the search functionality but lacks details on permissions, rate limits, pagination, or what happens on no matches. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its operational behavior.

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 a single, efficient sentence that directly states the tool's purpose without any wasted words. It is appropriately sized and front-loaded, making it easy to understand at a glance.

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 tool with no annotations and no output schema, the description is incomplete. It doesn't explain the return format, error handling, or how results are structured, leaving the agent with insufficient information to fully utilize the tool effectively.

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?

The schema description coverage is 100%, so the input schema already documents both parameters ('query' and 'limit') thoroughly. The description adds marginal value by listing the searchable fields ('name, organization, or notes'), which aligns with the schema's description for 'query', but doesn't provide additional syntax or format details beyond what the schema provides.

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

Purpose4/5

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

The description clearly states the action ('Search for contacts') and the searchable fields ('by name, organization, or notes'), which provides a specific verb+resource. However, it doesn't explicitly differentiate from sibling tools like 'get_recent_contacts' or 'get_contact', which might also retrieve contacts but through different mechanisms.

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

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description offers no guidance on when to use this tool versus alternatives. It doesn't mention when to prefer 'search_contacts' over 'get_recent_contacts' (for recent items) or 'get_contact' (for specific IDs), nor does it provide any context about prerequisites or exclusions for usage.

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/jcontini/macos-contacts-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server