Skip to main content
Glama
email-mcp

email-mcp

by a1exsun

🚀 Quick start

Let your AI set it up

Paste this one line into Claude Code, Codex or any assistant that can run shell commands:

Read https://raw.githubusercontent.com/a1exsun/email-mcp/main/skills/setup-email-mcp/SKILL.md and follow it to set up email-mcp for me.

The setup skill clones and builds the project, works out your provider's servers from your address, writes .env, verifies the login and registers the server with your client. It never asks for a password in chat: you paste the app password into .env yourself.

Or do it by hand

Clone and build (requires Node.js ≥ 22.18):

git clone https://github.com/a1exsun/email-mcp.git && cd email-mcp && npm install

Create your configuration and fill it in (see Configuration):

cp .env.example .env

Check that every mailbox can log in to IMAP and SMTP:

node --env-file=.env dist/index.js check

Connect your client and restart it.

Related MCP server: IMAP MCP Server

🧰 Tools

Then just ask in plain language:

"Summarize the unread mail in my work inbox from this week." "Find the invoice Alice sent in October and save the PDF to ~/Downloads." "Draft a reply to the latest message from my landlord, but don't send it."

⚙️ Configuration

The server is configured through environment variables. The simplest way is a .env file loaded with Node's built-in --env-file flag; .env.example documents every variable.

1 Not needed when OUTLOOK_CLIENT_ID is set.

Several mailboxes

List a short name for each mailbox in EMAIL_ACCOUNTS, then prefix every variable with the upper-cased name:

EMAIL_ACCOUNTS=work,home

WORK_EMAIL_ADDRESS=me@company.com
WORK_EMAIL_PASSWORD=...
WORK_IMAP_HOST=imap.company.com
WORK_SMTP_HOST=smtp.company.com

HOME_EMAIL_ADDRESS=me@icloud.com
HOME_EMAIL_PASSWORD=...
HOME_IMAP_HOST=imap.mail.me.com
HOME_SMTP_HOST=smtp.mail.me.com
HOME_SMTP_PORT=587

Every tool then accepts account (work or home here) and defaults to the first name in the list. Names may contain letters, digits and underscores.

📮 Providers

EMAIL_ADDRESS must be your @icloud.com address, because that is the login. Put the custom-domain sender in EMAIL_FROM:

EMAIL_ADDRESS=me@icloud.com
EMAIL_FROM="Alex <me@mydomain.com>"

Microsoft disabled password login for IMAP and SMTP, so Outlook mailboxes sign in with OAuth2.

  1. In the Azure portal → App registrations, create an app:

    • Supported account types: any organizational directory + personal Microsoft accounts.

    • Under Authentication, turn on Allow public client flows.

    • Under API permissions, add the delegated permissions IMAP.AccessAsUser.All and SMTP.Send.

    • Copy the Application (client) ID into OUTLOOK_CLIENT_ID.

  2. Log in once from a terminal (device-code flow: open the link it prints and enter the code):

    node --env-file=.env dist/index.js login

    With several mailboxes, add the account name: node --env-file=.env dist/index.js login work.

  3. The token is cached in ~/.email-mcp/ with permissions 600 and refreshes automatically.

On Microsoft 365 business accounts an administrator may need to enable SMTP AUTH for the mailbox.

🔌 Connect your client

Point your MCP client at dist/index.js and let Node load the .env file. Use absolute paths.

claude mcp add email -s user -- node --env-file=/absolute/path/to/email-mcp/.env /absolute/path/to/email-mcp/dist/index.js
[mcp_servers.email]
command = "node"
args = ["--env-file=/absolute/path/to/email-mcp/.env", "/absolute/path/to/email-mcp/dist/index.js"]
{
  "mcpServers": {
    "email": {
      "command": "node",
      "args": ["--env-file=/absolute/path/to/email-mcp/.env", "/absolute/path/to/email-mcp/dist/index.js"]
    }
  }
}

You can also pass the variables through the client's own env setting instead of a .env file.

Command line

Command

Purpose

node dist/index.js

Start the MCP server on stdio (what your client runs)

node dist/index.js check [account]

Log in to IMAP and SMTP for each mailbox and report OK / FAILED

node dist/index.js login [account]

One-time Outlook OAuth2 device-code login

🔒 Safety

IMPORTANT

send_email and forward_email really send mail. Keep your client's confirmation prompt on for them, and prefer save_draft for unattended runs.

  • Use an app password or authorization code, never your main account password. It is stored in plain text in .env, so keep that file private (chmod 600 .env). It is git-ignored.

  • Nothing is deleted permanently. delete_emails moves mail to Trash, and delete_folder refuses folders that still contain mail.

  • Your mail stays between you and your provider. The server talks only to the IMAP/SMTP hosts you configure (and Microsoft's login endpoint for Outlook); there is no telemetry.

  • Email is untrusted input. A message can contain text written to manipulate an AI assistant. Review what the assistant intends to do before approving actions triggered by mail content.

🛠️ Development

npm install     # install and build
npm test        # run the tests (node --test, runs the .ts sources directly)
npm run build   # compile to dist/

Built on the official @modelcontextprotocol/sdk, imapflow, nodemailer, mailparser and @azure/msal-node.

Issues and pull requests are welcome. Please run npm test before opening a PR.

📄 License

MIT © Alex Sun

Available Tools

13 tools
create_folderD

Create a folder.

Inputs: path (required), account.

delete_emailsA

Delete emails by moving them to Trash (recoverable; never permanent).

Inputs: uids (required), folder, account.

delete_folderA

Delete an EMPTY folder. Move or delete its emails first.

Inputs: path (required), account.

download_attachmentB

Save an email attachment to a local directory. Returns the saved path.

Inputs: uid (required), filename (required), save_dir (required), folder, +1 more.

forward_emailB

Forward an email (with its attachments) to new recipients, with an optional note on top.

Inputs: to (required), uid (required), cc, note, +2 more.

list_foldersB

List all folders. specialUse marks Inbox/Sent/Drafts/Trash/Junk/Archive.

Inputs: account.

move_emailsB

Move emails to another folder (archive, categorize).

Inputs: uids (required), dest_folder (required), folder, account.

read_emailB

Read one email: headers, text body (HTML converted to text) and attachment list.

Inputs: uid (required), folder, account, mark_read, +1 more.

rename_folderC

Rename or move a folder.

Inputs: path (required), new_path (required), account.

save_draftA

Save an email to the Drafts folder without sending it, so a human can review and send it.

Inputs: to (required), body (required), cc, bcc, +6 more.

search_emailsB

Search a folder, newest first. All filters are optional and combined with AND.

Inputs: to, body, from, seen, +9 more.

send_emailB

Send an email, optionally as a reply (pass reply_to_uid) and with attachments.

Inputs: to (required), body (required), cc, bcc, +6 more.

set_flagsA

Mark emails read/unread (seen) and starred/unstarred (flagged). Omitted values stay unchanged.

Inputs: uids (required), seen, folder, account, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 13 tools

    Disambiguation5/5

    Each tool has a clearly distinct operation: folder listing/creation/renaming/deletion, email search/read/send/save/forward/move/delete, flag updates, and attachment download. There is minimal overlap because reply is handled as an option on send_email, while save_draft and forward_email remain clearly separate workflows.

    Naming Consistency5/5

    All tool names use a consistent snake_case verb_noun pattern such as list_folders, read_email, move_emails, and delete_folder. This makes the set predictable and easy to scan.

    Tool Count5/5

    The server exposes 13 tools, which is well-scoped for email management. Folders, messages, drafts, attachments, and flags each get focused operations without an excessive number of tools.

    Completeness4/5

    The tool set covers the main email lifecycle: folder CRUD, search/read, send/reply, save draft, forward, move, delete, flags, and attachment download. Minor gaps exist, such as explicit draft editing or reply-all, but core workflows are well supported.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      B
      quality
      D
      maintenance
      Enables external AI agents to read, send, and manage email over IMAP/SMTP via MCP, including inbox listing, search, drafts, scheduled/batch sending, and operations like reply, archive, and labels.
      30
      3
      -
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants and MCP clients to manage multiple email accounts, including searching, reading, sending, replying to, forwarding, organizing, and bulk-deleting messages across IMAP/SMTP, with encrypted credential storage and connection pooling.
      1,009 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants to read, search, send, manage, schedule, and analyze email across multiple IMAP/SMTP accounts through MCP, including drafts and templates, provider-aware labels, bulk operations, real-time IMAP IDLE watching with AI triage, verification-code capture, calendar extraction, and analytics.
      31 npm
      ISC
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI assistants to search, read, send, reply to, forward, organize, and bulk-delete email across multiple IMAP/SMTP mailboxes, with AES-256-encrypted credential storage, connection pooling, and folder management. Supports 15+ pre-configured providers and simultaneous multi-account access from any MCP client.
      1,009 npm
      MIT