Skip to main content
Glama
4tal

MCP Google Contacts Server

by 4tal

get_contact_group

Retrieve detailed information about a specific Google Contacts group, including optional member contact IDs for managing contact organization.

Instructions

Get detailed information about a specific contact group.

    Args:
        resource_name: Contact group resource name (e.g., "contactGroups/12345")
        include_members: Whether to include the list of member contact IDs
        max_members: Maximum number of member IDs to return if include_members is True
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resource_nameYes
include_membersNo
max_membersNo

Implementation Reference

  • The MCP tool handler implementation for 'get_contact_group', decorated with @mcp.tool(). It initializes the service, fetches the group, and formats the output.
    async def get_contact_group(
        resource_name: str, include_members: bool = False, max_members: int = 50
    ) -> str:
        """Get detailed information about a specific contact group.
    
        Args:
            resource_name: Contact group resource name (e.g., "contactGroups/12345")
            include_members: Whether to include the list of member contact IDs
            max_members: Maximum number of member IDs to return if include_members is True
        """
        service = init_service()
        if not service:
            return "Error: Google Contacts service is not available. Please check your credentials."
    
        try:
            max_members_param = max_members if include_members else 0
            group = service.get_contact_group(resource_name, max_members_param)
            return format_contact_group(group)
        except Exception as e:
            return f"Error: Failed to get contact group - {str(e)}"
  • The core service method that performs the actual API call to retrieve contact group details from Google Contacts API.
    def get_contact_group(self, resource_name: str, max_members: int = 0) -> Dict[str, Any]:
        """Get a specific contact group by resource name.
    
        Args:
            resource_name: Contact group resource name (contactGroups/*)
            max_members: Maximum number of members to return (0 for metadata only)
    
        Returns:
            Contact group dictionary with member details
        """
        try:
            params = {}
            if max_members > 0:
                params["maxMembers"] = max_members
    
            response = (
                self.service.contactGroups().get(resourceName=resource_name, **params).execute()
            )
    
            return self._format_contact_group(response, include_members=max_members > 0)
    
        except HttpError as error:
            raise GoogleContactsError(f"Error getting contact group: {error}")
  • Helper function to format the contact group data into a human-readable string, used by the handler.
    def format_contact_group(group: Dict[str, Any]) -> str:
        """Format a contact group dictionary into a readable string.
    
        Args:
            group: Dictionary containing contact group information
    
        Returns:
            Formatted string representation of the contact group
        """
        if not group:
            return "No contact group data available"
    
        parts = []
    
        # Group name and type
        name = group.get("name", "Unnamed Group")
        group_type = group.get("groupType", "").replace("_", " ").title()
        if group_type:
            parts.append("📂 " + name + " (" + group_type + ")")
        else:
            parts.append("📂 " + name)
    
        # Member count
        member_count = group.get("memberCount", 0)
        if member_count > 0:
            parts.append("👥 Members: " + str(member_count))
        else:
            parts.append("👥 Members: None")
    
        # Update time
        if group.get("updateTime"):
            parts.append("🕒 Last Updated: " + group["updateTime"])
    
        # Resource ID
        if group.get("resourceName"):
            parts.append("🔗 ID: " + group["resourceName"])
    
        # Client data
        if group.get("clientData"):
            client_data_parts = []
            for data in group["clientData"]:
                key = data.get("key", "")
                value = data.get("value", "")
                if key and value:
                    client_data_parts.append("   • " + key + ": " + value)
            if client_data_parts:
                parts.append("🔧 Custom Data:\n" + "\n".join(client_data_parts))
    
        # Member resource names (if included)
        if group.get("memberResourceNames"):
            member_names = group["memberResourceNames"]
            if len(member_names) <= 5:
                parts.append("📋 Member IDs: " + ", ".join(member_names))
            else:
                parts.append(
                    "📋 Member IDs: "
                    + ", ".join(member_names[:5])
                    + " ... (and "
                    + str(len(member_names) - 5)
                    + " more)"
                )
    
        return "\n".join(parts)
  • src/tools.py:64-72 (registration)
    Top-level registration function called from main.py that includes registration of contact group tools containing 'get_contact_group'.
    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)
  • src/main.py:74-74 (registration)
    Call in main.py to register all tools via the register_tools function.
    register_tools(mcp)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves 'detailed information' but doesn't specify what that includes (e.g., metadata, permissions), whether it's a read-only operation, error conditions, or rate limits. For a tool with no 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.

Conciseness4/5

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

The description is appropriately sized and front-loaded, starting with the core purpose followed by parameter explanations in a structured format. Every sentence adds value, with no redundant or vague language. However, the parameter section uses a code-like format that slightly disrupts flow, preventing a perfect score.

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 (3 parameters, no output schema, no annotations), the description is minimally adequate. It covers the purpose and parameters but lacks behavioral details (e.g., what 'detailed information' includes, error handling) and usage guidelines. Without an output schema, it should ideally hint at return values, but the parameter explanations help offset this gap.

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

Parameters4/5

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

The description adds meaningful context beyond the input schema, which has 0% description coverage. It explains that resource_name is a 'Contact group resource name' with an example, clarifies include_members as 'Whether to include the list of member contact IDs', and notes max_members applies 'if include_members is True'. This compensates well for the schema's lack of descriptions, though it doesn't detail format constraints (e.g., resource_name pattern).

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get detailed information about a specific contact group.' It specifies the verb ('Get') and resource ('contact group'), and distinguishes it from siblings like list_contact_groups (which lists multiple groups) and get_contact (which gets individual contacts). However, it doesn't explicitly differentiate from search_contacts_by_group, which might overlap in functionality.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a resource_name), exclusions, or comparisons to siblings like list_contact_groups (for listing) or get_contact (for individual contacts). Usage is implied but not explicitly stated.

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