Skip to main content
Glama
jcontini

macOS Contacts MCP

by jcontini

update_contact

Modify contact details in macOS Contacts, including name, organization, emails, phones, URLs, and notes, by specifying the contact identifier.

Instructions

Update an existing contact

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
identifierYesContact name or unique ID
nameNoUpdated full name
organizationNoUpdated organization or company name
job_titleNoUpdated job title or position
emailsNoUpdated email addresses (replaces all existing)
phonesNoUpdated phone numbers (replaces all existing)
urlsNoUpdated URLs (replaces all existing)
noteNoUpdated notes

Implementation Reference

  • The main handler function for the 'update_contact' tool. It retrieves the contact by identifier, then updates specified fields (name, organization, job_title, note, emails, phones, urls) by executing AppleScript commands to modify the macOS Contacts app.
      private async updateContact(args: any): Promise<any> {
        const { identifier, ...updates } = args;
    
        // First get the contact to verify it exists and get the correct ID
        const existingContact = await this.getContact({ identifier });
        if (!existingContact.success) {
          throw new Error('Contact not found');
        }
    
        const contactId = existingContact.contact.id;
        const updatedFields: string[] = [];
    
        // Update name if provided
        if (updates.name !== undefined) {
          try {
            // Parse name into first/last name
            const nameParts = updates.name.trim().split(' ');
            const firstName = nameParts[0] || '';
            const lastName = nameParts.length > 1 ? nameParts.slice(1).join(' ') : '';
            
            const script = `tell application "Contacts"
      set targetPerson to person id "${contactId}"
      set first name of targetPerson to "${this.escapeForAppleScript(firstName)}"
      set last name of targetPerson to "${this.escapeForAppleScript(lastName)}"
      save
    end tell`;
            this.executeAppleScript(script);
            updatedFields.push('name');
          } catch (error) {
            console.error('Failed to update name:', error);
          }
        }
    
        // Update basic properties one by one
        if (updates.organization !== undefined) {
          try {
            const script = `tell application "Contacts"
      set targetPerson to person id "${contactId}"
      set organization of targetPerson to "${this.escapeForAppleScript(updates.organization)}"
      save
    end tell`;
            this.executeAppleScript(script);
            updatedFields.push('organization');
          } catch (error) {
            console.error('Failed to update organization:', error);
          }
        }
    
        if (updates.job_title !== undefined) {
          try {
            const script = `tell application "Contacts"
      set targetPerson to person id "${contactId}"
      set job title of targetPerson to "${this.escapeForAppleScript(updates.job_title)}"
      save
    end tell`;
            this.executeAppleScript(script);
            updatedFields.push('job_title');
          } catch (error) {
            console.error('Failed to update job title:', error);
          }
        }
    
        if (updates.note !== undefined) {
          try {
            const script = `tell application "Contacts"
      set targetPerson to person id "${contactId}"
      set note of targetPerson to "${this.escapeForAppleScript(updates.note)}"
      save
    end tell`;
            this.executeAppleScript(script);
            updatedFields.push('note');
          } catch (error) {
            console.error('Failed to update note:', error);
          }
        }
    
        // Update URLs if provided
        if (updates.urls !== undefined) {
          try {
            // First, remove all existing URLs
            const clearUrlScript = `tell application "Contacts"
      set targetPerson to person id "${contactId}"
      delete every url of targetPerson
      save
    end tell`;
            this.executeAppleScript(clearUrlScript);
    
            // Then add new URLs
            if (updates.urls.length > 0) {
              let addUrlScript = `tell application "Contacts"
      set targetPerson to person id "${contactId}"`;
              
              updates.urls.forEach((url: any) => {
                addUrlScript += `
      make new url at end of urls of targetPerson with properties {label:"${this.escapeForAppleScript(url.label)}", value:"${this.escapeForAppleScript(url.value)}"}`;
              });
              
              addUrlScript += `
      save
    end tell`;
              
              this.executeAppleScript(addUrlScript);
            }
            
            updatedFields.push('urls');
          } catch (error) {
            console.error('Failed to update URLs:', error);
          }
        }
    
        // Update emails if provided
        if (updates.emails !== undefined) {
          try {
            // First, remove all existing emails
            const clearEmailScript = `tell application "Contacts"
      set targetPerson to person id "${contactId}"
      delete every email of targetPerson
      save
    end tell`;
            this.executeAppleScript(clearEmailScript);
    
            // Then add new emails
            if (updates.emails.length > 0) {
              let addEmailScript = `tell application "Contacts"
      set targetPerson to person id "${contactId}"`;
              
              updates.emails.forEach((email: string, index: number) => {
                const label = index === 0 ? 'home' : index === 1 ? 'work' : `email${index + 1}`;
                addEmailScript += `
      make new email at end of emails of targetPerson with properties {label:"${label}", value:"${this.escapeForAppleScript(email)}"}`;
              });
              
              addEmailScript += `
      save
    end tell`;
              
              this.executeAppleScript(addEmailScript);
            }
            
            updatedFields.push('emails');
          } catch (error) {
            console.error('Failed to update emails:', error);
          }
        }
    
        // Update phones if provided
        if (updates.phones !== undefined) {
          try {
            // First, remove all existing phones
            const clearPhoneScript = `tell application "Contacts"
      set targetPerson to person id "${contactId}"
      delete every phone of targetPerson
      save
    end tell`;
            this.executeAppleScript(clearPhoneScript);
    
            // Then add new phones
            if (updates.phones.length > 0) {
              let addPhoneScript = `tell application "Contacts"
      set targetPerson to person id "${contactId}"`;
              
              updates.phones.forEach((phone: string, index: number) => {
                const label = index === 0 ? 'home' : index === 1 ? 'work' : `phone${index + 1}`;
                addPhoneScript += `
      make new phone at end of phones of targetPerson with properties {label:"${label}", value:"${this.escapeForAppleScript(phone)}"}`;
              });
              
              addPhoneScript += `
      save
    end tell`;
              
              this.executeAppleScript(addPhoneScript);
            }
            
            updatedFields.push('phones');
          } catch (error) {
            console.error('Failed to update phones:', error);
          }
        }
        
        return {
          success: true,
          message: `Updated contact: ${identifier}`,
          updated_fields: updatedFields,
        };
      }
  • The input schema definition for the 'update_contact' tool, specifying parameters like identifier (required), name, organization, job_title, emails (array), phones (array), urls (array of objects), and note.
    {
      name: 'update_contact',
      description: 'Update an existing contact',
      inputSchema: {
        type: 'object',
        properties: {
          identifier: {
            type: 'string',
            description: 'Contact name or unique ID',
          },
          name: {
            type: 'string',
            description: 'Updated full name',
          },
          organization: {
            type: 'string',
            description: 'Updated organization or company name',
          },
          job_title: {
            type: 'string',
            description: 'Updated job title or position',
          },
          emails: {
            type: 'array',
            items: { type: 'string' },
            description: 'Updated email addresses (replaces all existing)',
          },
          phones: {
            type: 'array',
            items: { type: 'string' },
            description: 'Updated phone numbers (replaces all existing)',
          },
          urls: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                label: { type: 'string' },
                value: { type: 'string' },
              },
              required: ['label', 'value'],
            },
            description: 'Updated URLs (replaces all existing)',
          },
          note: {
            type: 'string',
            description: 'Updated notes',
          },
        },
        required: ['identifier'],
      },
    },
  • src/index.ts:225-227 (registration)
    The dispatch case in the CallToolRequest handler that routes 'update_contact' calls to the updateContact method.
    case 'update_contact':
      result = await this.updateContact(args);
      break;
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. While 'Update an existing contact' implies a mutation operation, it doesn't specify what happens to fields not included in the update (partial vs. full replacement), whether the operation is idempotent, what permissions are required, or what the response looks like. This is inadequate for a mutation tool with zero annotation coverage.

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 communicates the core purpose without any wasted words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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?

For a mutation tool with 8 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what happens on success/failure, how partial updates work, or provide any behavioral context beyond the basic action. The high schema coverage helps with parameters, but the overall context for safe and correct usage is lacking.

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 adds no parameter information beyond what's already in the schema, which has 100% coverage with detailed descriptions for each parameter. According to the rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description, which applies here.

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 ('Update') and target resource ('an existing contact'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its sibling 'create_contact' beyond the 'existing' qualifier, which is why it doesn't reach a perfect score.

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 'create_contact' or 'get_contact'. There's no mention of prerequisites, error conditions, or contextual factors that would help an agent choose appropriately among the sibling tools.

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