update_contact_group
Modify the name and custom data of an existing contact group in Google Contacts. Use this tool to rename groups or update associated metadata for better organization.
Instructions
Update a contact group's name and custom data.
Args:
resource_name: Contact group resource name (e.g., "contactGroups/12345")
name: New name for the contact group
client_data: Optional updated custom data as list of key-value pairs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| resource_name | Yes | ||
| name | Yes | ||
| client_data | No |
Implementation Reference
- src/tools.py:476-496 (handler)MCP tool handler: async function decorated with @mcp.tool() that initializes the service, calls service.update_contact_group, formats the result, and handles errors.@mcp.tool() async def update_contact_group( resource_name: str, name: str, client_data: List[Dict[str, str]] = None ) -> str: """Update a contact group's name and custom data. Args: resource_name: Contact group resource name (e.g., "contactGroups/12345") name: New name for the contact group client_data: Optional updated custom data as list of key-value pairs """ service = init_service() if not service: return "Error: Google Contacts service is not available. Please check your credentials." try: group = service.update_contact_group(resource_name, name, client_data) return f"Contact group updated successfully!\n\n{format_contact_group(group)}" except Exception as e: return f"Error: Failed to update contact group - {str(e)}"
- Service helper method in GoogleContactsService that performs the Google People API call to update the contact group, handling ETag for concurrency and formatting the response.def update_contact_group( self, resource_name: str, name: str, client_data: Optional[List[Dict[str, str]]] = None ) -> Dict[str, Any]: """Update a contact group's name and client data. Args: resource_name: Contact group resource name name: New name for the contact group client_data: Optional updated client data Returns: Updated contact group dictionary """ try: # Get current group for etag current_group = self.service.contactGroups().get(resourceName=resource_name).execute() contact_group_body = { "contactGroup": { "resourceName": resource_name, "etag": current_group.get("etag"), "name": name, }, "updateGroupFields": "name", } if client_data: contact_group_body["contactGroup"]["clientData"] = client_data contact_group_body["updateGroupFields"] = "name,clientData" response = ( self.service.contactGroups() .update(contactGroup_resourceName=resource_name, body=contact_group_body) .execute() ) return self._format_contact_group(response) except HttpError as error: raise GoogleContactsError(f"Error updating contact group: {error}")
- src/main.py:71-74 (registration)Registration point where the MCP server is created and register_tools(mcp) is called, which in turn calls register_contact_group_tools(mcp) to define/register the update_contact_group tool via decorator.mcp = FastMCP("google-contacts") # Register all tools register_tools(mcp)