Skip to main content
Glama
4tal

MCP Google Contacts Server

by 4tal

get_contact

Retrieve Google Contacts information by resource name or email address, including comprehensive contact details and fields.

Instructions

Get a contact by resource name or email with comprehensive information.

Args: identifier: Resource name (people/*) or email address of the contact include_all_fields: Whether to include all contact fields (default: True)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
identifierYes
include_all_fieldsNo

Implementation Reference

  • MCP tool handler implementation for 'get_contact'. Uses @mcp.tool() decorator for automatic registration. Fetches contact details via GoogleContactsService and formats the output.
    @mcp.tool() async def get_contact(identifier: str, include_all_fields: bool = True) -> str: """Get a contact by resource name or email with comprehensive information. Args: identifier: Resource name (people/*) or email address of the contact include_all_fields: Whether to include all contact fields (default: True) """ service = init_service() if not service: return "Error: Google Contacts service is not available. Please check your credentials." try: contact = service.get_contact(identifier, include_all_fields) 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 Google People API call to retrieve a contact by resource name or email address, with support for full or limited fields, and enhanced formatting.
    def get_contact(self, identifier: str, include_all_fields: bool = True) -> Dict[str, Any]: """Get a contact by resource name or email with comprehensive field support. Args: identifier: Resource name (people/*) or email address include_all_fields: Whether to include all available fields Returns: Contact dictionary with comprehensive information """ try: person_fields = ( ",".join(self.PERSON_FIELDS) if include_all_fields else "names,emailAddresses,phoneNumbers,addresses,organizations" ) if identifier.startswith("people/"): # Get by resource name person = ( self.service.people() .get(resourceName=identifier, personFields=person_fields) .execute() ) return self._format_contact_enhanced(person) else: # Search by email contacts = self.search_contacts(identifier, max_results=1) if contacts: return contacts[0] raise GoogleContactsError(f"Contact with identifier {identifier} not found") except HttpError as error: raise GoogleContactsError(f"Error getting contact: {error}")
  • src/tools.py:64-73 (registration)
    Top-level registration function that calls register_contact_tools(mcp), where the get_contact handler is defined and registered via @mcp.tool() decorator.
    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)

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