Skip to main content
Glama

messages_compose_message

Open the Messages app with a pre-filled message to a recipient or automatically send a message using AppleScript on macOS.

Instructions

[iMessage operations] Open Messages app with a pre-filled message to a recipient or automatically send a message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
recipientYesPhone number or email of the recipient
bodyNoMessage body text
autoNoAutomatically send the message without user confirmation

Implementation Reference

  • Core handler implementation for 'messages_compose_message' tool. The 'script' function generates AppleScript that opens Messages app with pre-filled message or auto-sends it based on 'recipient', 'body', and 'auto' parameters.
        {
          name: "compose_message",
          description: "Open Messages app with a pre-filled message to a recipient or automatically send a message",
          schema: {
            type: "object",
            properties: {
              recipient: {
                type: "string",
                description: "Phone number or email of the recipient"
              },
              body: {
                type: "string",
                description: "Message body text",
                default: ""
              },
              auto: {
                type: "boolean",
                description: "Automatically send the message without user confirmation",
                default: false
              }
            },
            required: ["recipient"]
          },
          script: (args) => `
    on run
      -- Get the recipient and message body
      set recipient to "${args.recipient}"
      set messageBody to "${args.body || ''}"
      set autoSend to ${args.auto === true ? "true" : "false"}
      
      if autoSend then
        -- Automatically send the message using AppleScript
        tell application "Messages"
          -- Get the service (iMessage or SMS)
          set targetService to 1st service whose service type = iMessage
          
          -- Send the message
          set targetBuddy to buddy "${args.recipient}" of targetService
          send "${args.body || ''}" to targetBuddy
          
          return "Message sent to " & "${args.recipient}"
        end tell
      else
        -- Just open Messages app with pre-filled content
        -- Create the SMS URL with proper URL encoding
        set smsURL to "sms:" & recipient
        
        if messageBody is not equal to "" then
          -- Use percent encoding for spaces instead of plus signs
          set encodedBody to ""
          repeat with i from 1 to count of characters of messageBody
            set c to character i of messageBody
            if c is space then
              set encodedBody to encodedBody & "%20"
            else
              set encodedBody to encodedBody & c
            end if
          end repeat
          
          set smsURL to smsURL & "&body=" & encodedBody
        end if
        
        -- Open the URL with the default handler (Messages app)
        do shell script "open " & quoted form of smsURL
        
        return "Opening Messages app with recipient: " & recipient
      end if
    end run
          `
        }
  • Input schema defining parameters for the messages_compose_message tool.
    schema: {
      type: "object",
      properties: {
        recipient: {
          type: "string",
          description: "Phone number or email of the recipient"
        },
        body: {
          type: "string",
          description: "Message body text",
          default: ""
        },
        auto: {
          type: "boolean",
          description: "Automatically send the message without user confirmation",
          default: false
        }
      },
      required: ["recipient"]
    },
  • Dynamic registration of all tools including 'messages_compose_message' in the ListToolsRequestHandler by constructing name as `${category.name}_${script.name}`.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: this.categories.flatMap((category) =>
        category.scripts.map((script) => ({
          name: `${category.name}_${script.name}`, // Changed from dot to underscore
          description: `[${category.description}] ${script.description}`,
          inputSchema: script.schema || {
            type: "object",
            properties: {},
          },
        })),
      ),
    }));
  • MCP CallToolRequestHandler that resolves 'messages_compose_message' to category 'messages' and script 'compose_message', invokes the script generator with arguments, and prepares AppleScript for execution.
    // Split on underscore instead of dot
    const [categoryName, ...scriptNameParts] =
      toolName.split("_");
    const scriptName = scriptNameParts.join("_"); // Rejoin in case script name has underscores
    
    const category = this.categories.find((c) => c.name === categoryName);
    if (!category) {
      this.log("warning", "Category not found", { categoryName });
      throw new McpError(
        ErrorCode.MethodNotFound,
        `Category not found: ${categoryName}`,
      );
    }
    
    const script = category.scripts.find((s) => s.name === scriptName);
    if (!script) {
      this.log("warning", "Script not found", { 
        categoryName, 
        scriptName 
      });
      throw new McpError(
        ErrorCode.MethodNotFound,
        `Script not found: ${scriptName}`,
      );
    }
    
    this.log("debug", "Generating script content", { 
      categoryName, 
      scriptName,
      isFunction: typeof script.script === "function"
    });
    
    const scriptContent =
      typeof script.script === "function"
        ? script.script(request.params.arguments)
        : script.script;
  • src/index.ts:34-34 (registration)
    Registers the 'messages' category (containing compose_message script) with the MCP server framework.
    server.addCategory(messagesCategory);
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 that the tool can 'automatically send a message without user confirmation' (via the 'auto' parameter), which hints at a potentially destructive action, but it doesn't disclose other critical behaviors such as permissions required, error handling, or side effects (e.g., app launching). This leaves gaps in understanding the tool's operational context.

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 functionality in a single sentence. It efficiently covers the two modes of operation (opening with pre-filled message or auto-sending). There's no wasted text, though it could be slightly more structured to separate the two use cases explicitly.

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 tool's moderate complexity (3 parameters, no output schema, no annotations), the description is minimally adequate. It explains the basic action but lacks details on behavioral traits, usage context, and output expectations. Without annotations or an output schema, the description should do more to cover these gaps, but it meets a bare minimum for understanding the tool's intent.

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 input schema already documents all parameters ('recipient', 'body', 'auto') with clear descriptions. The description adds no additional meaning beyond what the schema provides, such as format examples or constraints. Baseline 3 is appropriate as the schema handles the heavy lifting, but the description doesn't compensate with extra insights.

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: 'Open Messages app with a pre-filled message to a recipient or automatically send a message.' It specifies the verb ('Open Messages app' or 'send a message'), resource ('Messages app'), and scope ('iMessage operations'), though it doesn't explicitly differentiate from sibling tools like 'messages_get_messages' or 'messages_list_chats' beyond the general 'iMessage operations' context.

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 mentions 'iMessage operations' but doesn't specify scenarios, prerequisites, or exclusions. For example, it doesn't clarify if this is for new messages only or if it interacts with existing chats, nor does it compare to other messaging tools in the sibling list.

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/joshrutkowski/applescript-mcp'

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