Skip to main content
Glama
4tal

MCP Google Contacts Server

by 4tal

remove_contacts_from_group

Remove specific contacts from a Google Contacts group by unlinking them from the designated label. Specify the group and contact resource names to manage your contact organization.

Instructions

Remove contacts from a contact group (remove a label from contacts).

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
group_resource_nameYes
contact_resource_namesYes

Implementation Reference

  • MCP tool handler that initializes the Google Contacts service and calls the service method to remove specified contacts from a group, returning formatted results or error messages.
    async def remove_contacts_from_group(
        group_resource_name: str, contact_resource_names: List[str]
    ) -> str:
        """Remove contacts from a contact group (remove a label from contacts).
    
        Args:
            group_resource_name: Contact group resource name (e.g., "contactGroups/12345")
            contact_resource_names: List of contact resource names to remove (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.remove_contacts_from_group(group_resource_name, contact_resource_names)
            return format_group_membership_result(result, "remove")
        except Exception as e:
            return f"Error: Failed to remove contacts from group - {str(e)}"
  • Core service method implementing the removal of contacts from a contact group via the Google People API contactGroups.members.modify endpoint, handling API response and errors.
    def remove_contacts_from_group(
        self, group_resource_name: str, contact_resource_names: List[str]
    ) -> Dict[str, Any]:
        """Remove contacts from a contact group.
    
        Args:
            group_resource_name: Contact group resource name
            contact_resource_names: List of contact resource names to remove
    
        Returns:
            Result dictionary with any errors
        """
        try:
            modify_body = {"resourceNamesToRemove": contact_resource_names}
    
            response = (
                self.service.contactGroups()
                .members()
                .modify(resourceName=group_resource_name, body=modify_body)
                .execute()
            )
    
            return {
                "success": True,
                "removed_count": len(contact_resource_names),
                "not_found": response.get("notFoundResourceNames", []),
                "could_not_remove": response.get("canNotRemoveLastContactGroupResourceNames", []),
            }
    
        except HttpError as error:
            raise GoogleContactsError(f"Error removing contacts from group: {error}")
  • src/tools.py:64-75 (registration)
    Registration function that calls register_contact_group_tools(mcp), which defines and registers the remove_contacts_from_group tool via @mcp.tool() decorator.
    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)
    
    
    def register_contact_tools(mcp: FastMCP) -> None:
  • src/main.py:94-96 (registration)
    Entry point that initializes FastMCP and calls register_tools(mcp) to register all tools including remove_contacts_from_group.
    if __name__ == "__main__":
        main()

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