Skip to main content
Glama
RayanZaki

MCP Google Contacts Server

by RayanZaki

update_contact

Modify existing Google Contacts by updating names, email addresses, or phone numbers to keep contact information current and accurate.

Instructions

Update an existing contact.

    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
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resource_nameYes
given_nameNo
family_nameNo
emailNo
phoneNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary MCP tool handler for the 'update_contact' tool. This async function is decorated with @mcp.tool(), which registers it with the MCP server. It initializes the GoogleContactsService, calls the service's update_contact method, formats the result using format_contact, and returns a success or error message.
    @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) -> str:
        """Update an existing contact.
        
        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
        """
        service = init_service()
        if not service:
            return "Error: Google Contacts service is not available. Please check your credentials."
        
        try:
            contact = service.update_contact(
                resource_name,
                given_name,
                family_name,
                email,
                phone
            )
            return f"Contact updated successfully!\n\n{format_contact(contact)}"
        except Exception as e:
            return f"Error: Failed to update contact - {str(e)}"
  • Supporting helper method in the GoogleContactsService class that performs the actual API interaction to update a contact. It fetches the current contact, prepares the update body and fields mask, and calls the Google People API's updateContact method.
    def update_contact(self, resource_name: str, given_name: Optional[str] = None, 
                      family_name: Optional[str] = None, email: Optional[str] = None,
                      phone: Optional[str] = None) -> Dict:
        """Update an existing contact."""
        try:
            # Get the etag for the contact first
            person = self.service.people().get(
                resourceName=resource_name,
                personFields='names,emailAddresses,phoneNumbers'
            ).execute()
            
            etag = person.get('etag')
            
            # Prepare update masks and body
            update_person = {'etag': etag, 'resourceName': resource_name}
            update_fields = []
            
            # Update name if provided
            if given_name or family_name:
                current_name = person.get('names', [{}])[0]
                update_person['names'] = [{
                    'givenName': given_name if given_name is not None else current_name.get('givenName', ''),
                    'familyName': family_name if family_name is not None else current_name.get('familyName', '')
                }]
                update_fields.append('names')
            
            # Update email if provided
            if email:
                update_person['emailAddresses'] = [{'value': email}]
                update_fields.append('emailAddresses')
            
            # Update phone if provided
            if phone:
                update_person['phoneNumbers'] = [{'value': phone}]
                update_fields.append('phoneNumbers')
            
            # Execute update
            if update_fields:
                updated_person = self.service.people().updateContact(
                    resourceName=resource_name,
                    updatePersonFields=','.join(update_fields),
                    body=update_person
                ).execute()
                
                return self._format_contact(updated_person)
            else:
                return self._format_contact(person)
        
        except HttpError as error:
            raise GoogleContactsError(f"Error updating contact: {error}")
  • The call to register_tools(mcp) in the main server setup, which defines and registers all tools including update_contact via @mcp.tool() decorators inside the register_tools function.
    # Register all tools
    register_tools(mcp)
  • The docstring providing the input schema/parameter descriptions for the update_contact tool, used by MCP for tool schema generation.
    """Update an existing contact.
    
    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
    """
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. It states this is an update operation, implying mutation, but doesn't mention permissions, reversibility, error handling, or rate limits. The description adds minimal behavioral context beyond the basic action, which is insufficient for a mutation tool without annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence, followed by a structured parameter list. It avoids unnecessary fluff, though the parameter explanations are minimal and could be more informative without sacrificing brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (mutation with 5 parameters), no annotations, and an output schema (which reduces the need to describe return values), the description is partially complete. It covers the basic action and parameters but lacks critical context like usage guidelines, behavioral details, and parameter nuances, making it adequate but with clear gaps.

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?

Schema description coverage is 0%, so the description must compensate. It lists all 5 parameters with brief explanations (e.g., 'Updated first name'), adding some meaning beyond the schema's titles. However, it doesn't clarify format expectations (e.g., email validation) or the implications of null values, leaving gaps in parameter understanding.

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 verb ('Update') and resource ('an existing contact'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its siblings like 'create_contact' or 'delete_contact' beyond the basic action, missing explicit comparison that would warrant 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 'delete_contact'. It lacks context about prerequisites (e.g., needing an existing contact resource) or exclusions, leaving the agent to infer usage from the tool name alone.

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/RayanZaki/mcp-google-contacts-server'

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