Skip to main content
Glama
jxnl
by jxnl

contacts

Search and retrieve contact information from Apple Contacts app using partial or full name queries to find specific people in your address book.

Instructions

Search and retrieve contacts from Apple Contacts app

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoName to search for (optional - if not provided, returns all contacts). Can be partial name to search.

Implementation Reference

  • tools.ts:3-15 (schema)
    Defines the input schema and metadata for the 'contacts' MCP tool.
    const CONTACTS_TOOL: Tool = {
        name: "contacts",
        description: "Search and retrieve contacts from Apple Contacts app",
        inputSchema: {
          type: "object",
          properties: {
            name: {
              type: "string",
              description: "Name to search for (optional - if not provided, returns all contacts). Can be partial name to search."
            }
          }
        }
      };
  • tools.ts:308-310 (registration)
    Registers the CONTACTS_TOOL in the array of tools exported for the MCP server.
    const tools = [CONTACTS_TOOL, NOTES_TOOL, MESSAGES_TOOL, MAIL_TOOL, REMINDERS_TOOL, WEB_SEARCH_TOOL, CALENDAR_TOOL, MAPS_TOOL];
    
    export default tools;
  • Utility function to check access permissions to the Contacts app before performing operations.
    async function checkContactsAccess(): Promise<boolean> {
        try {
            // Try to get the count of contacts as a simple test
            await runAppleScript(`
    tell application "Contacts"
        count every person
    end tell`);
            return true;
        } catch (error) {
            throw new Error(`Cannot access Contacts app. Please grant access in System Preferences > Security & Privacy > Privacy > Contacts.`);
        }
    }
  • Retrieves all contacts and their associated phone numbers, used when no search name is provided.
    async function getAllNumbers() {
        try {
            if (!await checkContactsAccess()) {
                return {};
            }
    
            const nums: { [key: string]: string[] } = await run(() => {
                const Contacts = Application('Contacts');
                const people = Contacts.people();
                const phoneNumbers: { [key: string]: string[] } = {};
    
                for (const person of people) {
                    try {
                        const name = person.name();
                        const phones = person.phones().map((phone: any) => phone.value());
    
                        if (!phoneNumbers[name]) {
                            phoneNumbers[name] = [];
                        }
                        phoneNumbers[name] = [...phoneNumbers[name], ...phones];
                    } catch (error) {
                        // Skip contacts that can't be processed
                    }
                }
    
                return phoneNumbers;
            });
    
            return nums;
        } catch (error) {
            throw new Error(`Error accessing contacts: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
  • Searches for a contact by name (partial match) and returns their phone numbers, with fallback search; used when name is provided.
    async function findNumber(name: string) {
        try {
            if (!await checkContactsAccess()) {
                return [];
            }
    
            const nums: string[] = await run((name: string) => {
                const Contacts = Application('Contacts');
                const people = Contacts.people.whose({name: {_contains: name}});
                const phones = people.length > 0 ? people[0].phones() : [];
                return phones.map((phone: any) => phone.value());
            }, name);
    
            // If no numbers found, run getNumbers() to find the closest match
            if (nums.length === 0) {
                const allNumbers = await getAllNumbers();
                const closestMatch = Object.keys(allNumbers).find(personName => 
                    personName.toLowerCase().includes(name.toLowerCase())
                );
                return closestMatch ? allNumbers[closestMatch] : [];
            }
    
            return nums;
        } catch (error) {
            throw new Error(`Error finding contact: ${error instanceof Error ? error.message : String(error)}`);
        }
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool searches and retrieves contacts, implying a read-only operation, but doesn't specify permissions needed, whether it accesses local or synced data, rate limits, or what the return format looks like (e.g., list of contacts with fields). This leaves significant gaps for a tool interacting with personal data.

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 with zero waste. It front-loads the core purpose ('Search and retrieve contacts') and specifies the source ('from Apple Contacts app'), making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (searching personal contacts), lack of annotations, and no output schema, the description is minimally adequate. It states what the tool does but omits critical context like return format, error handling, or data sensitivity considerations. It relies heavily on the schema for parameter details, leaving behavioral aspects underspecified.

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 input schema fully documents the single optional parameter. The description adds no additional parameter semantics beyond what's in the schema (e.g., no examples of search syntax or format). This meets the baseline for high schema coverage.

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 tool's purpose with a specific verb ('Search and retrieve') and resource ('contacts from Apple Contacts app'). It distinguishes itself from siblings like calendar or mail by focusing on contacts, but doesn't explicitly differentiate from potential contact-related tools that might exist in other contexts.

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 provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, limitations, or scenarios where other tools might be more appropriate. The agent must infer usage from the purpose alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools