Skip to main content
Glama
jcontini

macOS Contacts MCP

by jcontini

create_contact

Generate and store a new contact with details such as name, organization, job title, emails, phone numbers, URLs, and notes directly in macOS Contacts.

Instructions

Create a new contact

Input Schema

NameRequiredDescriptionDefault
emailsNoEmail addresses
job_titleNoJob title or position
nameYesFull name of the contact
noteNoNotes about the contact
organizationNoOrganization or company name
phonesNoPhone numbers
urlsNoURLs (social media, websites, etc.) with labels

Input Schema (JSON Schema)

{ "properties": { "emails": { "description": "Email addresses", "items": { "type": "string" }, "type": "array" }, "job_title": { "description": "Job title or position", "type": "string" }, "name": { "description": "Full name of the contact", "type": "string" }, "note": { "description": "Notes about the contact", "type": "string" }, "organization": { "description": "Organization or company name", "type": "string" }, "phones": { "description": "Phone numbers", "items": { "type": "string" }, "type": "array" }, "urls": { "description": "URLs (social media, websites, etc.) with labels", "items": { "properties": { "label": { "type": "string" }, "value": { "type": "string" } }, "required": [ "label", "value" ], "type": "object" }, "type": "array" } }, "required": [ "name" ], "type": "object" }

Implementation Reference

  • The main handler function for the 'create_contact' tool. It destructures input args, parses the name into first/last, builds an AppleScript to create a new person in Contacts app, adds emails/phones/urls with labels, saves, returns the new contact ID and summary.
    private async createContact(args: any): Promise<any> { const { name, organization = '', job_title = '', emails = [], phones = [], urls = [], note = '' } = args; // Parse name into first/last name const nameParts = name.trim().split(' '); const firstName = nameParts[0] || ''; const lastName = nameParts.length > 1 ? nameParts.slice(1).join(' ') : ''; let script = ` tell application "Contacts" set newPerson to make new person if "${this.escapeForAppleScript(firstName)}" is not "" then set first name of newPerson to "${this.escapeForAppleScript(firstName)}" end if if "${this.escapeForAppleScript(lastName)}" is not "" then set last name of newPerson to "${this.escapeForAppleScript(lastName)}" end if if "${this.escapeForAppleScript(organization)}" is not "" then set organization of newPerson to "${this.escapeForAppleScript(organization)}" end if if "${this.escapeForAppleScript(job_title)}" is not "" then set job title of newPerson to "${this.escapeForAppleScript(job_title)}" end if if "${this.escapeForAppleScript(note)}" is not "" then set note of newPerson to "${this.escapeForAppleScript(note)}" end if `; // Add emails if (emails.length > 0) { emails.forEach((email: string, index: number) => { const label = index === 0 ? 'home' : index === 1 ? 'work' : `email${index + 1}`; script += `\n make new email at end of emails of newPerson with properties {label:"${label}", value:"${this.escapeForAppleScript(email)}"}`; }); } // Add phones if (phones.length > 0) { phones.forEach((phone: string, index: number) => { const label = index === 0 ? 'home' : index === 1 ? 'work' : `phone${index + 1}`; script += `\n make new phone at end of phones of newPerson with properties {label:"${label}", value:"${this.escapeForAppleScript(phone)}"}`; }); } // Add URLs if (urls.length > 0) { urls.forEach((url: any) => { script += `\n make new url at end of urls of newPerson with properties {label:"${this.escapeForAppleScript(url.label)}", value:"${this.escapeForAppleScript(url.value)}"}`; }); } script += ` save return id of newPerson end tell `; try { const contactId = this.executeAppleScript(script); return { success: true, message: `Created contact: ${name}`, contact_id: contactId, contact: { name, organization, job_title, emails, phones, urls, note }, }; } catch (error) { throw new Error(`Create contact failed: ${error}`); } }
  • Input schema definition for the create_contact tool, specifying required 'name' and optional fields for organization, job_title, emails, phones, urls, note.
    { name: 'create_contact', description: 'Create a new contact', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Full name of the contact', }, organization: { type: 'string', description: 'Organization or company name', }, job_title: { type: 'string', description: 'Job title or position', }, emails: { type: 'array', items: { type: 'string' }, description: 'Email addresses', }, phones: { type: 'array', items: { type: 'string' }, description: 'Phone numbers', }, urls: { type: 'array', items: { type: 'object', properties: { label: { type: 'string' }, value: { type: 'string' }, }, required: ['label', 'value'], }, description: 'URLs (social media, websites, etc.) with labels', }, note: { type: 'string', description: 'Notes about the contact', }, }, required: ['name'], }, },
  • src/index.ts:222-224 (registration)
    Dispatches to the createContact handler in the CallToolRequestSchema request handler switch statement.
    case 'create_contact': result = await this.createContact(args); break;

Other Tools

Related 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