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}")
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 states the tool adds contacts to a group (implying a mutation), but doesn't mention permissions required, whether the operation is idempotent, error handling for invalid resource names, or what happens if contacts are already in the group. This leaves significant gaps for a mutation tool.

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 front-loaded with the core purpose in the first sentence, followed by a concise parameter section with examples. Every sentence earns its place, with no redundant or verbose language.

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?

For a mutation tool with no annotations and no output schema, the description is moderately complete: it covers purpose and parameters well, but lacks behavioral details (e.g., side effects, error cases) and return values. Given the complexity, it should do more to compensate for missing structured data.

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?

Schema description coverage is 0%, so the description must compensate. It provides clear parameter names, types (string, array of strings), and example values (e.g., 'contactGroups/12345', ['people/12345']), adding essential meaning beyond the bare schema. However, it doesn't explain where to find these resource names or format constraints.

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 ('add contacts to a contact group') and resource ('contact group'), distinguishing it from siblings like 'remove_contacts_from_group' (opposite action) and 'create_contact_group' (different resource). The parenthetical 'assign a label to contacts' further clarifies the purpose.

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 implies usage when needing to label contacts, but doesn't explicitly state when to use this tool versus alternatives like 'update_contact' (which might modify contact details) or 'search_contacts_by_group' (which retrieves contacts). It provides clear context but lacks explicit exclusions or comparisons.

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