Skip to main content
Glama
4tal

MCP Google Contacts Server

by 4tal

search_contacts_by_group

Find contacts within a specific Google Contacts group by providing the group resource name to filter and organize your contact list.

Instructions

Find all contacts that belong to a specific contact group.

    This is useful for seeing which contacts have a particular label assigned.

    Args:
        group_resource_name: Contact group resource name (e.g., "contactGroups/12345")
        max_results: Maximum number of contacts to return
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
group_resource_nameYes
max_resultsNo

Implementation Reference

  • Core handler function for the 'search_contacts_by_group' tool. It uses the Google Contacts service to retrieve group members and their contact details, then formats and returns the list.
    @mcp.tool()
    async def search_contacts_by_group(group_resource_name: str, max_results: int = 50) -> str:
        """Find all contacts that belong to a specific contact group.
    
        This is useful for seeing which contacts have a particular label assigned.
    
        Args:
            group_resource_name: Contact group resource name (e.g., "contactGroups/12345")
            max_results: Maximum number of contacts to return
        """
        service = init_service()
        if not service:
            return "Error: Google Contacts service is not available. Please check your credentials."
    
        try:
            # Get the group with member resource names
            group = service.get_contact_group(group_resource_name, max_results)
    
            if not group.get("memberResourceNames"):
                return f"No contacts found in group '{group.get('name', 'Unknown Group')}'"
    
            # Get full contact details for each member
            member_contacts = []
            for member_resource_name in group["memberResourceNames"]:
                try:
                    contact = service.get_contact(member_resource_name, include_all_fields=False)
                    member_contacts.append(contact)
                except Exception:
                    # Skip contacts that can't be retrieved
                    continue
    
            if not member_contacts:
                return (
                    f"No accessible contacts found in group '{group.get('name', 'Unknown Group')}'"
                )
    
            group_name = group.get("name", "Unknown Group")
            return f"Contacts in group '{group_name}':\n\n{format_contacts_list(member_contacts)}"
        except Exception as e:
            return f"Error: Failed to search contacts by group - {str(e)}"
  • src/main.py:73-74 (registration)
    Calls register_tools(mcp) which registers the search_contacts_by_group tool (along with others) to the MCP server.
    # Register all tools
    register_tools(mcp)
  • src/tools.py:70-72 (registration)
    The register_tools function calls register_contact_group_tools(mcp), where the search_contacts_by_group tool is defined and registered via @mcp.tool() decorator.
    register_contact_tools(mcp)
    register_directory_tools(mcp)
    register_contact_group_tools(mcp)
  • Helper function used by the tool to format the list of contacts retrieved from the group.
    def format_contacts_list(contacts: List[Dict[str, Any]]) -> str:
        """Format a list of contacts into a readable string with enhanced display.
    
        Args:
            contacts: List of contact dictionaries
    
        Returns:
            Formatted string representation of the contacts list
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 describes the basic function but lacks critical details: it doesn't mention whether this is a read-only operation, what permissions are required, how results are returned (e.g., pagination), or potential rate limits. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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

Conciseness5/5

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

The description is appropriately sized and front-loaded: the first sentence states the core purpose, the second adds useful context, and the Args section efficiently documents parameters. Every sentence earns its place without redundancy, and the structure (purpose, context, parameters) is logical and easy to parse.

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 moderate complexity (2 parameters, no annotations, no output schema), the description is partially complete. It covers the purpose and parameters well but lacks behavioral details (e.g., read/write nature, error handling) and output information. Without annotations or an output schema, the description should do more to explain what the tool returns and its operational constraints.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds substantial meaning beyond the input schema, which has 0% description coverage. It explains both parameters: 'group_resource_name' is clarified with an example ('e.g., "contactGroups/12345"'), and 'max_results' is described as limiting the return count. This fully compensates for the schema's lack of descriptions, making the parameters clear and actionable.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Find all contacts') and resource ('that belong to a specific contact group'), distinguishing it from siblings like 'list_contacts' (general listing) and 'search_contacts' (general search). The second sentence reinforces this by explaining the purpose ('seeing which contacts have a particular label assigned'), making the tool's scope explicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('Find all contacts that belong to a specific contact group') and implies an alternative use case ('useful for seeing which contacts have a particular label assigned'). However, it does not explicitly state when not to use it or name specific alternatives among siblings, such as 'list_contacts' for unfiltered listing or 'search_contacts' for broader searches.

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/4tal/mcp-google-contacts'

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