get_other_contacts
Retrieve contacts from Google's 'Other contacts' section to access people you've interacted with but haven't added to your main contacts list, such as email correspondents.
Instructions
Retrieve contacts from the 'Other contacts' section.
Other contacts are people you've interacted with but haven't added to your contacts list.
These often include email correspondents that aren't in your main contacts.
Args:
max_results: Maximum number of results to return (default: 50)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max_results | No |
Implementation Reference
- src/tools.py:383-410 (handler)MCP tool handler for 'get_other_contacts'. Decorated with @mcp.tool() for automatic registration. Fetches other contacts via GoogleContactsService and formats the response as a string.@mcp.tool() async def get_other_contacts(max_results: int = 50) -> str: """Retrieve contacts from the 'Other contacts' section. Other contacts are people you've interacted with but haven't added to your contacts list. These often include email correspondents that aren't in your main contacts. Args: max_results: Maximum number of results to return (default: 50) """ service = init_service() if not service: return "Error: Google Contacts service is not available. Please check your credentials." try: other_contacts = service.get_other_contacts(max_results) if not other_contacts: return "No 'Other contacts' found in your Google account." # Count how many have email addresses with_email = sum(1 for c in other_contacts if c.get("email")) # Format and return the results formatted_list = format_contacts_list(other_contacts) return f"Other Contacts (people you've interacted with but haven't added):\n\n{formatted_list}\n\n{with_email} of these contacts have email addresses." except Exception as e: return f"Error: Failed to retrieve other contacts - {str(e)}"
- src/tools.py:383-383 (registration)The @mcp.tool() decorator registers this function as an MCP tool.@mcp.tool()
- Core implementation in GoogleContactsService class that queries the Google People API for 'Other Contacts' and formats them into a list of dicts.def get_other_contacts(self, max_results: int = 100) -> List[Dict]: """Get contacts from the 'Other contacts' section of Google Contacts. These are contacts that the user has interacted with but has not added to their contacts. Args: max_results: Maximum number of results to return Returns: List of other contact dictionaries """ try: response = ( self.service.otherContacts() .list(readMask="names,emailAddresses,phoneNumbers", pageSize=max_results) .execute() ) other_contacts = response.get("otherContacts", []) if not other_contacts: return [] # Format the results contacts = [] for person in other_contacts: contact = self._format_contact(person) contacts.append(contact) return contacts
- src/tools.py:384-392 (schema)Function signature defines the input schema (max_results: int = 50) and output type (str).async def get_other_contacts(max_results: int = 50) -> str: """Retrieve contacts from the 'Other contacts' section. Other contacts are people you've interacted with but haven't added to your contacts list. These often include email correspondents that aren't in your main contacts. Args: max_results: Maximum number of results to return (default: 50) """