list_contact_groups
Retrieve all contact groups (labels) from Google Contacts to organize contacts into categories like Family, Work, or Friends. Optionally include system groups such as My Contacts.
Instructions
List all contact groups (labels) in your Google Contacts.
Contact groups are like labels that help you organize your contacts into categories
such as 'Family', 'Work', 'Friends', etc.
Args:
include_system_groups: Whether to include system groups like "My Contacts", "Starred", etc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| include_system_groups | No |
Implementation Reference
- src/tools.py:416-435 (handler)MCP tool handler: async function decorated with @mcp.tool() that initializes the service, calls service.list_contact_groups(), formats the result, and handles errors.@mcp.tool() async def list_contact_groups(include_system_groups: bool = True) -> str: """List all contact groups (labels) in your Google Contacts. Contact groups are like labels that help you organize your contacts into categories such as 'Family', 'Work', 'Friends', etc. Args: include_system_groups: Whether to include system groups like "My Contacts", "Starred", etc. """ service = init_service() if not service: return "Error: Google Contacts service is not available. Please check your credentials." try: groups = service.list_contact_groups(include_system_groups) return format_contact_groups_list(groups) except Exception as e: return f"Error: Failed to list contact groups - {str(e)}"
- src/tools.py:72-72 (registration)Call to register_contact_group_tools(mcp) within register_tools, which defines and registers the tool via nested @mcp.tool() decorators.register_contact_group_tools(mcp)
- Core service method in GoogleContactsService class that calls the Google Contacts API to list groups, filters system groups if requested, formats them, and returns the list.def list_contact_groups(self, include_system_groups: bool = True) -> List[Dict[str, Any]]: """List all contact groups owned by the authenticated user. Args: include_system_groups: Whether to include system contact groups Returns: List of contact group dictionaries """ try: response = self.service.contactGroups().list().execute() contact_groups = response.get("contactGroups", []) if not include_system_groups: contact_groups = [ group for group in contact_groups if group.get("groupType") == "USER_CONTACT_GROUP" ] formatted_groups = [] for group in contact_groups: formatted_group = self._format_contact_group(group) formatted_groups.append(formatted_group) return formatted_groups