Skip to content

iMessage Desktop Extension: search_contacts times out with large contact databases #175

@alexwb72

Description

@alexwb72

Summary: The search_contacts tool in the verified iMessage extension hangs indefinitely and times out after 4 minutes for users with large contact lists.

Environment:
Claude Desktop (latest)
macOS
Verified iMessage extension from the Extensions directory
Contact database size: ~10,000 contacts

Steps to reproduce:
Install the iMessage extension
Have a large Contacts database (10,000+ contacts)
Ask Claude to search for a contact

Expected behavior: Search returns results within a few seconds

Actual behavior: Request times out after 4 minutes with MCP error -32001

Root cause: The AppleScript in server/index.js (line ~643) iterates through every contact with a repeat with p in every person loop and performs string comparisons. This is O(n) and extremely slow for large databases.

Log evidence:
2026-01-02T22:57:54.949Z [Read and Send iMessages] [info] Message from client: {"method":"tools/call","params":{"name":"search_contacts","arguments":{"query":"John"}},...}
2026-01-02T23:01:54.954Z [Read and Send iMessages] [info] Message from client: {"jsonrpc":"2.0","method":"notifications/cancelled","params":{"requestId":16,"reason":"McpError: MCP error -32001: Request timed out"}}

Suggested fix: Replace the loop-based search with Contacts' native whose filter:
applescripttell application "Contacts"
set matchingPeople to every person whose name contains "query"
-- then iterate only over matchingPeople
end tell
This delegates filtering to the Contacts app and is nearly instant regardless of database size.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions