imap-mcp-server
Allows searching and retrieving emails from an iCloud mailbox via IMAP, including indexing and querying of email content for use by AI models.
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., "@imap-mcp-serversearch my mailbox for emails from my boss about Q3 budget"
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.
imap-mcp
A generic IMAP → MCP server on Cloudflare Workers. It indexes a mailbox into Cloudflare's storage on a cron, then serves it to an MCP client as search, retrieval and narrow write tools — so a model can answer questions against fifteen years of mail without the mailbox itself being in the loop on every query.
Contributions are welcome; there is no support commitment. The project is run against one personal iCloud mailbox, and it is generic by design rather than by ambition — host, port and credentials are configuration, not constants — with a second provider (Gmail, #42) on the way to being exercised. Deploy your own instance from your own fork; a release is the signal that something worth merging has landed.
┌─────────────────────────────┐
IMAP over TLS │ imap-mcp (one Worker) │
┌──────────────┐ │ │
│ mailbox │ ◀──▶│ sync half src/sync │
│ (iCloud) │ │ cron + queues, owns creds │
└──────────────┘ │ │ writes ▲ writes, │
│ ▼ │ audited │
│ ┌──────────────────┐ │
│ │ D1 (+FTS5), R2 │ │
│ └──────┬───────────┘ │
│ │ reads │
│ ▼ │ ┌──────────────┐
│ MCP half src/mcp │◀────▶│ MCP client │
│ auth gate, tools, audit │ HTTP │ │
└─────────────────────────────┘ └──────────────┘Six tools: search_messages, get_message, get_thread, flag_message,
move_message, create_draft. Bodies leave one at a time, capped, inside an
untrusted-content envelope; there is no send and no delete, structurally —
the codebase contains no SMTP client and no delete path. Every write is
audited. docs/architecture.md is the full design
essay.
Deploy
What it costs, before you click: you need the Workers Paid plan (US$5/month at time of writing). Not for Queues — that has been available on the free plan since February 2026 — but for CPU: the free plan caps a Worker at 10 ms of CPU per invocation, and parsing a message's MIME, decoding its attachments and extracting its text does not fit in that. Paid raises the cap to 30 seconds. Everything else fits comfortably in the paid plan's included usage for one mailbox. You also need a mailbox app-specific password; on iCloud it grants full mailbox access including SMTP send, so treat it like the account password.
The button provisions the database, queues and bucket, prompts for the four
values only you can supply — the mailbox host, the mailbox user, its
app-specific password, and an MCP API key of your choosing — and deploys.
Migrations run inside the deploy script, so the schema is applied on the first
deploy and on every redeploy after you merge an upstream change. You get a
working endpoint authenticated by the API key; putting Cloudflare Access in
front of it is an optional, documented upgrade. The button deploys main;
deploying a tagged release
instead means putting /tree/<tag> on the button URL yourself, until the
first by-hand button verification confirms tags work there.
docs/deploy.md is the full guide — the button path, the
manual path, and the configuration reference.
docs/authentication.md covers the two auth modes
and the trade between them.
Deployed and not sure it is working? Ask it:
curl -s -H "Authorization: Bearer $MCP_API_KEY" https://<worker>.workers.dev/status | jqdocs/observability.md reads that document line by
line, and covers the logs, the queues, and what a stalled backfill looks like.
Related MCP server: stalwart-mail-mcp
Quickstart, for working on it
No Cloudflare account needed — the whole suite runs offline:
pnpm install
pnpm run test # vitest: workerd + a scripted-IMAP-server protocol suite
pnpm run lint # biome (lint + format)
pnpm run typecheck # wrangler types + tsc --noEmit
pnpm run dead-code # knip
pnpm run build # wrangler deploy --dry-runCONTRIBUTING.md has the rest — including the one hard
requirement: a change to provider behaviour needs a test in the
scripted-server harness.
Documentation
the design essay: sync internals, gap detection, the schema, the untrusted-content envelope, the IMAP client's quirks | |
nothing → working instance: button, manual path, secrets, migrations | |
every value the Worker reads: the four a deploy prompts for, the committed knobs, and the optional extras | |
API key vs Cloudflare Access, the upgrade ordering, lockout recovery | |
is it working? the | |
running the suite offline, the provider-test requirement, triage | |
the reporting channel, and an honest list of what is and is not guaranteed | |
the compact invariants file for agents and humans alike |
Status and roadmap
Everything below "done" is implemented and green in the test suite — a suite that runs the real protocol client against a scripted server, and the real Worker runtime against local storage. What has not happened yet is a full production run against a real mailbox on the current architecture: that is #39, and until it lands, "done" means done in the suite and the spikes, not proven in production.
mailbox interface, schema, sync + fan-out + incremental sync, attachments, MCP server, Access gate, retrieval and write tools — done | |
one Worker, two auth modes, deploy button — done | |
docs restructure, releases — this | |
rebuild the deployment, run the backfill to completion | |
flag reconciliation over CONDSTORE | |
| |
file cf-imap defects upstream; spikes: static-bearer client support, Gmail over IMAP |
Licence
MIT — see LICENSE. The IMAP protocol client is
cf-imap by Exerra, also MIT; its
licence text ships in the tarball but no license field is set in its
package.json, so licence scanners misreport it. The build currently
installs a patched fork (lswith/cf-imap)
while its fixes are upstreamed —
docs/architecture.md has the
defect table, where each was filed, and which pull request fixes it.
This server cannot be installed
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
- AlicenseNot gradedqualityBmaintenanceConnects multiple IMAP and SMTP mailboxes to MCP clients like ChatGPT without exposing credentials, enabling email search and thread retrieval via natural language.1Apache 2.0
- AlicenseNot gradedqualityCmaintenanceConnects AI agents to self-hosted Stalwart mail servers via a Cloudflare Worker and JMAP, enabling mailbox search, reading, listing, and two-step draft-and-send email operations through MCP.MIT
- AlicenseNot gradedqualityCmaintenanceEnables interaction with Gmail through MCP, supporting search, read, send, reply, forward, draft management, labels, and multiple accounts, deployed on Cloudflare Workers.MIT
- AlicenseNot gradedqualityCmaintenanceEnables connecting Gmail to MCP clients, allowing search, read, send, reply-all, forward, attachments, drafts, labels, and thread management across multiple Google accounts at once via a self-hosted Cloudflare Worker.MIT
Related MCP Connectors
Read, search, send, organize, draft and schedule email across your inboxes from any MCP client.
Hosted email MCP for AI agents with inboxes, send/receive, memory, recovery, and credits.
Cloudflare Workers MCP server: email-validator
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/lswith/imap-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server