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)}`);
        }
    }
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. It mentions 'Search and retrieve' but doesn't disclose behavioral traits such as permissions needed, rate limits, whether it's read-only or destructive, or what the return format looks like. This leaves significant gaps for a tool with no output schema.

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 front-loads the core purpose ('Search and retrieve contacts') without unnecessary words. It earns its place by clearly stating the tool's function in a compact form.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what 'retrieve' entails (e.g., what data is returned, format, or pagination), nor does it cover behavioral aspects like safety or constraints, making it inadequate for a search tool with no structured output documentation.

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 description does not add meaning beyond the input schema, which has 100% coverage and fully documents the single optional parameter 'name'. Since schema coverage is high, the baseline score of 3 is appropriate, as the description doesn't compensate with extra details like search syntax or examples.

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 and retrieve') and resource ('contacts from Apple Contacts app'), making the purpose evident. However, it doesn't differentiate this tool from potential sibling tools like 'calendar' or 'mail' in terms of domain specificity beyond mentioning 'Apple Contacts app'.

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 like 'mail' or 'messages', nor does it mention any prerequisites or exclusions. It implies usage for contact-related searches but lacks explicit context or comparisons.

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/jxnl/apple-mcp'

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