Skip to main content
Glama
RayanZaki

MCP Google Contacts Server

by RayanZaki

get_contact

Retrieve a Google Contacts entry using a resource name or email address to access contact details from your Google account.

Instructions

Get a contact by resource name or email.

    Args:
        identifier: Resource name (people/*) or email address of the contact
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
identifierYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main MCP tool handler for 'get_contact'. This async function is decorated with @mcp.tool() for automatic registration. It initializes the GoogleContactsService, calls service.get_contact(identifier), formats the contact with format_contact, and returns the formatted string or an error message.
    @mcp.tool()
    async def get_contact(identifier: str) -> str:
        """Get a contact by resource name or email.
        
        Args:
            identifier: Resource name (people/*) or email address of the contact
        """
        service = init_service()
        if not service:
            return "Error: Google Contacts service is not available. Please check your credentials."
        
        try:
            contact = service.get_contact(identifier)
            return format_contact(contact)
        except Exception as e:
            return f"Error: Failed to get contact - {str(e)}"
  • Core helper method in GoogleContactsService that implements the contact retrieval logic using Google People API v1. Handles both resourceName lookups and email-based searches (falling back to directory if enabled). Returns formatted contact dict or raises error.
    def get_contact(self, identifier: str, include_email: bool = True, 
                   use_directory_api: bool = False) -> Dict[str, Any]:
        """Get a contact by resource name or email.
        
        Args:
            identifier: Resource name (people/*) or email address
            include_email: Whether to include email addresses
            use_directory_api: Whether to try the directory API as well
            
        Returns:
            Contact dictionary
            
        Raises:
            GoogleContactsError: If contact cannot be found or API request fails
        """
        try:
            if identifier.startswith('people/'):
                # Determine which API to use based on parameters
                if use_directory_api:
                    # For directory contacts
                    try:
                        person = self.service.people().people().get(
                            resourceName=identifier,
                            personFields='names,emailAddresses,phoneNumbers,organizations'
                        ).execute()
                    except HttpError:
                        # Fall back to standard contacts API if directory API fails
                        person = self.service.people().get(
                            resourceName=identifier,
                            personFields='names,emailAddresses,phoneNumbers'
                        ).execute()
                else:
                    # Standard contacts API
                    person = self.service.people().get(
                        resourceName=identifier,
                        personFields='names,emailAddresses,phoneNumbers'
                    ).execute()
                
                return self._format_contact(person)
            else:
                # Assume it's an email address and search for it
                contacts = self.list_contacts()
                for contact in contacts:
                    if contact.get('email') == identifier:
                        return contact
                
                # If not found in regular contacts, try directory
                if use_directory_api:
                    directory_users = self.list_directory_people(query=identifier, max_results=1)
                    if directory_users:
                        return directory_users[0]
                
                raise GoogleContactsError(f"Contact with email {identifier} not found")
        
        except HttpError as error:
            raise GoogleContactsError(f"Error getting contact: {error}")
  • In main.py, register_tools(mcp) is called on the FastMCP server instance. This invokes the register_tools function from tools.py, which defines the get_contact handler with @mcp.tool() decorator, thereby registering the tool.
    # Register all tools
    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 a contact but doesn't describe what happens if the contact isn't found (e.g., error handling), authentication needs, rate limits, or the format of the output. For a read operation with zero annotation coverage, this leaves significant gaps in understanding the tool's 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, with the core purpose stated clearly in the first sentence. The additional parameter explanation is concise and directly relevant. There's no wasted text, though the structure could be slightly improved by integrating the parameter details more seamlessly.

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 low complexity (single parameter, read operation) and the presence of an output schema, the description is somewhat complete but has gaps. It covers the basic purpose and parameter semantics adequately, but without annotations, it lacks behavioral details like error handling. The output schema likely explains return values, reducing the burden on the description.

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 the 'identifier' parameter can be either a resource name (people/*) or an email address, clarifying the two valid input types. This compensates well for the schema's lack of detail, though it doesn't specify format constraints or examples.

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 a contact by resource name or email.' It specifies the verb ('Get') and resource ('contact'), and distinguishes it from siblings like list_contacts or search_contacts by focusing on retrieving a single contact. However, it doesn't explicitly differentiate from get_other_contacts, which might have overlapping 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. With siblings like list_contacts, search_contacts, and get_other_contacts, there's no indication of when this specific retrieval method is preferred, such as for known identifiers versus broader searches. It lacks context on prerequisites or exclusions.

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/RayanZaki/mcp-google-contacts-server'

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