AnyMail MCP
AnyMail MCP is a local MCP server that gives AI agents full read, send, organize, and delete access across multiple Gmail (and experimental IMAP) accounts simultaneously, with credentials stored securely in the macOS Keychain.
Account Management
List configured accounts (including default and read-only status)
Add new accounts: Gmail, iCloud, Fastmail, or custom IMAP (with App Password, optional read-only or default flag)
Reading & Searching
Search messages using native Gmail query syntax, optionally filtered by label
Fetch full message content (headers, plain-text/HTML bodies, attachment metadata)
Fetch entire email threads (oldest first)
List all labels/mailboxes for an account
Download attachments by index; returns base64 or saves to disk for large files
Sending & Drafting
Send emails with to/cc/bcc, plain text, HTML, attachments, and reply threading
Create and save drafts without sending
Organizing & Labeling
Create new labels (supports nested labels)
Add/remove labels on messages
Mark messages as read or unread
Star or unstar messages
Archive messages (remove from Inbox)
Move messages to a target label/folder
Deleting
Trash messages (reversible ~30 days)
Permanently delete messages (requires
confirm: true)
Bulk Operations (all support dryRun: true and confirm: true for large batches)
Mark all matching messages as read
Bulk add/remove labels on matching messages
Bulk move matching messages to a folder
Bulk trash matching messages
Bulk permanently delete matching messages
Empty Spam or Trash (optionally narrowed by query)
Security & Integration
Credentials stored in macOS Keychain; runs entirely locally, binding only to
127.0.0.1Bearer token API access with sensitive info redacted from logs
Integrates with AI agents via HTTP (Cursor, Claude Code, VS Code, Windsurf) or stdio (Claude Desktop)
Allows reading, sending, organizing, and deleting emails across multiple Gmail accounts via IMAP/SMTP.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@AnyMail MCPsearch all accounts for 'invoice'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Email Local MCP
Give your AI agent every one of your mailboxes, without giving anything to a cloud service. A local MCP server that lets Claude Code, Claude Desktop, Cursor, VS Code or Windsurf search, read, send, organize and clean up mail across all your accounts at once, over plain IMAP/SMTP. Gmail, iCloud, Fastmail, Microsoft 365, or any IMAP host.
Your mail is read by a program running on your own machine. Nothing is uploaded, proxied, or seen by anyone, including this project.
Pre-1.0. It works and it is in daily use, but tool names and options may still change between versions.
Install in one line
claude mcp add email-local -- npx -y email-local-mcp
npx -y email-local-mcp add you@example.com --defaultThat is the whole setup. Restart your agent and ask it to list_accounts.
Note on the examples below.
npxruns the tool without installing a binary, so there is no bareemail-local-mcpcommand on your PATH. Every example in this README is written asemail-local-mcp …; if you installed withnpx, prefix it withnpx -y. A Homebrew or from-source install gives you the bare command.
Prefer a menu bar app, a Homebrew install, or no terminal at all? See Other ways to install.
Related MCP server: mail-mcp
What you can actually ask for
Once it is connected, these are ordinary requests:
"What did I miss this week across all my accounts?"
"Find the invoice from Acme, any mailbox, and save the PDF to my desktop."
"Reply to Sarah's last email agreeing to Tuesday, but keep it short."
"Unsubscribe sweep: trash every promotional email older than a year."
"Move everything from my accountant into a Tax folder."
The last two touch thousands of messages. They are still one request, because the bulk tools work on a whole search result rather than one message at a time.
Is it safe to give an agent your email?
That is the right question to ask, so here is the honest answer in four parts.
1. Your mail never leaves your machine
There is no server run by this project, no account to create, and no telemetry. The engine is a Node process on your computer that opens a direct IMAP/SMTP connection to your mail provider. The only parties involved are you, your computer, and your provider, exactly as with any desktop mail client.
Your agent does see the messages it is asked to read, because that is the point. That happens on whatever terms you already have with your agent.
2. Your password is not the credential
You never give it your real password. You create an App Password or sign in with OAuth: either way a per-app credential you can revoke at any time without touching your account. It is stored only in your operating system's credential store:
Platform | Where credentials live |
macOS | Keychain |
Windows | Credential Manager |
Linux | Secret Service (gnome-keyring / KWallet) |
Never in a config file, never in the repo, never in a log line, and never in a response your agent can read back.
3. Nothing outside your machine can reach the server
The always-on HTTP mode is locked down three ways at once, because a local port that speaks to your mailbox is worth attacking:
Bound to
127.0.0.1only. Not reachable from your network, let alone the internet.A bearer token on every request. Generated on first run and stored with permissions only you can read.
Originvalidation. This is what stops a malicious website in your browser from quietly talking to the port behind your back, an attack called DNS rebinding.
4. The destructive things are gated
Deleting mail is irreversible, so it is not treated like reading it:
Trash is the default.
trash_messageis reversible. Permanent deletion is a separate tool that refuses to run withoutconfirm:true.Bulk operations preview first.
dryRun:truereports what would be affected and changes nothing. Anything destructive, or any batch over 100 messages, requiresconfirm:true.Accounts can be read-only. Add one with
--read-onlyand every write is refused for that account, whatever the agent decides to try.
Full detail, including an App Password's blast radius and how to revoke one, is in SECURITY.md. The code is MIT licensed, so none of the above has to be taken on trust.
Add an account
Two ways. Most people want the first.
App Password (simplest)
Create a per-app credential with your provider, then:
email-local-mcp add you@gmail.com --default
email-local-mcp add you@icloud.com --provider icloud
email-local-mcp add you@work.com --provider imap --imap-host mail.work.com --smtp-host smtp.work.comProvider | Where to create it | Notes |
Gmail | Turn on 2-Step Verification first. IMAP is always on. | |
iCloud | https://account.apple.com → Sign-In and Security → App-Specific Passwords | Needs two-factor auth on the Apple Account. |
Fastmail | Settings → Password & Security → App Passwords | Scope it to IMAP + SMTP. |
Other IMAP | Your host's control panel | Some hosts require enabling IMAP access explicitly. |
Useful flags: --default (used when a tool omits account), --read-only
(refuse every write), --name "Full Name" (the display name recipients see).
OAuth (required for Microsoft 365)
login connects through the provider's own sign-in page, with no App Password.
For Microsoft it is the only option, since Exchange Online no longer accepts
basic auth for IMAP.
email-local-mcp login you@gmail.com --provider gmail --client-id … --client-secret …
email-local-mcp login you@contoso.com --provider microsoft --client-id … --tenant contoso.onmicrosoft.comOne piece of setup is yours: you register the OAuth client and pass its id. That is not busywork. Mail scopes are "restricted", so a client id shipped inside a public binary would force this project through Google verification and an annual security assessment, and until it passed, your refresh tokens would expire every week. A client you create yourself has none of those limits and takes about five minutes. docs/oauth.md walks through both providers.
Tokens refresh automatically and live in the same credential store as App
Passwords. email-local-mcp logout <email> disconnects and revokes at the
provider where the provider supports it.
What it can do
Full CRUD across every connected account:
Kind | Operations |
Read | list accounts · search · read message · read thread (Gmail) · list labels (Gmail) · fetch attachments |
Create | send · save draft · create label · add an account |
Update | add/remove labels · read/unread · star/unstar · archive · move |
Delete | trash (reversible) · permanent delete (explicit |
Bulk | one call acts on every message matching a query: |
Every tool takes an optional account (the email address). Omit it to use your
default.
Cleaning up in bulk
The bulk tools are query-first. They take
{ query?, mailbox?, dryRun?, confirm?, max? } and act on the whole matching set
in one pass, rather than one tool call per message. "Trash every promo older
than a year" is a single call, not four hundred.
dryRun:truepreviews the matched count and a sample, changing nothing.Destructive or large (>100 message) batches require
confirm:true.Per-message failures are reported, never hidden.
Spam and Trash are reachable with the
mailboxparam, e.g.'[Gmail]/Spam'.
For very large sweeps, the removing operations act on up to max messages per
call (default 2000) and return { matched, affected, remaining, done }. If
done is false, re-run the identical call until it is true. Messages that
were acted on leave the search scope, so it resumes cleanly and a 10,000 message
cleanup never trips your agent's tool timeout.
Providers
Every provider speaks IMAP/SMTP, so the core (search, read, send, draft, move, archive, trash, delete, attachments, bulk) works everywhere. What differs is what the protocol itself exposes:
Gmail | iCloud · Fastmail · Microsoft 365 · any IMAP host | |
Status | Fully supported | Works, smaller feature set |
Organizing | Labels, many per message | Folders, one per message |
Search | Native Gmail syntax ( | Server-side text match only |
Threads |
| Not available |
Add it with | (default) |
|
list_accounts reports each account's provider, so an agent can tell which
rules apply before it acts. Mixing is the point: a Gmail work account and an
iCloud personal account can be connected at once, and every tool takes an
optional account to choose between them.
Other ways to install

The app supervises the engine and gives you an Add Account window, an Install into Agents button, and Start at Login.
Download
Email-Local-MCP-<version>-universal.dmgfrom the latest release. One universal build runs on Apple Silicon and Intel, with Node bundled inside, so there are no prerequisites.Open the DMG and drag Email Local MCP to Applications.
The first launch is blocked. The app is ad-hoc signed and not yet notarized, so macOS refuses it once. Open System Settings > Privacy & Security, find the "Email Local MCP was blocked" notice, click Open Anyway, and confirm. macOS remembers.
xattr -dr com.apple.quarantine "/Applications/Email Local MCP.app"A mail icon appears in the menu bar. Open Add Account and connect a mailbox. The first time a password is read, macOS shows a Keychain Always Allow prompt. Click it once. (It re-prompts after each update while builds are ad-hoc signed; a notarized release will end that.)
That is the last DMG you download. The app updates itself, checking on launch, every 6 hours, and when you open the menu. Updates are cryptographically verified against a key pinned inside the app, so only releases signed by the maintainer are ever installed.

The Add Account window covers Gmail, iCloud, Fastmail, or a custom IMAP host.
The App Password never touches the app itself: it is posted once to 127.0.0.1
and the engine puts it straight in the Keychain.
brew tap marcinwalendowski/tap
brew install email-local-mcp # the CLI and MCP server
brew install --cask email-local-mcp # the menu bar appThey are independent, and most people want the first. brew install with no
flag resolves to the formula, so the app genuinely needs --cask.
Then:
claude mcp add email-local -- email-local-mcp
email-local-mcp add you@example.com --defaultThe cask does not remove the Gatekeeper step described above. Homebrew installs the app; it does not vouch for it.
On a macOS beta or seed build, brew install of the formula can fail with a
complaint that your Xcode is outdated, naming a version Apple has only released
as a Beta. That is Homebrew deriving the requirement from the OS version, not a
problem with this formula. Use the cask or npx until a stable Xcode ships.
git clone https://github.com/MarcinWalendowski/email-local-mcp.git
cd email-local-mcp && ./scripts/setup-cli.sh --install-agents
node dist/index.js add you@gmail.com --defaultOn Windows, run npm ci && npm run build in place of the setup script. The
engine runs on macOS, Windows and Linux.
Paste this into Claude Code, Cursor, or any coding agent:
Install the Email Local MCP email server for me: run
claude mcp add email-local -- npx -y email-local-mcp
Then restart yourself, confirm it worked by calling list_accounts, and walk me
through adding my first mail account with npx -y email-local-mcp add.Connect it to your agent
email-local-mcp install (or the app's Install into Agents button) writes
the right config for every agent it detects:
Agent | Transport | What gets written |
Cursor · Claude Code · VS Code · Windsurf | HTTP | local URL + |
Claude Desktop | stdio | spawn command (its own engine, same credential store) |
Restart the agent afterwards, then ask it to list_accounts.
Upgrading from a previous name
This project has shipped as gmail-mcp and as anymail-mcp. If you used
either, your accounts come across on their own the first time you start
Email Local MCP: the registry with its flags, App Passwords, and OAuth refresh
tokens. There is nothing to run.
To watch it happen, or to find out why an account did not make it:
email-local-mcp import-legacy # explicit run, with a report
email-local-mcp import-legacy --force # look again after it has already runYour old data is copied, not moved.
~/.anymail-mcp/and the old credential-store items stay where they are. Delete them once you are satisfied.It runs once. A marker at
~/.email-local-mcp/legacy-import.jsonrecords the run, so an account you delete afterwards stays deleted. If a credential could not be read, from a locked Keychain say, the marker is deliberately not written and the next start tries again.
Re-registering the MCP server is the one step that is not automatic, since the old spawn command names the old binary.
How it works
Agent (Claude Code / Desktop / Cursor ...)
│ MCP over stdio or HTTP (127.0.0.1, bearer token)
▼
Email Local MCP engine (local Node process, yours)
│ one provider per account
│
├─ GmailProvider ── ImapFlow → imap.gmail.com:993 (+ X-GM-*: labels, threads, raw search)
│ Nodemailer→ smtp.gmail.com:465
│
└─ ImapProvider ── ImapFlow → imap.mail.me.com:993 (iCloud / Fastmail / Microsoft / any host)
Nodemailer→ smtp.mail.me.com:587 folders, IMAP SEARCH
▼
Each account authenticated with its own credential, read from the OS storeGmailProvider extends ImapProvider, so Gmail is the generic IMAP behaviour
plus the X-GM-* extensions. Adding a provider means extending ImapProvider
and adding a preset. See src/node/providers/.
Why IMAP/SMTP rather than the Gmail HTTP API. Full-CRUD Gmail API access
needs restricted OAuth scopes, which for personal @gmail.com accounts forces
Google app verification plus an annual CASA security assessment, or a 7-day
token expiry in Testing mode. App Passwords over IMAP sidestep all of it and run
fine in a local process. IMAP also needs a long-lived TCP socket, so this could
not be a serverless function in any case.
The macOS app internals are in app/BUILD.md; the distribution
pipeline is in docs/DISTRIBUTION.md.
Roadmap
Generic IMAP providers: iCloud, Fastmail, and any IMAP host.
Universal DMG: one macOS app for Apple Silicon and Intel, Node bundled.
Windows and Linux CLI, using each OS's native credential store.
OAuth sign-in, which also brings in Microsoft 365 / Outlook.
Homebrew tap: a formula for the CLI and a cask for the app.
npm / npx distribution, which is now the one-line install.
Automatic import of accounts from a previous install.
Richer search for IMAP providers: map the common Gmail-style operators (
from:,subject:,has:attachment, date ranges) onto IMAP SEARCH, so a query behaves the same across accounts.More providers: Yahoo.
A sign-in button in the app, so OAuth does not need the CLI.
A notarized DMG, so the first launch opens without the Gatekeeper step.
Contributing
See CONTRIBUTING.md. Security reports: SECURITY.md.
License
MIT. See LICENSE.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityBmaintenanceEmail for AI agents. Send and receive as markdown with human oversight.Last updated71812MIT
- Alicense-qualityDmaintenanceA generic IMAP and SMTP MCP server that enables AI agents to interact with email accounts for reading, searching, and sending messages. It provides high-level tools for managing email workflows like daily digests and folder organization across any standard email provider.Last updated1MIT
- AlicenseAqualityDmaintenanceProvider-agnostic email MCP server that connects any IMAP mailbox to AI assistants, enabling email management through natural language.Last updated8AGPL 3.0
- Alicense-qualityBmaintenanceConnects any IMAP/SMTP mailbox to AI agents via MCP, enabling email read, search, send, reply, and management through natural language.Last updated0MIT
Related MCP Connectors
Hosted email MCP for AI agents with inboxes, send/receive, memory, recovery, and credits.
Shipmail MCP server for AI agent custom-domain email inboxes with REST API and webhooks.
Authenticated email gateway for AI agents — per-agent inboxes, HITL approval, SPF/DKIM verified.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/MarcinWalendowski/email-local-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server