Skip to main content
Glama
adamzaidi

icloud-mcp

by adamzaidi

update_contact

Modify specific details for an existing contact in iCloud Contacts while preserving unchanged information.

Instructions

Update an existing contact in iCloud Contacts. Only provided fields are changed; others are preserved.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contactIdYesContact ID to update
firstNameNo
lastNameNo
fullNameNo
orgNo
phoneNo
emailNo
phonesNo
emailsNo
addressesNo
birthdayNo
noteNo
urlNo

Implementation Reference

  • The handler implementation for the `update_contact` tool, which fetches an existing contact, merges new fields, and updates it back to the CardDAV server using a PUT request with ETag validation.
    export async function updateContact(contactId, fields) {
      const { dataHost, addressBookPath } = await discover();
      const url = `${dataHost}${addressBookPath}${contactId}.vcf`;
    
      // Fetch existing to get etag and merge fields
      const existing = await davRequest('GET', url);
      if (existing.status === 404) throw new Error(`Contact not found: ${contactId}`);
    
      const current = parseVCard(existing.body);
    
      // Merge: new fields override, but keep arrays from existing if not overridden
      const merged = { ...current, ...fields };
      // Preserve the original VCARD UID (which may differ from the filename UUID)
      const vcard = serializeVCard(merged, current.uid || contactId);
    
      const resp = await davRequest('PUT', url, {
        contentType: 'text/vcard; charset=utf-8',
        etag: existing.etag,
        body: vcard,
      });
    
      if (resp.status !== 204 && resp.status !== 200) {
        throw new Error(`CardDAV PUT (update) failed: ${resp.status} — ${resp.body.slice(0, 200)}`);
      }
    
      return { updated: true, contactId, etag: resp.etag };
    }

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/adamzaidi/icloud-mcp'

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