Skip to main content
Glama

MCP Google Contacts Server

by RayanZaki

search_contacts

Locate specific contacts by searching with a name, email, or phone number query using this tool to retrieve up to a defined maximum number of results.

Instructions

Search contacts by name, email, or phone number.

Args: query: Search term to find in contacts max_results: Maximum number of results to return (default: 10)

Input Schema

NameRequiredDescriptionDefault
max_resultsNo
queryYes

Input Schema (JSON Schema)

{ "properties": { "max_results": { "default": 10, "title": "Max Results", "type": "integer" }, "query": { "title": "Query", "type": "string" } }, "required": [ "query" ], "title": "search_contactsArguments", "type": "object" }

Implementation Reference

  • Handler function for the 'search_contacts' tool. Decorated with @mcp.tool() for registration. Fetches contacts via service and performs local fuzzy search on name, email, phone fields.
    @mcp.tool() async def search_contacts(query: str, max_results: int = 10) -> str: """Search contacts by name, email, or phone number. Args: query: Search term to find in contacts max_results: Maximum number of results to return (default: 10) """ service = init_service() if not service: return "Error: Google Contacts service is not available. Please check your credentials." try: # Get all contacts and filter locally with more flexible search all_contacts = service.list_contacts(max_results=max(100, max_results*2)) query = query.lower() matches = [] for contact in all_contacts: if (query in contact.get('displayName', '').lower() or query in contact.get('givenName', '').lower() or query in contact.get('familyName', '').lower() or query in str(contact.get('email', '')).lower() or query in str(contact.get('phone', '')).lower()): matches.append(contact) if len(matches) >= max_results: break if not matches: return f"No contacts found matching '{query}'." return f"Search results for '{query}':\n\n{format_contacts_list(matches)}" except Exception as e: return f"Error: Failed to search contacts - {str(e)}"
  • Invocation of register_tools(mcp) which defines and registers the search_contacts handler along with other tools.
    register_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/RayanZaki/mcp-google-contacts-server'

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