Skip to main content
Glama
viraatdas

iMessage MCP Server

by viraatdas

search_messages

Find specific text across all iMessage conversations by searching message history with a query string.

Instructions

Search across all iMessage conversations for messages containing a query string.

Args: query: Text to search for (case-insensitive) limit: Max results to return (default 30)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Implementation of the search_messages tool, which queries the iMessage SQLite database for messages containing a specific query string.
    @mcp.tool()
    async def search_messages(
        query: str,
        limit: int = 30,
    ) -> str:
        """Search across all iMessage conversations for messages containing a query string.
    
        Args:
            query: Text to search for (case-insensitive)
            limit: Max results to return (default 30)
        """
        db = _get_db()
        rows = db.execute(
            """
            SELECT
                m.text,
                m.date as apple_date,
                m.is_from_me,
                COALESCE(h.id, 'me') as sender,
                c.chat_identifier,
                c.display_name
            FROM message m
            LEFT JOIN handle h ON h.ROWID = m.handle_id
            LEFT JOIN chat_message_join cmj ON cmj.message_id = m.ROWID
            LEFT JOIN chat c ON c.ROWID = cmj.chat_id
            WHERE m.text LIKE '%' || ? || '%'
            ORDER BY m.date DESC
            LIMIT ?
            """,
            (query, limit),
        ).fetchall()
        db.close()
    
        results = []
        for r in rows:
            results.append(
                {
                    "text": r["text"],
                    "date": _apple_ts_to_iso(r["apple_date"]),
                    "from_me": bool(r["is_from_me"]),
                    "sender": r["sender"] if not r["is_from_me"] else "me",
                    "chat_identifier": r["chat_identifier"] or "",
                    "chat_name": r["display_name"] or "",
                }
            )
        return json.dumps(results, indent=2)
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions case-insensitive matching, which is useful behavioral context. However, it lacks disclosure of other important traits such as whether the operation is read-only, whether it searches archived messages, or any rate limiting.

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 efficiently organized with a clear purpose statement followed by an 'Args:' section. There is no redundant language or filler. The formatting is slightly unconventional but highly scannable, with every line contributing necessary information not present in the schema.

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

Completeness3/5

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

Given the simple 2-parameter structure and presence of an output schema (removing the need to describe return values), the description covers the essential scope and functionality. However, it could be improved by noting query constraints (e.g., minimum length) or explicitly confirming the read-only nature of the search operation.

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

Parameters4/5

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

Schema description coverage is 0% (only titles provided). The description fully compensates by documenting both parameters: 'query' includes semantics (text to search for) and constraints (case-insensitive), while 'limit' includes purpose (max results) and default value (30).

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 states 'Search across all iMessage conversations for messages containing a query string,' providing a specific verb (search), resource (messages), and scope (across all conversations). While it implicitly distinguishes from 'get_messages' by emphasizing global search functionality, it does not explicitly contrast with siblings.

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 offers no guidance on when to use this tool versus alternatives like 'get_messages' (likely for retrieving specific conversation history) or 'list_conversations'. There are no explicit when-to-use or when-not-to-use conditions.

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/viraatdas/imessage-mcp'

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