Skip to main content
Glama

messages

Manage Apple Messages app interactions: send, read, schedule messages, and check unread messages directly from the MCP server for automated communication tasks.

Instructions

Interact with Apple Messages app - send, read, schedule messages and check unread messages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of messages to read (optional, for read and unread operations)
messageNoMessage to send (required for send and schedule operations)
operationYesOperation to perform: 'send', 'read', 'schedule', or 'unread'
phoneNumberNoPhone number to send message to (required for send, read, and schedule operations)
scheduledTimeNoISO string of when to send the message (required for schedule operation)

Implementation Reference

  • The handleMessages function that executes the tool logic for send, read, schedule, and unread operations using the loaded message module and contacts module for name resolution.
    export async function handleMessages(
      args: MessagesArgs,
      loadModule: LoadModuleFunction
    ): Promise<ToolResult> {
      try {
        const messageModule = await loadModule('message');
    
        switch (args.operation) {
          case "send": {
            await messageModule.sendMessage(args.phoneNumber, args.message);
            return {
              content: [{ type: "text", text: `Message sent to ${args.phoneNumber}` }],
              isError: false
            };
          }
    
          case "read": {
            const messages = await messageModule.readMessages(args.phoneNumber, args.limit);
            return {
              content: [{ 
                type: "text", 
                text: messages.length > 0 ? 
                  messages.map(msg => 
                    `[${new Date(msg.date).toLocaleString()}] ${msg.is_from_me ? 'Me' : msg.sender}: ${msg.content}`
                  ).join("\n") :
                  "No messages found"
              }],
              isError: false
            };
          }
    
          case "schedule": {
            const scheduledMsg = await messageModule.scheduleMessage(
              args.phoneNumber,
              args.message,
              new Date(args.scheduledTime)
            );
            return {
              content: [{ 
                type: "text", 
                text: `Message scheduled to be sent to ${args.phoneNumber} at ${scheduledMsg.scheduledTime}` 
              }],
              isError: false
            };
          }
    
          case "unread": {
            const messages = await messageModule.getUnreadMessages(args.limit);
            
            // Look up contact names for all messages
            const contactsModule = await loadModule('contacts'); // Need contacts module here
            const messagesWithNames = await Promise.all(
              messages.map(async msg => {
                // Only look up names for messages not from me
                if (!msg.is_from_me) {
                  const contactName = await contactsModule.findContactByPhone(msg.sender);
                  return {
                    ...msg,
                    displayName: contactName || msg.sender // Use contact name if found, otherwise use phone/email
                  };
                }
                return {
                  ...msg,
                  displayName: 'Me'
                };
              })
            );
    
            return {
              content: [{ 
                type: "text", 
                text: messagesWithNames.length > 0 ? 
                  `Found ${messagesWithNames.length} unread message(s):\n` +
                  messagesWithNames.map(msg => 
                    `[${new Date(msg.date).toLocaleString()}] From ${msg.displayName}:\n${msg.content}`
                  ).join("\n\n") :
                  "No unread messages found"
              }],
              isError: false
            };
          }
    
          default:
            // This should be unreachable due to Zod validation
            throw new Error(`Unknown messages operation: ${(args as any).operation}`);
        }
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: `Error with messages operation: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    }
  • Zod schema used for input validation of the messages tool arguments in the server handler.
    export const MessagesArgsSchema = z.discriminatedUnion("operation", [
      z.object({ operation: z.literal("send"), phoneNumber: z.string(), message: z.string() }),
      z.object({ operation: z.literal("read"), phoneNumber: z.string(), limit: z.number().optional() }),
      z.object({ operation: z.literal("schedule"), phoneNumber: z.string(), message: z.string(), scheduledTime: z.string().datetime() }), // Assuming ISO 8601 format
      z.object({ operation: z.literal("unread"), limit: z.number().optional() }),
    ]);
  • index.ts:124-127 (registration)
    Registration of the messages tool handler in the MCP server's CallToolRequest handler switch statement.
    case "messages": {
      const validatedArgs = MessagesArgsSchema.parse(args);
      return await handleMessages(validatedArgs, loadModule);
    }
  • JSON inputSchema definition for the messages tool, used in tool discovery (ListTools).
    const MESSAGES_TOOL: Tool = {
      name: "messages",
      description: "Interact with Apple Messages app - send, read, schedule messages and check unread messages",
      inputSchema: {
        type: "object",
        properties: {
          operation: {
            type: "string",
            description: "Operation to perform: 'send', 'read', 'schedule', or 'unread'",
            enum: ["send", "read", "schedule", "unread"]
          },
          phoneNumber: {
            type: "string",
            description: "Phone number to send message to (required for send, read, and schedule operations)"
          },
          message: {
            type: "string",
            description: "Message to send (required for send and schedule operations)"
          },
          limit: {
            type: "number",
            description: "Number of messages to read (optional, for read and unread operations)"
          },
          scheduledTime: {
            type: "string",
            description: "ISO string of when to send the message (required for schedule operation)"
          }
        },
        required: ["operation"]
      }
    };
  • tools.ts:317-317 (registration)
    Includes MESSAGES_TOOL in the exported tools array returned by ListToolsRequest.
    const tools = [CONTACTS_TOOL, NOTES_TOOL, MESSAGES_TOOL, MAIL_TOOL, REMINDERS_TOOL, WEB_SEARCH_TOOL, CALENDAR_TOOL, MAPS_TOOL];

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.9/5.0
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 operations like 'send' and 'schedule,' which imply mutations, but doesn't state whether these require user confirmation, have rate limits, or affect device state. For a tool with multiple operations including writes, this is inadequate, as it omits critical behavioral traits like safety or side effects.

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 concise and front-loaded, stating the core purpose in a single sentence. It efficiently lists the four operations without unnecessary details. However, it could be slightly more structured by grouping related operations or adding brief context, but overall, it avoids waste and is appropriately sized for the tool's complexity.

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 with 5 parameters, multiple operations including mutations, no annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects, usage contexts, or return values, leaving gaps that could hinder an AI agent's ability to invoke the tool correctly. For a multi-operation tool with no structured safety hints, more detail is needed.

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 meaning beyond the input schema, which has 100% coverage. It implies that parameters are tied to specific operations (e.g., 'message' for 'send'), but doesn't elaborate on semantics like format constraints or dependencies. Since the schema descriptions are comprehensive, the baseline score of 3 is appropriate, as the description doesn't significantly enhance parameter understanding.

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: 'Interact with Apple Messages app - send, read, schedule messages and check unread messages.' It specifies the verb ('interact with') and resource ('Apple Messages app'), and lists the four operations. However, it doesn't explicitly differentiate from sibling tools like 'contacts' or 'mail,' which could have overlapping communication functions.

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 lists operations but doesn't specify contexts, prerequisites, or exclusions. For example, it doesn't mention if 'schedule' requires specific permissions or if 'read' is limited to recent messages. With sibling tools like 'calendar' and 'reminders' that might handle scheduling, this lack of differentiation is a significant gap.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools

Related Tools