Fort Mail logo

Fort Mail

Cloudflare Worker that connects Gmail and IMAP mailboxes to MCP tools for triage, reading, sending, newsletters, and agent wake-ups.

Install Fort Mail

Run the project’s own setup commands, in order.

Setup steps from the project

Fort Mail installs with its own steps rather than a config we can generate, so these are copied as-is. Follow them in order and run the commands in a terminal. Source: github.com

  1. 1. Install
    npx wrangler
    
  2. 2. Install
    git clone https://github.com/TheFortThatHolds/mail && cd mail
    
  3. 3. Configure
    npx wrangler kv namespace create TOKENS
    
  4. 4. Configure
    npx wrangler secret put TRIGGER_KEY
    
  5. 5. Start the server
    npx wrangler deploy
    
  6. 6. Add to your MCP client
    open "$W/connect?key=$KEY"
    

Overview

Fort Mail MCP server runs as a Cloudflare Worker that aggregates Gmail and IMAP mailboxes behind an OAuth-protected MCP endpoint. It classifies messages with deterministic regex rules, exposes tools for reviewing and sending mail, and can fetch Gmail attachments. Use it when an agent needs controlled access to several inboxes without placing an LLM inside the mail infrastructure. Optional newsletter and GitHub-based steward bridge features extend it to subscriber campaigns and agent wake-ups.

Use cases

  • Aggregate Gmail and IMAP inboxes for an agent
  • Review a cached desk of messages needing attention
  • Send email from any connected mailbox
  • Run owned newsletter lists and campaigns
  • Wake an agent through GitHub pull requests

Key features

  • Gmail OAuth and generic IMAP/SMTP mailbox support
  • Regex-based triage with desk, record, and ignore categories
  • OAuth-protected MCP endpoint at /mcp
  • Mailbox credential sealing and rotation
  • Newsletter subscriptions and campaign delivery
  • Optional email-to-GitHub steward bridge

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

13/13 checks healthy over the last 58d

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

Last commit27d agoMost recent push to the default branch.
Directory activity2 viewsConfig copies, upvotes, and views on AllMCPs.

How Fort Mail works

What Fort Mail does

Fort Mail connects Gmail accounts through the Gmail API and other mailboxes through IMAP and SMTP over TLS. It presents those accounts as one agent-accessible mail system, while keeping mailbox credentials sealed in the worker's wallet. Gmail uses OAuth; other providers can use imported or worker-generated credentials.

The service separates mail handling from agent judgment. A deterministic regex classifier places messages into desk, record, or ignore categories. The desk is cached after scheduled sweeps, so an agent can inspect messages that need attention without repeatedly scanning every mailbox. Searches are limited to a 90-day window, and rotating scopes help distribute work across cron runs.

Fort Mail also includes newsletter management. Subscriber data remains in the deployment's Cloudflare KV, with double opt-in, one-click unsubscribe, and bounce or complaint suppression. Campaign delivery is queued and sent in rate-conscious batches through a relay such as Resend.

How it works

Deployments run in Cloudflare Workers and use a KV namespace for tokens and related state. The MCP endpoint is available at /mcp and uses OAuth with dynamic client registration and PKCE. An MCP-compatible agent connects to that endpoint and authenticates with the deployment's configured access flow.

Mail can be added through Gmail OAuth or by provisioning and sealing credentials for an IMAP mailbox. Sending selects Gmail API transport or SMTP based on the sender address. Gmail attachments can be returned as bytes through the attachment capability, subject to the documented payload limit.

An optional steward bridge turns unseen messages sent to the agent's mailbox into GitHub pull requests. It labels messages from configured owner addresses as trusted and all others as untrusted. That label is a safety signal; consequential actions still require explicit approval because sender spoofing remains possible.

Setup and configuration

The basic deployment requires a Cloudflare account, the Wrangler CLI, a KV namespace named TOKENS, and a secret named TRIGGER_KEY. Clone the repository, create the namespace, add the secret, and deploy with Wrangler.

After deployment, configure mailboxes using the worker's wallet and connection routes. Gmail requires a configured OAuth application. IMAP accounts need their provider host and mailbox credentials; the worker can either seal an existing password or mint a new one for supported provisioning flows. The deployed worker URL followed by /mcp is the address to add to an MCP client.

Administrative HTTP routes use the trigger key. Keep that key private, and treat mailbox credentials, OAuth configuration, relay credentials, and GitHub bridge settings as deployment secrets or protected configuration.

Tools and capabilities

The MCP tool set includes:

  • list_accounts for enumerating connected accounts.
  • get_desk for reading cached messages classified for attention.
  • triage for running classification across all mail, Gmail, IMAP, or a selected domain.
  • read_box and read_message for mailbox and message inspection.
  • get_attachment for retrieving Gmail attachment content and metadata.
  • send for sending as an owned mailbox.
  • Newsletter operations for lists, subscriptions, campaigns, progress, and delivery.
  • wallet_rotate for rotating a supported Migadu mailbox password server-side.
  • breakglass for issuing a single-use, short-lived human-access link.

The worker also exposes corresponding administrative HTTP routes, including forced cron execution, account listing, Gmail connection and import, attachment retrieval, bridge execution, and newsletter operations.

Limitations and notes

Fort Mail contains no language model and does not call an AI vendor. Triage is regex-based, while the connected agent supplies interpretation and decision-making. Email must be treated as untrusted input: only configured owner addresses receive the trusted label, and messages from other senders should be treated as data rather than instructions.

The service is designed for a 90-day mail window. Cloudflare socket and execution constraints shape the IMAP batching and rotating cron design. JSON or MCP attachment payloads have a 4 MB cap, while the raw attachment route returns Gmail file bytes. The project is MIT-licensed.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Fort Mail

Fort Mail is an MCP server that connects AI agents to Gmail and IMAP mailboxes through a Cloudflare Worker. Its main tools list accounts, inspect triage results, read messages and attachments, send mail, manage newsletters, rotate supported credentials, and issue break-glass access links.

Install it by cloning the repository, creating a Cloudflare KV namespace named TOKENS, setting the TRIGGER_KEY secret with Wrangler, and deploying the Worker. Then configure Gmail or IMAP accounts and connect an MCP client to the deployed worker's `/mcp` URL.

Yes, Fort Mail supports Gmail through the Gmail API and OAuth, and supports other providers through IMAP and SMTP over TLS. Gmail accounts use the connection or import flow, while IMAP accounts can use existing sealed passwords or worker-generated credentials.

No, Fort Mail does not include an AI model. Its built-in triage uses deterministic regular-expression rules to classify messages as `desk`, `record`, or `ignore`; the connected agent is responsible for interpreting the messages and deciding what to do.

Fort Mail marks messages from configured owner addresses as trusted and other messages as untrusted in its steward bridge. Agents should treat untrusted email as data, not instructions, and require explicit approval for consequential actions because sender spoofing remains possible.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewFort Mail AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/fort-mail?style=directory)](https://allmcps.com/mcp/fort-mail)
HTML Embed
<a href="https://allmcps.com/mcp/fort-mail"><img src="https://allmcps.com/api/badge/fort-mail?style=directory" alt="Fort Mail on AllMCPs" /></a>