Skip to main content
Glama

send_imessage

Send an iMessage or SMS to a recipient using a phone number, Apple ID email, or buddy name. Specify the message body and choose between iMessage or SMS service.

Instructions

Send an iMessage/SMS via Messages.app.

Args: recipient: phone (+15551234567), Apple ID email, or an existing buddy name. body: message text. service: "iMessage" (default) or "SMS".

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
recipientYes
bodyYes
serviceNoiMessage

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The tool 'send_imessage' is registered as an MCP tool via @mcp.tool() decorator. It validates service param then delegates to the send module.
    @mcp.tool()
    def send_imessage(recipient: str, body: str, service: str = "iMessage") -> dict[str, Any]:
        """Send an iMessage/SMS via Messages.app.
    
        Args:
            recipient: phone (+15551234567), Apple ID email, or an existing buddy name.
            body: message text.
            service: "iMessage" (default) or "SMS".
        """
        if service not in ("iMessage", "SMS"):
            raise ValueError("service must be 'iMessage' or 'SMS'")
        return send.send_imessage(recipient=recipient, body=body, service=service)  # type: ignore[arg-type]
  • Core implementation of send_imessage. Validates inputs, invokes AppleScript via osascript subprocess to send the message through Messages.app, and returns status.
    def send_imessage(recipient: str, body: str, service: Service = "iMessage") -> dict:
        if not recipient or not recipient.strip():
            raise SendError("recipient is required")
        if body is None:
            raise SendError("body is required")
        if service not in ("iMessage", "SMS"):
            raise SendError("service must be 'iMessage' or 'SMS'")
    
        try:
            result = subprocess.run(
                ["osascript", "-e", APPLESCRIPT, recipient, body, service],
                capture_output=True,
                text=True,
                timeout=20,
            )
        except FileNotFoundError as exc:
            raise SendError("osascript not found — is this macOS?") from exc
        except subprocess.TimeoutExpired as exc:
            raise SendError("osascript timed out after 20s") from exc
    
        if result.returncode != 0:
            stderr = (result.stderr or "").strip()
            hint = ""
            lower = stderr.lower()
            if "not authorized" in lower or "1743" in stderr or "-1743" in stderr:
                hint = (
                    " — grant automation permission at: System Settings → Privacy & "
                    "Security → Automation → your terminal/Claude → enable 'Messages'."
                )
            raise SendError(f"send failed (exit {result.returncode}): {stderr}{hint}")
    
        return {
            "status": "sent",
            "recipient": recipient,
            "service": service,
            "body_preview": body[:120],
        }
  • Delegation call from the tool registration to the actual send handler module.
    if service not in ("iMessage", "SMS"):
        raise ValueError("service must be 'iMessage' or 'SMS'")
    return send.send_imessage(recipient=recipient, body=body, service=service)  # type: ignore[arg-type]
  • The AppleScript string used by the handler to interface with macOS Messages.app.
    APPLESCRIPT = r'''
    on run argv
        set theRecipient to item 1 of argv
        set theBody to item 2 of argv
        set theService to item 3 of argv
        tell application "Messages"
            if theService is "SMS" then
                set svc to 1st service whose service type = SMS
            else
                set svc to 1st service whose service type = iMessage
            end if
            set theBuddy to buddy theRecipient of svc
            send theBody to theBuddy
        end tell
        return "sent"
    end run
    '''
  • Literal type alias 'Service' defining valid service values ('iMessage' | 'SMS').
    Service = Literal["iMessage", "SMS"]
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry the full burden. It mentions using Messages.app but does not disclose important traits like whether it costs money, requires permissions, or the consequences of sending. For a mutation tool, this is insufficient.

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 with two main sentences and a clean list. Every sentence is useful, though the structure could be slightly more streamlined.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity and presence of an output schema, the description covers the essential aspects. It could mention return value or error behavior, but overall it is complete enough for a send action.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description adds meaningful detail for all three parameters: recipient format, body text, and service default. This compensates well for the lack of schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Send an iMessage/SMS via Messages.app.' which is a specific verb+resource. It distinguishes well from sibling tools like get_chat_messages and search_imessages, which are read-only.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides details on recipient formats and service default, but lacks explicit guidance on when to use this tool vs alternatives. It does not mention when not to use it or discuss trade-offs between iMessage and SMS.

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

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