Skip to main content
Glama
MailOtter

MailOtter

by Choplac

A little help for a lot of mail.

MailOtter lets your AI assistant (Claude, or any MCP client) search and clean up all your Gmail accounts at once, without the scary parts:

  • πŸ” Search everywhere. One search across every inbox you own.

  • πŸ“Š Top senders. Find out who's actually filling your inbox.

  • πŸ—‘οΈ Bulk trash, two steps. Preview first ("43 emails, here are 5"), act only after you say yes.

  • ↩️ Undo anything. Every trash or archive is logged and can be reversed.

  • πŸ“₯ Archive to clear the inbox without deleting.

And what it can't do, by design:

  • βœ‰οΈ It can't send email. MailOtter has no send function at all. (Honest note: Google's gmail.modify permission, which MailOtter needs for Trash, would technically allow sending. The guarantee comes from MailOtter's code, which tests check.)

  • πŸ”₯ It can't permanently delete. Mail goes to Trash, which you can recover for 30 days.

  • 🧩 It can't do half a job. If a search matches more than the limit (2,000 by default), it refuses and changes nothing.

  • ⏱️ It can't act on stale previews. A preview code works once, for 15 minutes, on exactly the emails it showed. Mail that arrives later is never touched, and mail already changed since the preview is skipped.

  • πŸ”Œ It can't half-connect. Every account is reached before anything changes. A crash mid-way still leaves a journal, so undo works.

It runs on your own computer (Linux, macOS or WSL). Your mail goes only between your computer and Google.

It deliberately stays under Gmail's per-account speed limit, so big jobs take time: about 7 minutes to trash 1,000 emails, and about 2 minutes to scan 250 for top senders.

Install

pipx install git+https://github.com/Choplac/mailotter

Related MCP server: A1 Gmail MCP

One-time Google setup (about 15 minutes)

Gmail needs a "client key" that belongs to you:

  1. Go to Google Cloud Console and create a project (any name).

  2. Under APIs & Services β†’ Library, open Gmail API and click Enable.

  3. Open Google Auth Platform β†’ Get started. App name: MailOtter. Audience: External.

  4. Under Audience β†’ Test users, add every Gmail address you want to manage.

  5. Under Clients β†’ Create client, choose Desktop app, then click Download JSON.

  6. Run mailotter setup ~/Downloads/client_secret_XXXX.json, then delete the download.

While your Google app is in Testing, Google makes sign-ins expire after 7 days. To avoid re-signing weekly, open Audience and click Publish app. It stays private to you, and Google shows an "unverified app" warning at sign-in, which is expected for a personal tool.

Sign in your accounts

mailotter login personal --email you@gmail.com
mailotter login old --email old.you@gmail.com
mailotter accounts

login prints a link. Open it, sign in, and allow access. If your browser can't reach the computer (some WSL, SSH or container setups), use mailotter login personal --manual.

Use it from the command line

mailotter top-senders                          # who fills your inboxes
mailotter search "from:newsletter@shop.com"    # across all accounts
mailotter trash "from:newsletter@shop.com older_than:3m"   # preview, then type yes
mailotter archive "category:promotions" -a personal
mailotter history
mailotter undo                                 # reverse the last action

The search words are Gmail's own.

Save attachments

mailotter save-attachments "from:reports@example.com has:attachment" -a work --to ~/reports --pdf-only

Saves the attachments of the newest matching emails (20 by default, -n for more) in one account. It only reads mail: nothing is labelled, archived, trashed or marked read.

  • Files are named <date>-<message id>.<ext> (-2, -3 for the second and third attachment of an email, so a rerun after a failed download gives the same names), never after the attachment's own name, which a stranger chose; attachments that have no name are saved too. A file that really is a PDF always ends in .pdf, with or without --pdf-only. --pdf-only keeps only files that really are PDFs.

  • A new folder is created private to you, and files are readable only by you.

  • It never overwrites. A file already saved with the same content is skipped; a different file with the same name is reported as a conflict and left alone. Attachments over 25 MB are refused.

  • This is command line only: the assistant tools below cannot save files.

Use it from Claude Code

claude mcp add mailotter -- mailotter serve

Then just ask: "Who sends me the most mail across all my accounts? Preview trashing the newsletters older than 3 months."

Keep yourself in the loop: when Claude asks permission to run confirm_action, read the preview first. Don't add confirm_action to your always-allow list.

Tools

Tool

What it does

Changes mail?

list_accounts

Your accounts and nicknames

No

search_mail

Gmail search in one account or all

No

read_mail

Read one email (plain text)

No

top_senders

Biggest senders over recent mail

No

preview_trash / preview_archive

Count and examples, plus a one-time code

No

confirm_action

Carry out a preview

Yes (reversible)

undo_action

Reverse a confirmed action

Yes (restores)

action_history

Recent actions and their ids

No

Safety notes

  • Emails are written by strangers. MailOtter tells the assistant never to follow instructions found inside an email, and the two-step confirm means a sneaky email can't trash your mail on its own.

  • Files live in ~/.config/mailotter (or $MAILOTTER_HOME) and only your user can read them: client_secret.json, tokens/<nickname>.json, state/history.jsonl.

  • To revoke access completely, run mailotter logout <nickname> and remove MailOtter at https://myaccount.google.com/permissions.

  • Undo works for as long as Gmail keeps Trash (30 days).

Develop

python -m venv .venv && .venv/bin/pip install -e '.[test]'
.venv/bin/pytest        # uses an in-memory fake Gmail, never a real inbox

License

MIT. See also the privacy policy.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to interact with Gmail through OAuth2 authentication, allowing users to list, search, read emails, and create drafts with a safety-first design that prevents accidental sends by default.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI assistants to search, read, draft, and send Gmail messages, as well as manage labels and trash using natural language.
      24
      168 npm
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants to read and draft emails across multiple Gmail accounts at once, with strict safeguards that prevent sending, deleting, or modifying mailbox settings.
      AGPL 3.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables an assistant to search and read mail across multiple Gmail accounts, create drafts in the correct account and thread, apply labels, archive or mark read reversibly, and view events from every calendar in read-only mode. Sending and deleting are deliberately not exposed, so all outgoing mail is reviewed and sent by the user.
      17 npm
      MIT