Skip to main content
Glama
p-l-ta

mail-mcp

by p-l-ta

list_accounts_and_mailboxes

Read-only

Retrieve all Mail.app accounts and their mailboxes, including unread email counts, to monitor inbox activity at a glance.

Instructions

List all configured Mail.app accounts and their mailboxes with unread counts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The register function defines the 'list_accounts_and_mailboxes' tool on the McpServer. It runs an AppleScript to iterate all Mail.app accounts and mailboxes, parses the output, and returns JSON with account names, user names, mailbox names, and unread counts.
    export function register(server: McpServer): void {
      server.tool(
        "list_accounts_and_mailboxes",
        "List all configured Mail.app accounts and their mailboxes with unread counts.",
        {},
        { title: "List Accounts and Mailboxes", readOnlyHint: true, destructiveHint: false },
        async () => {
          const raw = await runAppleScript({ script: SCRIPT });
          const accounts = parse(raw);
          return {
            content: [{ type: "text", text: JSON.stringify(accounts, null, 2) }],
          };
        },
      );
    }
  • The AppleScript SCRIPT that lists all accounts and their mailboxes with unread counts, tab-separated, line-by-line.
    const SCRIPT = `
      set buf to ""
      tell application "Mail"
        repeat with acct in accounts
          set buf to buf & "ACCOUNT" & tab & (name of acct) & tab & (user name of acct) & linefeed
          repeat with mb in mailboxes of acct
            set buf to buf & "MAILBOX" & tab & (name of mb) & tab & ((unread count of mb) as string) & linefeed
          end repeat
        end repeat
      end tell
      return buf
    `;
  • The parse() function that converts the tab-separated AppleScript output into structured Account[] objects with nested Mailbox arrays.
    function parse(raw: string): Account[] {
      const accounts: Account[] = [];
      let current: Account | null = null;
      for (const line of raw.split("\n")) {
        if (!line) continue;
        const [kind, a, b] = line.split("\t");
        if (kind === "ACCOUNT") {
          current = { name: a ?? "", user: b ?? "", mailboxes: [] };
          accounts.push(current);
        } else if (kind === "MAILBOX" && current) {
          current.mailboxes.push({ name: a ?? "", unread: Number(b) || 0 });
        }
      }
      return accounts;
    }
  • TypeScript interfaces defining the Account and Mailbox shapes returned by the tool.
    interface Mailbox {
      name: string;
      unread: number;
    }
    interface Account {
      name: string;
      user: string;
      mailboxes: Mailbox[];
    }
  • src/server.ts:7-7 (registration)
    Import of the register function from accounts.ts.
    import { register as registerAccounts } from "./tools/accounts.js";
  • src/server.ts:27-27 (registration)
    Registration call that hooks the tool into the MCP server.
    registerAccounts(server);
Behavior4/5

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

Annotations declare readOnlyHint true and destructiveHint false. Description adds 'with unread counts', providing useful behavioral context 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?

Single sentence of 10 words, perfectly concise with no wasted text.

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?

No output schema, but description adequately states what is returned (accounts, mailboxes, unread counts). Could be enhanced by mentioning if metadata or folder hierarchy is included, but sufficient for a simple list.

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?

Input schema has zero parameters, so description needs no param info. Baseline 4 applies as schema coverage is 100%.

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?

Description clearly states verb 'list', resource 'Mail.app accounts and their mailboxes', and includes 'with unread counts', making it specific and distinct from siblings like list_recent or search_emails.

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?

No explicit guidance on when to use this tool vs alternatives. Usage is implied by the tool's function but not formally stated.

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