Skip to main content
Glama

messages_compose_message

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

Instructions

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

Input Schema

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

Implementation Reference

  • Handler function that generates the AppleScript executed when 'messages_compose_message' tool is called. Handles both auto-send and pre-fill modes.
    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 for the 'messages_compose_message' tool defining parameters: recipient (required), body, and auto-send flag.
    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 in ListToolsRequestSchema handler. Constructs tool name as 'messages_compose_message' from category 'messages' and script 'compose_message'.
    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: {}, }, })), ), }));
  • src/index.ts:34-34 (registration)
    Registers the 'messages' category (containing compose_message script) with the MCP server framework.
    server.addCategory(messagesCategory);
  • src/index.ts:11-11 (registration)
    Imports the messages category definition containing the 'compose_message' script.
    import { messagesCategory } from "./categories/messages.js";

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