Skip to main content
Glama
marissamarym

iMessage MCP Server

by marissamarym

search_contacts

Find contacts in your macOS Contacts app by searching names, phone numbers, or email addresses using natural language queries.

Instructions

Search contacts by name, phone, or email

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query

Implementation Reference

  • Handler for the search_contacts tool: extracts query, runs AppleScript to search Contacts app for matching names, formats results as JSON, and returns them.
    case "search_contacts": {
      const query = String(request.params.arguments?.query).toLowerCase();
    
      const script = `
        tell application "Contacts"
          set output to "["
          set isFirst to true
          repeat with p in every person
            if ((name of p as text) contains "${query}") then
              if not isFirst then
                set output to output & ","
              end if
              set output to output & "{"
              set output to output & "\\"name\\":\\"" & (name of p as text) & "\\","
              set output to output & "\\"phones\\":["
              set firstPhone to true
              repeat with ph in phones of p
                if not firstPhone then
                  set output to output & ","
                end if
                set output to output & "\\"" & (value of ph) & "\\""
                set firstPhone to false
              end repeat
              set output to output & "],"
              set output to output & "\\"emails\\":["
              set firstEmail to true
              repeat with em in emails of p
                if not firstEmail then
                  set output to output & ","
                end if
                set output to output & "\\"" & (value of em) & "\\""
                set firstEmail to false
              end repeat
              set output to output & "]"
              set output to output & "}"
              set isFirst to false
            end if
          end repeat
          return output & "]"
        end tell
      `;
    
      try {
        const results = await runAppleScript(script);
        return {
          content: [
            {
              type: "text",
              text: results,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Search failed: ${getErrorMessage(error)}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema defining the 'query' parameter as a required string for searching contacts.
    inputSchema: {
      type: "object",
      properties: {
        query: {
          type: "string",
          description: "Search query",
        },
      },
      required: ["query"],
    },
  • src/index.ts:141-154 (registration)
    Registration of the search_contacts tool in the ListTools response, providing name, description, and input schema.
    {
      name: "search_contacts",
      description: "Search contacts by name, phone, or email",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Search query",
          },
        },
        required: ["query"],
      },
    },
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 the search functionality but doesn't describe behavioral traits like whether it's read-only, how results are returned (e.g., pagination, format), error handling, or any limitations (e.g., rate limits, authentication needs). This leaves significant gaps for an agent to understand how to use it effectively.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without any wasted words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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 lack of annotations and output schema, the description is incomplete. It covers the basic purpose and parameters but fails to address behavioral aspects like result format, error conditions, or usage context. For a search tool with no structured behavioral data, more detail is needed to ensure the agent can invoke it correctly.

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 input schema has 100% description coverage, with one parameter 'query' documented as 'Search query'. The description adds value by specifying what the query searches ('by name, phone, or email'), which provides context beyond the schema. However, it doesn't detail syntax, examples, or constraints, so it meets the baseline for high schema coverage.

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 with a specific verb ('search') and resource ('contacts'), and specifies the searchable fields (name, phone, or email). However, it doesn't explicitly differentiate from the sibling tool 'send_imessage', which appears unrelated but context isn't provided for comparison.

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 or in what context. It simply states what the tool does without mentioning any prerequisites, exclusions, or scenarios where it's preferred over other methods.

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

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