Skip to main content
Glama
4tal

MCP Google Contacts Server

by 4tal

update_contact

Modify existing Google Contacts entries by updating fields like name, email, phone, address, job title, birthday, and notes to keep contact information current.

Instructions

Update an existing contact with comprehensive field support.

Args: resource_name: Contact resource name (people/*) given_name: Updated first name family_name: Updated last name email: Updated email address phone: Updated phone number organization: Updated company/organization name job_title: Updated job title or position address: Updated physical address birthday: Updated birthday in YYYY-MM-DD format website: Updated website URL notes: Updated notes or biography nickname: Updated nickname

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resource_nameYes
given_nameNo
family_nameNo
emailNo
phoneNo
organizationNo
job_titleNo
addressNo
birthdayNo
websiteNo
notesNo
nicknameNo

Implementation Reference

  • The handler function for the 'update_contact' MCP tool. It collects optional field updates into a contact_data dict and delegates to the GoogleContactsService.update_contact method.
    @mcp.tool() async def update_contact( resource_name: str, given_name: Optional[str] = None, family_name: Optional[str] = None, email: Optional[str] = None, phone: Optional[str] = None, organization: Optional[str] = None, job_title: Optional[str] = None, address: Optional[str] = None, birthday: Optional[str] = None, website: Optional[str] = None, notes: Optional[str] = None, nickname: Optional[str] = None, ) -> str: """Update an existing contact with comprehensive field support. Args: resource_name: Contact resource name (people/*) given_name: Updated first name family_name: Updated last name email: Updated email address phone: Updated phone number organization: Updated company/organization name job_title: Updated job title or position address: Updated physical address birthday: Updated birthday in YYYY-MM-DD format website: Updated website URL notes: Updated notes or biography nickname: Updated nickname """ service = init_service() if not service: return "Error: Google Contacts service is not available. Please check your credentials." try: contact_data = {} # Add fields that are being updated if given_name is not None: contact_data["given_name"] = given_name if family_name is not None: contact_data["family_name"] = family_name if email is not None: contact_data["email"] = email if phone is not None: contact_data["phone"] = phone if organization is not None: contact_data["organization"] = organization if job_title is not None: contact_data["job_title"] = job_title if address is not None: contact_data["address"] = address if birthday is not None: contact_data["birthday"] = birthday if website is not None: contact_data["website"] = website if notes is not None: contact_data["notes"] = notes if nickname is not None: contact_data["nickname"] = nickname if not contact_data: return "Error: No fields provided for update." contact = service.update_contact(resource_name, contact_data) return f"Contact updated successfully!\n\n{format_contact(contact)}" except Exception as e: return f"Error: Failed to update contact - {str(e)}"
  • Core service helper method that handles the Google People API updateContact call, including building the request body from contact_data, determining update fields, and formatting the response.
    def update_contact(self, resource_name: str, contact_data: Dict[str, Any]) -> Dict[str, Any]: """Update an existing contact with comprehensive field support. Args: resource_name: Contact resource name contact_data: Dictionary containing updated contact information Returns: Updated contact dictionary """ try: # Get current contact for etag current_person = ( self.service.people() .get(resourceName=resource_name, personFields=",".join(self.PERSON_FIELDS)) .execute() ) etag = current_person.get("etag") # Build update body using the same logic as create update_body = self._build_contact_body(contact_data, current_person) update_body["etag"] = etag update_body["resourceName"] = resource_name # Map input fields to API fields for updatePersonFields field_mapping = { "given_name": "names", "family_name": "names", "nickname": "nicknames", "email": "emailAddresses", "emails": "emailAddresses", "phone": "phoneNumbers", "phones": "phoneNumbers", "address": "addresses", "addresses": "addresses", "organization": "organizations", "job_title": "organizations", "birthday": "birthdays", "website": "urls", "urls": "urls", "notes": "biographies", "relations": "relations", "events": "events", "custom_fields": "userDefined", } # Determine which API fields to update based on input update_fields = set() for input_field in contact_data.keys(): if input_field in field_mapping: update_fields.add(field_mapping[input_field]) if not update_fields: return self._format_contact_enhanced(current_person) # Execute update updated_person = ( self.service.people() .updateContact( resourceName=resource_name, updatePersonFields=",".join(update_fields), body=update_body, ) .execute() ) return self._format_contact_enhanced(updated_person) except HttpError as error:
  • src/main.py:74-75 (registration)
    Call to register_tools(mcp) in main.py, which triggers registration of all tools including update_contact via chained register_contact_tools(mcp).
    register_tools(mcp)
  • src/tools.py:64-73 (registration)
    Top-level registration function that calls register_contact_tools(mcp), where the update_contact tool is defined and registered.
    def register_tools(mcp: FastMCP) -> None: """Register all Google Contacts tools with the MCP server. Args: mcp: FastMCP server instance """ register_contact_tools(mcp) register_directory_tools(mcp) register_contact_group_tools(mcp)
  • src/tools.py:75-76 (registration)
    Function that defines and registers the update_contact handler using nested @mcp.tool() decorator (excerpt shows beginning; full function spans to line 338).
    def register_contact_tools(mcp: FastMCP) -> None: """Register contact management tools with the MCP server."""

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/4tal/mcp-google-contacts'

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