Skip to main content
Glama
carterlasalle

mac-messages-mcp

tool_find_contact

Search for contacts by name with fuzzy matching to locate message recipients in macOS Messages.

Instructions

Find a contact by name using fuzzy matching.

Args:
    name: The name to search for

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Implementation Reference

  • The primary handler for the 'tool_find_contact' tool. Decorated with @mcp.tool() for registration. Performs fuzzy contact search by calling the helper function, handles errors, and formats single or multiple match results.
    @mcp.tool()
    def tool_find_contact(ctx: Context, name: str) -> str:
        """
        Find a contact by name using fuzzy matching.
        
        Args:
            name: The name to search for
        """
        logger.info(f"Finding contact: {name}")
        try:
            matches = find_contact_by_name(name)
            
            if not matches:
                return f"No contacts found matching '{name}'."
            
            if len(matches) == 1:
                contact = matches[0]
                return f"Found contact: {contact['name']} ({contact['phone']}) with confidence {contact['score']:.2f}"
            else:
                # Format multiple matches
                result = [f"Found {len(matches)} contacts matching '{name}':"]
                for i, contact in enumerate(matches[:10]):  # Limit to top 10
                    result.append(f"{i+1}. {contact['name']} ({contact['phone']}) - confidence {contact['score']:.2f}")
                
                if len(matches) > 10:
                    result.append(f"...and {len(matches) - 10} more.")
                
                return "\n".join(result)
        except Exception as e:
            logger.error(f"Error in find_contact: {str(e)}")
            return f"Error finding contact: {str(e)}"
  • Key helper function implementing the fuzzy contact matching logic. Uses cached contacts from AddressBook, applies fuzzy_match utility, and returns scored contact matches used by the tool handler.
    def find_contact_by_name(name: str) -> List[Dict[str, Any]]:
        """
        Find contacts by name using fuzzy matching.
        
        Args:
            name: The name to search for
        
        Returns:
            List of matching contacts (may be multiple if ambiguous)
        """
        contacts = get_cached_contacts()
        
        # Build a list of (name, phone) pairs to search through
        candidates = [(contact_name, phone) for phone, contact_name in contacts.items()]
        
        # Perform fuzzy matching
        matches = fuzzy_match(name, candidates)
        
        # Convert to a list of contact dictionaries
        results = []
        for contact_name, phone, score in matches:
            results.append({
                "name": contact_name,
                "phone": phone,
                "score": score
            })
        
        return results
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 mentions 'fuzzy matching,' which hints at approximate search behavior, but fails to detail critical aspects like error handling, permissions needed, rate limits, or what happens if no matches are found. For a search tool with zero annotation coverage, this is a significant gap in transparency.

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 first. The two-sentence structure is efficient, and the 'Args:' section adds clarity without redundancy. While it could be slightly more detailed, it avoids unnecessary verbosity, earning a high score for conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a search operation), lack of annotations, and no output schema, the description is incomplete. It doesn't explain return values, error cases, or behavioral nuances like how 'fuzzy matching' works. This leaves gaps that could hinder an AI agent's ability to use the tool effectively, especially compared to more comprehensive descriptions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal semantics beyond the input schema. It explains that 'name' is 'The name to search for,' which clarifies the parameter's purpose. However, with 0% schema description coverage and only one parameter, this is adequate but not exceptional. The baseline for a single parameter with low coverage is met, but no additional details like format or constraints are provided.

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: 'Find a contact by name using fuzzy matching.' It specifies the verb ('Find'), resource ('contact'), and method ('fuzzy matching'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'tool_check_contacts' or 'tool_fuzzy_search_messages', which prevents a perfect score.

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. It doesn't mention sibling tools like 'tool_check_contacts' or 'tool_fuzzy_search_messages', nor does it specify prerequisites, exclusions, or contextual cues for selection. This lack of comparative information limits its utility for an AI agent.

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/carterlasalle/mac_messages_mcp'

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