Skip to main content
Glama
p-l-ta

mail-mcp

by p-l-ta

empty_mailbox

Destructive

Delete all messages in a mailbox at once. Moves to Deleted Messages, or permanently removes if emptying the Trash or Deleted Messages folder.

Instructions

Delete every message in a mailbox at once — moves to Deleted Messages, or permanently removes if the mailbox is already Deleted Messages/Trash. Use for Junk, Trash, or bulk-cleanup folders.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mailbox_nameYesExact mailbox name to empty (e.g. 'Junk', 'Deleted Messages'). Use list_accounts_and_mailboxes for exact names.
accountNoAccount name to disambiguate when the same mailbox name exists in multiple accounts

Implementation Reference

  • The handler function that registers and executes the 'empty_mailbox' tool. It accepts mailbox_name and optional account, runs an AppleScript to delete every message in the target mailbox, and returns the count of deleted messages.
    export function register(server: McpServer): void {
      server.tool(
        "empty_mailbox",
        "Delete every message in a mailbox at once — moves to Deleted Messages, or permanently removes if the mailbox is already Deleted Messages/Trash. Use for Junk, Trash, or bulk-cleanup folders.",
        schema,
        { title: "Empty Mailbox", readOnlyHint: false, destructiveHint: true },
        async ({ mailbox_name, account }) => {
          const result = await runAppleScript({
            script: SCRIPT,
            args: {
              theMailbox: mailbox_name,
              theAcct: account ?? "",
            },
            timeoutMs: 120_000,
          });
          return { content: [{ type: "text", text: result }] };
        },
      );
    }
  • Zod schema defining the tool's input parameters: mailbox_name (required string) and account (optional string for disambiguation).
    const schema = {
      mailbox_name: z.string().describe("Exact mailbox name to empty (e.g. 'Junk', 'Deleted Messages'). Use list_accounts_and_mailboxes for exact names."),
      account: z.string().optional().describe("Account name to disambiguate when the same mailbox name exists in multiple accounts"),
    };
  • src/server.ts:18-18 (registration)
    Import of the register function from the empty_mailbox tool module.
    import { register as registerEmptyMailbox } from "./tools/empty_mailbox.js";
  • src/server.ts:38-38 (registration)
    Registration call that wires the 'empty_mailbox' tool into the MCP server.
    registerEmptyMailbox(server);
  • The runAppleScript helper that writes the AppleScript to a temp file and executes it via osascript, safely passing arguments through argv.
    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(() => {});
      }
    }
Behavior4/5

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

The description discloses conditional behavior (moves vs permanently removes) and batch operation. Annotations already indicate destructive, so description adds value by detailing the behavior beyond annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences that are front-loaded and free of unnecessary words. Every sentence adds essential information: action, behavior, and usage context.

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

Completeness5/5

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

For a simple destructive tool with only two parameters and no output schema, the description covers purpose, behavior, and usage fully. It includes necessary warnings about permanent deletion and scope.

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 coverage is 100% with clear parameter descriptions. The tool description adds value by referencing 'list_accounts_and_mailboxes' for exact names and providing examples, which aids parameter understanding beyond the schema.

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 the action ('Delete every message in a mailbox at once') and resource, with specific use cases (Junk, Trash, bulk-cleanup). It distinguishes from sibling tools like trash_email and bulk_mark_read by emphasizing batch deletion.

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

Usage Guidelines4/5

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

The description explicitly says when to use ('Use for Junk, Trash, or bulk-cleanup folders'), providing clear context. It doesn't mention alternatives or exclusions, but the context is sufficient for an agent to decide.

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