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];
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 operations but lacks critical details: it doesn't specify permissions needed (e.g., access to Messages app), side effects (e.g., whether 'send' is immediate or requires confirmation), error handling, or rate limits. For a tool with multiple operations including mutations ('send', 'schedule'), 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 concise and front-loaded, stating the core purpose in one sentence: 'Interact with Apple Messages app - send, read, schedule messages and check unread messages.' It efficiently lists the four operations without unnecessary elaboration. However, it could be slightly more structured by grouping related operations (e.g., 'send' and 'schedule' as write operations).

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 (5 parameters, 4 distinct operations including mutations) and lack of annotations and output schema, the description is incomplete. It doesn't address behavioral aspects like authentication, side effects, or return values, which are crucial for safe and effective use. The schema covers parameters well, but overall context for agent decision-making is insufficient.

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?

Schema description coverage is 100%, so the schema already documents all five parameters thoroughly. The description adds no additional meaning beyond what's in the schema (e.g., it doesn't clarify parameter dependencies or operational nuances). Baseline 3 is appropriate since the schema does the heavy lifting, but the description doesn't compensate or 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 this tool from its siblings (e.g., calendar, contacts), though the domain (messages vs. other Apple apps) is implied.

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 (e.g., when to use 'send' vs. 'schedule', or how this differs from other messaging tools). Without such guidance, the agent must infer usage from the operation parameter alone.

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

Related 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/wearesage/mcp-apple'

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