Skip to main content
Glama
4tal

MCP Google Contacts Server

by 4tal

add_contacts_to_group

Assign labels to Google Contacts by adding them to contact groups for better organization and management.

Instructions

Add contacts to a contact group (assign a label to contacts).

Args: group_resource_name: Contact group resource name (e.g., "contactGroups/12345") contact_resource_names: List of contact resource names to add (e.g., ["people/12345", "people/67890"])

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
group_resource_nameYes
contact_resource_namesYes

Implementation Reference

  • MCP tool handler function for 'add_contacts_to_group'. Decorated with @mcp.tool() for registration. Initializes service and calls the underlying service method to perform the operation.
    @mcp.tool() async def add_contacts_to_group( group_resource_name: str, contact_resource_names: List[str] ) -> str: """Add contacts to a contact group (assign a label to contacts). Args: group_resource_name: Contact group resource name (e.g., "contactGroups/12345") contact_resource_names: List of contact resource names to add (e.g., ["people/12345", "people/67890"]) """ service = init_service() if not service: return "Error: Google Contacts service is not available. Please check your credentials." try: result = service.add_contacts_to_group(group_resource_name, contact_resource_names) return format_group_membership_result(result, "add") except Exception as e: return f"Error: Failed to add contacts to group - {str(e)}"
  • Core service implementation that interacts with Google Contacts API to add contacts to a group using the contactGroups.members.modify endpoint.
    def add_contacts_to_group( self, group_resource_name: str, contact_resource_names: List[str] ) -> Dict[str, Any]: """Add contacts to a contact group. Args: group_resource_name: Contact group resource name contact_resource_names: List of contact resource names to add Returns: Result dictionary with any errors """ try: modify_body = {"resourceNamesToAdd": contact_resource_names} response = ( self.service.contactGroups() .members() .modify(resourceName=group_resource_name, body=modify_body) .execute() ) return { "success": True, "added_count": len(contact_resource_names), "not_found": response.get("notFoundResourceNames", []), "could_not_add": response.get("canNotRemoveLastContactGroupResourceNames", []), } except HttpError as error: raise GoogleContactsError(f"Error adding contacts to group: {error}")

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