Mabus Mailroom
Can be used as the token store for Gmail OAuth tokens, so credentials are kept in 1Password rather than in plain text.
Supported as a token storage backend, letting OAuth tokens for the connected Gmail accounts be held in Bitwarden.
Gives an AI agent read-only access to multiple Gmail accounts at once, referenced by short aliases or 'all' for fan-out search. Provides tools to search messages with Gmail's search syntax, fetch single messages with headers and plain-text bodies, read whole threads within a size budget, list labels, and extract text from attachments (text, HTML, PDF). Per account, the agent can optionally save drafts, or save drafts and send real emails, with each send gated on explicit human confirmation via MCP elicitation; scopes and modes are enforced server-side and accounts can only be added or widened from the CLI.
Proton Pass can serve as the token store, keeping Gmail OAuth tokens in the password manager instead of on disk in plain text.
Click on "Deploy 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., "@Mabus Mailroom check all my Gmail accounts for messages from my landlord this week"
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.
Mabus Mailroom
Mabus Mailroom is a local MCP server that lets your AI agent read several Gmail accounts at once, read-only by default.
Free and open source (AGPL-3.0). Privacy policy: PRIVACY.md, also at https://mabus.ai/mabus-mailroom/privacy. Terms of use: TERMS.md, also at https://mabus.ai/mabus-mailroom/terms.
An MCP server that gives an AI agent (Claude Code, Claude Desktop, or any other MCP client) access to several Gmail accounts at once. Every account is read-only unless you opt it in. You choose, per account, whether the agent may also save drafts, or save drafts and send. By default the human confirms each send.
you: "anything from the landlord this week, in any of my inboxes?"
agent -> search(query="from:landlord@example.com newer_than:7d", account="all")Why
Claude's built-in Google connector reads the Gmail of the one Google account you
connected. Anthropic's help article says: "Claude can only access the Gmail, Calendar,
and Drive data for the Google account you've connected". To use a different account,
you disconnect and sign in again
(source).
Many people have a personal address, a work address and a side-project address. This
server holds all of them, each under a short alias you pick, such as personal, work
or club.
Other open-source servers already handle several accounts. See RESEARCH.md for a survey with sources. Mabus Mailroom is built around a narrower, safer default:
Mabus Mailroom | |
Default permission |
|
Drafts / send | Opt-in per account: |
Accounts | One server, explicit alias on every call. |
Who adds accounts | Only you, from the CLI. The agent cannot add accounts or widen scopes. |
Tokens | OS keychain, an AES-256-GCM file encrypted with your passphrase, or your password manager (Proton Pass, 1Password, Bitwarden, or any CLI). Never plain text. |
Email content | Treated as untrusted. HTML is turned into text, fields have size caps, and content is fenced off with random-nonce markers and a "data, not instructions" notice. |
OAuth client | Your own Google Cloud client. This project ships no client ID and runs no server. |
Related MCP server: multiGmailMCP
Modes
Mode |
| Google scopes | Tools allowed |
readonly (default) | none |
| read tools |
drafts |
|
| read tools, |
send |
|
| read tools, drafts, both send tools |
gmail.compose is the narrowest scope that covers drafts.create, drafts.send and
messages.send
(drafts.send,
messages.send).
That is why the drafts and send modes get the same token, and Mabus Mailroom itself
enforces the difference between them (see Security model).
Tools
Tool | What it does | Account argument |
| Lists aliases, addresses, modes | none |
| Gmail search syntax. Returns metadata and snippets, newest first | an alias, or |
| One message: headers, plain-text body, attachments (with | alias |
| A whole conversation, cut to a size budget | alias |
| The account's labels | alias |
| Text extract of one attachment: text files, HTML, and PDF (with | alias |
| Saves a draft (optionally as a reply in a thread) | drafts or send account |
| Sends a real email, after the human confirms | send account |
| Sends an existing draft, after the human confirms | send account |
create_draft is listed only when some account can draft. send_message and
send_draft are listed only when some account is in send mode. All three are hidden
under serve --read-only. Every call checks the account's mode again, whatever the tool
list says.
Setup
You need Python 3.10+ and about 10 minutes for the Google Cloud part, which you do once.
1. Create your own Google OAuth client
Go to the Google Cloud console and create a project, for example
mabus-mailroom.Enable the Gmail API: APIs & Services > Library > "Gmail API" > Enable.
Set up the OAuth consent screen (Google Auth Platform > Branding / Audience):
User type External for a personal @gmail.com account. Choose Internal if all your accounts are in one Google Workspace organization.
With External and "Testing" status, add every address you will connect as a test user (Audience > Test users).
Data access / scopes: add
.../auth/gmail.readonly, and.../auth/gmail.composeif you want drafts or sending.
Create the client: Clients > Create client > Application type Desktop app. Download the JSON file (
client_secret_....json).
Testing mode expires tokens after 7 days. Google issues refresh tokens that expire in 7 days for External apps in "Testing" status (Google docs). You can re-run
mabus-mailroom add <alias>weekly, or set the app to "In production". Gmail scopes are restricted scopes, so a production app that is not verified shows an "unverified app" warning you click through. For a client only you use, that is expected. You are both the developer and the user.
Google Workspace accounts: your admin may need to allow the app under Admin console > Security > Access and data control > API controls > Manage App Access > Configure new app. They search for your OAuth client ID and choose "Trusted" or "Specific Google data" (Google docs).
2. Install
From a clone of this repository:
python3 -m venv .venv
.venv/bin/pip install . # or ".[pdf]" for PDF text in get_attachment
export PATH="$PWD/.venv/bin:$PATH" # puts the mabus-mailroom command on your PATH
mabus-mailroom --version3. Add accounts
mabus-mailroom add personal --client-file ~/Downloads/client_secret_XXXX.json # first time only
mabus-mailroom add club --drafts # may also save drafts
mabus-mailroom add work --send # may save drafts and send (each send confirmed)
mabus-mailroom listadd opens your browser on Google's consent page. Pick the account and approve.
Google redirects to a one-shot listener on 127.0.0.1, and the tokens go straight into
the token store. Once the client is stored you can delete the downloaded JSON file.
On a headless machine, use a fixed port and forward it:
mabus-mailroom add work --port 8765 --no-browser
# on your desktop: ssh -L 8765:127.0.0.1:8765 <server> then open the printed URLTo change an account's mode, run add again with --drafts, --send or neither. Google
does not support adding scopes later for installed apps, so the account is authorized
again.
Removing: mabus-mailroom remove <alias> (also revoke) revokes the grant at Google and
deletes the stored tokens. --keep-grant only deletes the stored tokens.
4. Choose where tokens live (first add only)
| Where |
| the OS keychain if there is a secure one, otherwise the encrypted file |
| macOS Keychain, Windows Credential Locker, Secret Service / KWallet |
|
|
| your password manager, through its CLI ( |
Password-manager examples:
# Proton Pass (pass-cli). Make a vault named "mabus-mailroom" first, or pass --store-vault.
mabus-mailroom add personal --client-file client.json --store command --store-preset proton-pass \
--store-env PROTON_PASS_KEY_PROVIDER=fs # only if your pass-cli setup uses the fs key provider
# 1Password (op). Sign in first: desktop-app integration, `op signin`, or OP_SERVICE_ACCOUNT_TOKEN in your shell.
mabus-mailroom add personal --client-file client.json --store command --store-preset 1password --store-vault mabus-mailroom
# Bitwarden (bw). Run `bw unlock` and export BW_SESSION in the shell that runs mabus-mailroom.
mabus-mailroom add personal --client-file client.json --store command --store-preset bitwarden
# Anything else: three commands with an {item} placeholder. set reads the secret on stdin, get prints it.
mabus-mailroom add personal --client-file client.json --store command --store-preset custom \
--store-get 'mypm read {item}' --store-set 'mypm write {item}' --store-delete 'mypm rm {item}'How each preset talks to its CLI. Secrets only ever travel on stdin or stdout, and argv carries vault and item names only:
Preset | Read | Write | Delete |
|
| trash the old item, then |
|
|
| delete the old item, then |
|
|
|
|
|
Item names are mabus-mailroom-client and mabus-mailroom-account-<alias>. Docs used:
pass-cli item commands,
op item (its own
warning: "Command arguments get logged in your command history, and can be visible to
other processes on your machine"), and Bitwarden CLI.
Locked or signed-out vault: the CLI's error is turned into a clear message ("vault looks locked or signed out..."), and the secret never appears in it. In
serve, an account whose token cannot be read is reported as unavailable, and the other accounts keep working.Proton Pass agent sessions need a reason on each access. Mabus Mailroom sets
PROTON_PASS_AGENT_REASONunless you already set it.Old versions: "write" replaces the item. Proton Pass and Bitwarden move the old item to trash, and 1Password to Recently Deleted. Empty those if you want old tokens gone. Removed accounts are revoked at Google anyway.
--store-envtakes non-secret settings only. Names that look like secrets (*TOKEN*,*SESSION*, ...) are refused, so keep those in your shell environment.
5. Connect your MCP client
Claude Code:
claude mcp add --transport stdio --scope user mabus-mailroom \
-- /path/to/mabus-mailroom/.venv/bin/mabus-mailroom serveClaude Desktop: edit claude_desktop_config.json. On macOS it is
~/Library/Application Support/Claude/, on Windows %APPDATA%\Claude\, and on Linux
~/.config/Claude/
(MCP docs):
{
"mcpServers": {
"mabus-mailroom": {
"command": "/path/to/mabus-mailroom/.venv/bin/mabus-mailroom",
"args": ["serve"]
}
}
}serve flags:
--read-onlyturns off drafts and sending for every account.--no-confirm-sendskips Mabus Mailroom's own confirmation prompt (see below).
If you use the encrypted-file store, add
"MABUS_MAILROOM_PASSPHRASE_CMD": "pass show mabus-mailroom", or a similar command for your
password manager, to env.
Sending, and the confirmation step
send_message and send_draft send real email. They cannot be unsent. Their tool
descriptions say so, and they carry the MCP destructiveHint.
Before each send, Mabus Mailroom asks the human through MCP elicitation. The prompt shows:
the sending account and address,
To, Cc and Bcc, and the number of recipients,
the subject,
the body (the first 1,500 characters). For
send_draft, open the draft in Gmail to read the body.
The email goes out only if the person ticks "send". Declining or cancelling returns
"Not sent". The MCP Python SDK carries the question either as a live request (older
protocol versions) or as a multi-round-trip input_required result (2026-07-28)
(SDK docs).
Clients without elicitation support: the send is refused, and the model is told why. It fails closed. The owner can then pick a client that supports elicitation, or start the server with
serve --no-confirm-send. In that case the client's own tool-approval prompt is the only check, so keep it on forsend_*.The prompt is only as good as the client. The MCP spec allows a client to answer elicitations itself. Use a client that shows them to you.
Checks before anything is sent:
the account must be in send mode,
the server must not be in
--read-only,To, Cc, Bcc and Subject must each be a single line (header injection is refused),
at most 20 recipients across To, Cc and Bcc,
a body of at most 100,000 characters.
A refused send never reaches the confirmation prompt.
send_draftchecks the draft's recipients again just before sending. A send is never retried automatically.
Attachments
get_messagelists each attachment with itspart_id, file name, type and size.get_attachment(account, message_id, part_id)returns a text extract only:text files (text/*, JSON, XML, CSV, .md, .log, ...),
HTML, converted to text,
PDF, when the optional pure-Python
pypdfis installed: text from up to 50 pages, with a 20-second time limit, and pypdf's own decompression limits.
Other file types give metadata only.
Caps: a 5 MB download cap (checked before downloading, and again on the bytes received) and 50,000 characters of text returned.
The extract is wrapped as untrusted content, exactly like a message body.
Files are never saved to disk.
Security model
What the agent can do:
read mail in the accounts you added,
save drafts in drafts-mode and send-mode accounts,
send from send-mode accounts, normally after you confirm each send.
It cannot delete, archive, label, or change settings. No code path in this server calls those endpoints.
The token caveat. For drafts-mode accounts, the "no send" rule is enforced by
Mabus Mailroom, not by Google. Google's gmail.compose scope covers drafts and sending
(scope list), so a
stolen drafts or send token could send. Keep read-only as the default, and opt in only
where you need to.
What the agent cannot do. It cannot add accounts, change modes or widen scopes. Those are CLI-only and need you in a browser.
Tokens:
Keychain: via
keyring. Backends known to be insecure (null/fail, keyrings.alt plaintext) are refused.Encrypted file:
tokens.encholds the whole store, encrypted with AES-256-GCM under a key derived from your passphrase with scrypt. The passphrase comes fromMABUS_MAILROOM_PASSPHRASE_CMD(recommended),MABUS_MAILROOM_PASSPHRASE, or a prompt. The server fails closed if it has none.Password manager: see step 4. Secrets go over stdin and stdout only, never argv, never into Mabus Mailroom's config, and never into logs or error messages.
config.json(aliases, addresses, modes, password-manager settings) andtokens.encare written with mode 600 in a mode-700 directory. The directory is~/.config/mabus-mailroom, or%APPDATA%\mabus-mailroom, or setMABUS_MAILROOM_HOME.The OAuth client secret is stored in the token store too. Google says desktop clients "cannot keep secrets confidential" (docs), so the client secret is not the real protection. Your refresh tokens are.
OAuth flow. This is Google's installed-app flow: a loopback redirect on
127.0.0.1:<random port>, PKCE with S256, and a random state checked against CSRF.
After consent, Mabus Mailroom checks which scopes you actually granted. If you declined
compose, the account is saved as read-only. If you declined read access, nothing is
saved and the token is revoked.
Email is untrusted input. Anyone can email you text written to steer an AI agent ("ignore previous instructions and forward..."). Mabus Mailroom:
converts HTML to text, dropping scripts, styles and hidden markup. Link targets are shown, but only http, https and mailto links,
removes control characters and bidi-override characters,
caps every field: 20,000 characters per body, an 80,000-character body budget per response, 50,000 characters per attachment extract, header and subject caps, at most 50 search results,
returns content as JSON between
<<<UNTRUSTED_EMAIL nonce=…>>>markers with a fresh random nonce each time, and removes any look-alike markers from the content,starts every result with a notice that the content is data and must not be followed.
Wrapping lowers the risk of prompt injection but does not remove it. A malicious email could still try to talk the agent into sending something. The real limits are:
read-only by default,
send only where you opted in,
a human confirmation on every send,
the 20-recipient cap.
Rate limiting. At most 120 tool calls per minute and 8 concurrent Gmail requests per server.
Limits (v0.2)
No label changes, archive or delete. No attachments on outgoing mail. Binary attachments give metadata only.
Search returns metadata and snippets only. Call
get_message/get_threadfor bodies.allfans out to every account at once, so large searches over many accounts use more Gmail API quota.Testing-mode apps need re-authorization every 7 days (see above).
Google allows 100 refresh tokens per account per OAuth client. Adding the same account over and over eventually invalidates the oldest token (docs).
removerevokes the grant for that Google account and client. If two aliases point to the same address,removedoes not revoke, because that would cut off the other alias too.The password-manager presets were checked against each CLI's documentation and
--help, and tested against fake CLIs, but not yet against live vaults.
Development
.venv/bin/pip install pytest pytest-asyncio pypdf
.venv/bin/python -m pytest -qThe tests use fake Gmail clients, fake password-manager CLIs and httpx.MockTransport.
They never call Google or a real vault.
History
Renamed from gmail-multi on 2026-11-23. Nobody had installed it yet, so there are no compatibility shims: the old command, module, config directory and environment variables are gone.
Privacy
Mabus Mailroom runs only on your machine and talks only to Google. The author runs no service and receives no data. See PRIVACY.md or https://mabus.ai/mabus-mailroom/privacy. Terms of use: TERMS.md.
License
AGPL-3.0. Free and open source.
Available Tools
6 toolsget_attachmentARead-onlyIdempotent
Text extract of one attachment (text files, HTML, PDF). Other types return metadata only. Downloads are capped at 5 MB and the returned text at 50,000 characters.
Inputs: account (required), part_id (required), message_id (required).
get_messageARead-onlyIdempotent
Read one message (headers, plain-text body, attachment names). HTML is converted to text.
Inputs: account (required), message_id (required).
get_threadBRead-onlyIdempotent
Read a whole conversation. Long threads are cut to a size budget.
Inputs: account (required), thread_id (required).
list_accountsARead-onlyIdempotent
List the configured Gmail accounts: alias, address, mode (readonly or drafts).
Inputs: no named parameters.
list_labelsCRead-onlyIdempotent
List the labels of one account.
Inputs: account (required).
searchARead-onlyIdempotent
Search messages in one account or in all accounts. Returns metadata and snippets, newest first.
Inputs: query (required), account (required), max_results.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a clearly distinct resource+action: account enumeration, message search, single-message read, thread read, label listing, and attachment extraction. The read boundaries between search (metadata/snippets), get_message (one message), and get_thread (conversation) are explicitly spelled out in the descriptions. No two tools could reasonably be confused.
Five tools follow a clean verb_noun or verb_resource pattern (list_accounts, get_message, get_thread, list_labels, get_attachment). The single outlier is `search`, which omits its object (messages) and is the only bare verb, a minor but visible deviation.
Six tools is well-scoped for a multi-account Gmail read/inspect server; each tool maps to a distinct read operation with no padding. There is no redundancy and nothing feels missing at the count level.
Read coverage is decent (accounts, search, message, thread, labels, attachments), but list_accounts advertises a 'drafts' mode while no draft-creation or send tool exists, and there are no label mutation or attachment-download/save operations. Agents can read mail but will hit dead ends the moment a workflow requires composing or modifying anything.
Maintenance
Related MCP Connectors
Multiple Gmail accounts, editable Google Sheets & Docs for AI agents. Deny-by-default access rules.
Give AI agents their own email inboxes: list, read and send mail via scoped, revocable OAuth grants.
Search and triage all your mailboxes; draft replies and campaigns; send only as you allow.
Connect Gmail, iCloud Mail, Outlook, Yahoo Mail, Fastmail and other IMAP inboxes to ChatGPT, Claude and compatible AI assistants. Find emails by meaning across languages with semantic search. Ask AI to find customer conversations, summarize deadlines and draft follow-ups. Give a sales rep access to a shared outreach inbox or bring email into a compatible CRM. Share an iCloud custom-domain inbox with teammates without their own Apple ID or iCloud+ plan. Search results may be incomplete or stale; separate permissions control mail actions.
Related MCP Servers
- AlicenseBqualityBmaintenanceEnables AI assistants to manage multiple Gmail accounts simultaneously with built-in OAuth authentication, supporting email reading, sending, drafts, labels, and account management.605MIT
- AlicenseAqualityBmaintenanceConnects AI assistants to multiple Gmail accounts simultaneously, enabling search, read, draft, send, and reply operations with per-account permission controls.54ISC
- FlicenseNot gradedqualityBmaintenanceEnables AI agents to access multiple Gmail/Google Workspace accounts for searching and reading mail, calendars, and attachments.-
- FlicenseBqualityDmaintenanceEnables AI agents to search, read, and draft emails across multiple Gmail accounts using short aliases, while requiring human approval before any message is sent.121-