What mail-muncher does
The mail-muncher MCP server separates mailbox access from the program consuming email. It connects to an IMAP mailbox or to Gmail through the Gmail API, evaluates messages against ordered rules, and writes matching content to a destination directory. The same archive can be read directly by an agent or queried through MCP.
Messages are preserved as .eml files and can also be rendered as Markdown. The Markdown output places message headers in YAML frontmatter, keeps the body as text, and places extracted attachments in a neighboring directory. Archived messages include fields such as sender, recipients, date, message ID, thread ID, account, rule, labels, and attachment names.
Rules can read filter values from a plain text file owned by another program. The file is re-read at the beginning of each cycle, so changing a line changes which messages are delivered without editing configuration or restarting the process.
How it works
Choose either provider: imap or provider: gmail. IMAP supports Gmail, Fastmail, iCloud, Proton Bridge, work accounts, and self-hosted mail servers, with the folders listed in mailboxes. Gmail uses a read-only OAuth token and covers the Gmail account except Spam and Trash unless those are requested.
The file-based workflow runs one cycle with mail-muncher run or polls continuously with mail-muncher daemon --interval 5m. Matching messages are placed under the configured destination using a year-and-month directory layout. Thread IDs are included on every message, allowing conversations to be grouped by that field.
The mail-muncher MCP server runs with mail-muncher mcp and provides questions and actions over the same archive. The documented agent workflow includes checking subscriptions, seeing what arrived, reading a thread, and requesting a fetch. A daemon and the MCP process can run together: one fills the archive while the other answers queries.
Setup and configuration
IMAP uses an app password obtained from the mail provider. The configuration uses password_cmd, whose standard output supplies the password; there is deliberately no plain password setting. The default IMAP mailbox is [INBOX], and additional folders can be listed in mailboxes.
Gmail requires a Google Cloud project, a Desktop-app OAuth client, and the gmail.readonly scope. Run mail-muncher auth after completing the Gmail setup. Credentials are stored in token.json with mode 0600. Testing-mode consent screens cause the token to expire every seven days, requiring authentication again.
A rule specifies a name, a match condition, a destination, and output formats. For example, a from_domains_file match can point at a text file containing domains, while formats: [eml, markdown] requests both archive forms.
Tools and capabilities
- Read from IMAP or Gmail without mailbox-writing operations.
- Apply ordered rules to select messages.
- Re-read file-based filter inputs on every cycle.
- Write byte-faithful
.eml messages.
- Produce Markdown with YAML frontmatter and extracted attachments.
- Run once, poll on an interval, or serve the archive over stdio MCP.
- Emit a machine-readable manifest in each operating mode.
- Query subscriptions, new arrivals, threads, and fetch operations through the MCP workflow.
Limitations and notes
IMAP read-only behavior is enforced by the program, not by the credential. Mailboxes are opened with read-only operations, message bodies are fetched without marking them read, and the provider code does not issue write, append, or expunge commands. However, an IMAP app password itself is a full mail credential that could permit sending or deletion if used elsewhere.
Gmail read-only access is enforced by Google because the requested OAuth scope is gmail.readonly; the resulting token cannot send, delete, label, or modify messages. Gmail setup takes longer than IMAP and requires periodic reauthentication when the consent screen is in Testing mode.
The MCP interface is stdio-based, and the archive is local to the configured destination.