A small inbox that AI agents can read.

A Cloudflare Worker that files forwarded emails into lanes. An agent can read only the lanes it has been granted, through a small MCP server, so it can see your receipts and invoices without getting at the rest of your mail.

Experimental. It was built for personal use and is only lightly tested. Read the threat model before pointing an agent at real mail.

Unofficial. Not affiliated with, endorsed by, or sponsored by Cloudflare.

What it does

Forwarded mail goes into lanes.

You forward the emails you choose (receipts, invoices, notifications) from your own mailbox to a lane's address, which is a long random string nobody could guess. The Worker checks the mail really came from you, turns it into plain text, keeps the original, and lets the agents you've granted that lane read it. Nobody else can.

Lanes
A lane is one kind of email that needs its own handling, like receipts or supplier invoices. Each has its own address, allowed senders, attachment rules, size limits and retention. They live in the database, not in the code.
Who it accepts mail from
Before anything is stored, the Worker checks the sender and the authentication results (DKIM and SPF, or the forwarder's own record for server-side forwards). Anything that fails is dropped without a reply and logged with headers only. The one exception is a verified forward to a paused lane, which bounces so you notice.
Plain text, every time
Nothing in the pipeline uses AI, so the same email always gives the same text. HTML is converted, zero-width and bidi characters are removed, and links become text (domain). It also tries to drop hidden text, but that's best effort and won't catch everything.
What an agent can do
It has four tools: list_messages, get_message, create_share_link and mark_processed. Anything written by a third party comes back in a field whose name starts with untrusted.
Get started

Getting a first lane going.

Four steps to an agent reading its first message.

  1. Deploy the Worker from a plain clone with npm run deploy.
  2. Create a lane. The CLI prints its address; point a mail rule in your mailbox at it.
  3. Create an agent token and grant it the lanes it should see. It's shown once, in a terminal only.
  4. Connect your agent to the MCP endpoint with that bearer token.

Steps 2 and 3, at a terminal:

# point the CLI at your account
$ export AGENT_INBOX_CLI_API_TOKEN=...
$ export CLOUDFLARE_ACCOUNT_ID=...
$ export AGENT_INBOX_WORKER_NAME=...
$ export AGENT_INBOX_MAIL_HOSTNAME=mail.example.com

# create a lane, then give an agent access to it
$ npm run cli -- lanes create receipts --description "Shop receipts"
$ npm run cli -- agents create my-agent
$ npm run cli -- agents grant my-agent receipts
$ npm run cli -- messages inject-test receipts --text "Total 3.50 GBP"

The full guide covers DNS, Email Routing and deploy tokens. There's also a prompt you can give an agent to do the mechanical parts, but it hasn't been run end to end yet, so treat a first run as a trial.

Admin and CLI

In a browser or at a terminal.

The command-line tool does everything. The optional admin interface does the day-to-day tasks in a browser.

The admin overview in light mode. A Needs attention panel lists two transform failures, a paused lane and four recent rejections, above a table of five lanes with their status, message counts and when each last received mail. The admin overview in dark mode. A Needs attention panel lists two transform failures, a paused lane and four recent rejections, above a table of five lanes with their status, message counts and when each last received mail.
Overview. Every lane at a glance, and anything that needs attention. Lanes and agents are managed from here.
A message in the admin interface, in light mode. The subject, the body and the original sender each sit inside a dashed amber block labelled as untrusted email content, beside the envelope and authentication details. The body text is an invented attempt to give an agent instructions. A message in the admin interface, in dark mode. The subject, the body and the original sender each sit inside a dashed amber block labelled as untrusted email content, beside the envelope and authentication details. The body text is an invented attempt to give an agent instructions.
A message. Email text is only ever plain text in a marked block, and a body loads only on request.

The admin interface has its own hostname and signs you in with Cloudflare Access. The Worker checks the Access token on every request, so a misconfigured Access application does not leave it open. It is off unless configured.

The same from the terminal.

The CLI prints metadata only, and never a message body unless asked.

$ npm run cli -- lanes list
LANE             STATUS  MESSAGES  UNPROCESSED  LAST RECEIVED             ADDRESS
---------------  ------  --------  -----------  ------------------------  -------------------------------------------------
alerts           active  69        2            2026-11-19T23:15:16.068Z  inbox+x5db7ys3gq2nwm4zc6hta5k2rp@mail.example.com
bank-statements  paused  12        0            2026-11-13T23:35:16.068Z  inbox+m7ta4cx2qs5bnz6dy3wkpj7h2f@mail.example.com
invoices         active  58        0            2026-11-19T21:35:16.068Z  inbox+p4yw2nq6dz7kxm3ta5hbcj2r6s@mail.example.com
receipts         active  144       3            2026-11-19T23:23:16.068Z  inbox+k3x7qmz2ab5wd4ycp6jrn2tv7e@mail.example.com
school-letters   active  38        4            2026-11-19T23:00:16.068Z  inbox+c2hq5wz7ntb3xy4ka6dmr2p7je@mail.example.com

$ npm run cli -- agents list
AGENT            STATUS                            CREATED                   LANES
---------------  --------------------------------  ------------------------  -----------------------------------
finance-agent    active                            2026-09-05T23:35:16.068Z  bank-statements, invoices, receipts
household-agent  active                            2026-10-10T23:35:16.068Z  school-letters
ops-agent        active                            2026-09-30T23:35:16.068Z  alerts
trial-agent      revoked 2026-10-30T23:35:16.068Z  2026-09-20T23:35:16.068Z  -

$ npm run cli -- lanes get invoices
Lane:           invoices (active)
Address:        inbox+p4yw2nq6dz7kxm3ta5hbcj2r6s@mail.example.com
Description:    Supplier invoices for the home office.
Allowed senders: (deployment default)
Forwarded from: accounts@supplier.example.com (dmarc or dkim), *@billing.example.net (dmarc)
Shareable:      yes
Attachments:    application/pdf (max 10.0 MiB each)
Transforms:     none
Limits:         message 25.0 MiB, text 200000 chars, retention 365 days

Transform failures: 0
Active share links: 0

$ 
Architecture

How it's put together.

Everything can be managed from your own machine with the CLI, which talks to the Cloudflare API.

Email RoutingYour forward arrives at inbox+<token>@mail.example.com. The token is 160 random bits.
Worker: email()Finds the lane from the token, then checks the sender and authentication, the lane's paused state, and its size and attachment policy. It converts the message to clean text and runs any transforms the lane has, such as unzipping. Anything that fails is dropped silently, except a verified forward to a paused lane, which bounces.
D1 and R2Clean text and metadata go in D1. The raw message and its attachments go in R2.
Worker: fetch()Serves the MCP server, with bearer tokens and every query limited to the lanes an agent has been granted. Short-lived share links serve file downloads from a second hostname. If you turn it on, the admin interface is served from a third, and only to requests that carry a valid Cloudflare Access token.
Worker: scheduled()Runs every hour to purge messages past their retention, expired share links and old rejection records.
agent-inbox CLIRuns on your machine. Manages lanes, agent tokens and secrets, and prints metadata only unless you ask for message bodies.

Every email body is treated as untrusted, because somebody else wrote it. The Worker doesn't try to spot malicious content. It keeps the risk down by being strict about who can send mail in and what an agent can read, so how safe this is also depends on what the agent itself is allowed to do. Read the threat model before connecting one.

Licence

MIT licensed.

You can use, copy, modify and distribute it, including commercially, as long as the copyright and licence notice stay with it. It comes as is, without warranty.

LicenceMIT
Copyright2026 Luke Redpath
Security issuesSECURITY.md
Source and issuesgithub.com/lukeredpath/cloudflare-agent-inbox