Skip to main content
Glama
p-l-ta

mail-mcp

by p-l-ta

send_email

Destructive

Send new emails directly from Mail.app using an existing account. Specify recipient, subject, body, and optionally CC and sender account.

Instructions

Send a new email via Mail.app from an existing account.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYesPrimary recipient email address
ccNoCC recipient email address
subjectYes
bodyYes
from_accountNoAccount name to send from (matches Mail.app account name)

Implementation Reference

  • The send_email tool handler function. Registers the tool on the MCP server, passes schema-validated arguments (to, cc, subject, body, from_account) to the AppleScript runner, and returns a confirmation message.
    export function register(server: McpServer): void {
      server.tool(
        "send_email",
        "Send a new email via Mail.app from an existing account.",
        schema,
        { title: "Send Email", readOnlyHint: false, destructiveHint: true },
        async ({ to, cc, subject, body, from_account }) => {
          await runAppleScript({
            script: SCRIPT,
            args: {
              theTo: to,
              theCc: cc ?? "",
              theSubject: subject,
              theBody: body,
              fromAccount: from_account ?? "",
            },
          });
          return { content: [{ type: "text", text: `Email sent to ${to}` }] };
        },
      );
  • Zod schema defining the input parameters for send_email: to (required string), cc (optional string), subject (required string), body (required string), from_account (optional string with description).
    const schema = {
      to: z.string().describe("Primary recipient email address"),
      cc: z.string().optional().describe("CC recipient email address"),
      subject: z.string(),
      body: z.string(),
      from_account: z
        .string()
        .optional()
        .describe("Account name to send from (matches Mail.app account name)"),
    };
  • src/server.ts:9-29 (registration)
    Import of the send tool's register function and registration on the MCP server at line 29.
    import { register as registerSend } from "./tools/send.js";
    import { register as registerReply } from "./tools/reply.js";
    import { register as registerFlags } from "./tools/flags.js";
    import { register as registerMove } from "./tools/move.js";
    import { register as registerTrash } from "./tools/trash.js";
    import { register as registerCreateMailbox } from "./tools/create_mailbox.js";
    import { register as registerBulkMarkRead } from "./tools/bulk_mark_read.js";
    import { register as registerGetUnsubscribeLink } from "./tools/get_unsubscribe_link.js";
    import { register as registerListSenders } from "./tools/list_senders.js";
    import { register as registerEmptyMailbox } from "./tools/empty_mailbox.js";
    
    const server = new McpServer({
      name: "mail-app-mcp",
      version: "1.0.0",
    });
    
    registerSearch(server);
    registerRead(server);
    registerAccounts(server);
    registerListRecent(server);
    registerSend(server);
  • The AppleScript that constructs and sends an email via Mail.app. Creates an outgoing message, sets the sender if provided, adds to/cc recipients, then sends.
    const SCRIPT = `
      tell application "Mail"
        set newMsg to make new outgoing message with properties {subject:theSubject, content:theBody, visible:false}
        if fromAccount is not "" then
          set sender of newMsg to fromAccount
        end if
        tell newMsg
          make new to recipient at end of to recipients with properties {address:theTo}
          if theCc is not "" then
            make new cc recipient at end of cc recipients with properties {address:theCc}
          end if
        end tell
        send newMsg
      end tell
      return "sent"
    `;
  • The runAppleScript utility function that writes the script to a temp file and executes it via osascript, passing arguments safely through argv (no string interpolation).
    export async function runAppleScript(opts: RunAppleScriptOptions): Promise<string> {
      const { script, args = {}, timeoutMs = 30_000 } = opts;
    
      const argNames = Object.keys(args);
      const argValues = argNames.map((n) => args[n]!);
    
      const bindings = argNames
        .map((name, i) => `  set ${name} to item ${i + 1} of argv`)
        .join("\n");
    
      const wrapped = `on run argv\n${bindings}\n${script}\nend run\n`;
    
      const dir = await mkdtemp(path.join(tmpdir(), "mail-mcp-"));
      const scriptPath = path.join(dir, "script.applescript");
      try {
        await writeFile(scriptPath, wrapped, "utf8");
        const { stdout } = await execFileP("osascript", [scriptPath, ...argValues], {
          timeout: timeoutMs,
          maxBuffer: 10 * 1024 * 1024,
        });
        return stdout.trimEnd();
      } finally {
        await rm(dir, { recursive: true, force: true }).catch(() => {});
      }
    }
Behavior3/5

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

Annotations already mark the tool as destructive (destructiveHint=true) and not read-only. The description adds no extra behavioral context beyond 'Send a new email', which aligns with the annotations. It could clarify whether it actually sends the email or opens a compose window, but the annotations satisfy the basic safety profile.

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 a single sentence that is concise and front-loaded with the core purpose. It could include more detail without becoming verbose, but it is efficient and not overly long.

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?

The description is too brief given the tool's complexity. It fails to mention return values (e.g., success/failure), whether the email is actually sent or queued, and does not address edge cases like invalid accounts. Without an output schema, the description should clarify what the agent can expect as a result.

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

Parameters2/5

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

The schema has 60% description coverage, leaving subject and body without descriptions. The tool description does not add any parameter-specific details beyond what the schema provides. The description mentions 'from an existing account' which ties to the from_account parameter, but does not compensate for the missing schema descriptions for subject and body.

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 a new email via Mail.app from an existing account', specifying the verb (send), resource (email), and context (Mail.app). Among sibling tools like reply_to_email and trash_email, this uniquely identifies the tool's purpose.

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?

No guidance is provided on when to use this tool versus alternatives such as reply_to_email or search_emails. It does not mention prerequisites like having an account configured, nor does it indicate that it is for composing new messages only.

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/p-l-ta/mail-mcp'

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