Connect Claude Code to your email

chainmail is an open-source email MCP server for Claude Code. A daemon holds your mail passwords and checks every send against your allowlist. Claude Code reaches it through chainmail mcp, and you reach it from the CLI.

What chainmail is

chainmail is one Go binary for Linux and macOS. The same binary runs the daemon, the CLI and the MCP server. The daemon keeps every password and token in an age-encrypted vault, and no call returns one. It makes every connection to your mail servers over IMAP and SMTP.

chainmail mcp is the MCP server. Claude Code starts it as a subprocess and talks to it over stdio. It holds no secrets and no mail logic. Each tool call goes over a Unix socket to the daemon, which checks the send policy and writes a row to the audit log.

chainmail is free, and the source is on GitHub under the MIT license.

Install chainmail

Homebrew installs the binary, its shell completions and its man page. Release archives, Nix and building from source are on the install page.

brew install yaklabco/tap/chainmail
chainmail version

Set up the daemon and an account

chainmail bootstrap sets up the daemon to run as its own system user, with one account. Run it as yourself, not as root. It asks for sudo once.

chainmail bootstrap [email protected]

Bootstrap finds the provider from the address, prints its plan and asks for the account's app password. It then creates the chainmail user and the chainmail-clients group, installs the service, stores the password and tests the login. --dry-run prints the plan and changes nothing. Gmail, iCloud and IMAP accounts covers each provider.

Only members of chainmail-clients can reach the daemon, and bootstrap adds you to the group. Log out and back in, or run newgrp chainmail-clients. Then check the account, which is named after the address's local part, you here:

chainmail accounts list
chainmail accounts test you

Add chainmail to Claude Code

This registers the server for every project. $(command -v chainmail) fills in the binary's full path.

claude mcp add --scope user chainmail -- "$(command -v chainmail)" mcp

On NixOS with the chainmail module, the binary is at /run/current-system/sw/bin/chainmail:

claude mcp add --scope user chainmail -- /run/current-system/sw/bin/chainmail mcp

On Linux, chainmail mcp finds the daemon's socket at /run/chainmail/chainmail.sock with no settings. On macOS, bootstrap writes the socket's path to your cli.toml when you have none, and Claude Code reads the same file when it runs as you.

Group membership applies to new logins only. If Claude Code started before you joined chainmail-clients, log in again. On Linux you can also start it under the group with sg chainmail-clients -c claude.

Try it

Ask Claude Code to list your accounts, then to search for unread mail in the inbox. The first request calls the list_accounts tool and the second calls search. Then ask it to send a message to an address that is not on your allowlist. The send comes back held, and the message waits in the account's Drafts folder. The agent should tell you so and stop.

The audit log shows each of those calls with client kind mcp:

chainmail audit --since 10m --output table

What Claude Code can do with your mail

chainmail mcp serves 56 tools. 54 are always listed. expunge and delete_folder are listed only while the policy allows them.

  • It searches every account with Gmail-style operators, and opens messages, threads and folders. Reading never marks mail read.
  • It sends, replies and forwards with Markdown bodies and attachments, and keeps drafts. Every send goes through the policy.
  • It moves, copies, archives and trashes mail, sets flags and Gmail labels, and creates and renames folders.
  • It waits for new mail with read_events. A named group resumes where it stopped.
  • It keeps work items, a tree from objectives down to tasks, with mail threads linked to them.
  • It writes rules that label, file, forward and archive mail as it arrives, and dry-runs each rule first.
  • It reads the agenda, answers invites, checks free/busy and creates events on Google and CalDAV calendars.

The vault, logins, the audit log and the daemon's admin commands have no MCP tool, so only you run them from the shell. MCP tools lists every tool with its arguments, and the features page groups them by area.

Sends that wait for you

A send to anyone off your allowlist is saved to the account's Drafts folder and is never transmitted. The allowlist is in the daemon's config, which root owns, so neither your user nor the daemon can loosen it. Let Claude send email safely explains the policy.

An agent that can run sudo without a password can get around the daemon. Run Claude Code from an account that cannot.

Other MCP clients

Any MCP client that starts stdio servers takes the same command, with the single argument mcp. Agent setup shows the Codex config and the JSON mcpServers form. An agent that runs shell commands can use the CLI instead, which prints JSON when its output is piped.

Connect an agent and Working with mail in the manual go further.