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
- The main MCP tool handler function for 'get_other_contacts'. It initializes the GoogleContactsService, calls the service method, formats the results using format_contacts_list, counts contacts with emails, and returns a formatted string response.@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)}"
- mcp_google_contacts_server/main.py:84-84 (registration)The call to register_tools(mcp) in the main server function, which registers all tools including 'get_other_contacts' via the @mcp.tool() decorators defined in tools.py.register_tools(mcp)
- The GoogleContactsService.get_other_contacts method that implements the core logic by calling the Google People API otherContacts().list() endpoint, formats the results, and returns a list of contact dictionaries.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 except HttpError as error: raise Exception(f"Error getting other contacts: {error}")