Skip to main content
Glama
p-l-ta

mail-mcp

by p-l-ta

bulk_mark_read

Mark multiple messages as read in one call by specifying mailbox, sender substring, or both. Saves time compared to flagging each message individually.

Instructions

Mark multiple messages as read in one call — by mailbox, sender substring, or both. Far faster than calling set_message_flags per message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mailboxNoRestrict to this exact mailbox name. At least one of mailbox or from is required.
fromNoSubstring to match against the sender field. At least one of mailbox or from is required.
accountNoRestrict to this account name.

Implementation Reference

  • The register function that defines the 'bulk_mark_read' tool with its handler logic. It validates that at least one of mailbox/from is provided, then runs the AppleScript to mark matching messages as read.
    export function register(server: McpServer): void {
      server.tool(
        "bulk_mark_read",
        "Mark multiple messages as read in one call — by mailbox, sender substring, or both. Far faster than calling set_message_flags per message.",
        schema,
        { title: "Bulk Mark Read", readOnlyHint: false, destructiveHint: false },
        async ({ mailbox, from, account }) => {
          if (!mailbox && !from) {
            return {
              content: [{ type: "text", text: "At least one of mailbox or from is required." }],
              isError: true,
            };
          }
          const result = await runAppleScript({
            script: SCRIPT,
            args: {
              theMailbox: mailbox ?? "",
              theSender: from ?? "",
              theAcct: account ?? "",
            },
            timeoutMs: 120_000,
          });
          return { content: [{ type: "text", text: result }] };
        },
      );
    }
  • Zod schema for tool inputs: optional mailbox (exact name), from (substring match sender), and account (exact name).
    const schema = {
      mailbox: z.string().optional().describe("Restrict to this exact mailbox name. At least one of mailbox or from is required."),
      from: z.string().optional().describe("Substring to match against the sender field. At least one of mailbox or from is required."),
      account: z.string().optional().describe("Restrict to this account name."),
    };
  • The AppleScript template that iterates over accounts/mailboxes/messages and marks unread messages as read, given theMailbox, theSender, and theAcct variables.
    const SCRIPT = `
      tell application "Mail"
        set markedCount to 0
        repeat with acct in accounts
          if theAcct is "" or (name of acct) contains theAcct then
            repeat with mb in mailboxes of acct
              if theMailbox is "" or (name of mb) is theMailbox then
                set msgs to messages of mb
                repeat with m in msgs
                  if (read status of m) is false then
                    if theSender is "" or (sender of m) contains theSender then
                      set read status of m to true
                      set markedCount to markedCount + 1
                    end if
                  end if
                end repeat
              end if
            end repeat
          end if
        end repeat
        return (markedCount as string) & " messages marked read"
      end tell
    `;
  • The helper function runAppleScript imported from ../lib/applescript.ts, which writes the script to a temp file and executes it via osascript with safe argument passing.
    export function register(server: McpServer): void {
      server.tool(
        "bulk_mark_read",
        "Mark multiple messages as read in one call — by mailbox, sender substring, or both. Far faster than calling set_message_flags per message.",
        schema,
        { title: "Bulk Mark Read", readOnlyHint: false, destructiveHint: false },
        async ({ mailbox, from, account }) => {
          if (!mailbox && !from) {
            return {
              content: [{ type: "text", text: "At least one of mailbox or from is required." }],
  • src/server.ts:15-35 (registration)
    Import of the register function from bulk_mark_read.ts, and its invocation at line 35 to register the tool with the MCP server.
    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);
    registerReply(server);
    registerFlags(server);
    registerMove(server);
    registerTrash(server);
    registerCreateMailbox(server);
    registerBulkMarkRead(server);
Behavior3/5

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

Annotations already indicate the tool is not read-only (readOnlyHint=false) and not destructive (destructiveHint=false). The description adds that it marks messages as read in one call, which is consistent with annotations. It does not detail idempotency or edge cases, but with annotations covering safety, a score of 3 is appropriate.

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 focused sentences that immediately state the action and usage context. No wasted words; front-loaded and efficient.

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?

For a tool with three optional parameters and no output schema, the description covers the core behavior and differentiation. It lacks edge case details but is sufficient for typical use. Annotations further help.

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?

Input schema has 100% description coverage, so parameters are well-documented. The description adds no new information about parameters beyond summarizing the filtering criteria. Baseline 3 is correct.

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 tool marks multiple messages as read, with specific filtering by mailbox or sender substring. It also distinguishes from the sibling tool set_message_flags by noting it is faster for bulk operations.

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 contrasts with set_message_flags by stating 'Far faster than calling set_message_flags per message', providing clear context for when to use this tool. It does not mention when not to use it but the context is clear.

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