🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@aiwerk/mcp-server-imap

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aiwerk/mcp-server-imap

IMAP/SMTP MCP server for listing, reading, searching and sending email

latest
Source
npmnpm
Version
1.2.2
Version published
Maintainers
1
Created
Source

@aiwerk/mcp-server-imap

npm version npm downloads License: MIT

IMAP/SMTP MCP server that works with any email provider. Set host, user, pass — done.

Unlike Gmail-only or Outlook-only MCP servers, this one speaks standard IMAP/SMTP — so it works with every email provider out of the box.

Why this server?

Most email MCP servers only work with one provider (Gmail, Outlook). This one works with any provider that supports IMAP:

  • Gmail, Outlook, Yahoo — yes
  • Fastmail, ProtonMail Bridge, Zoho — yes
  • Self-hosted (Dovecot, Postfix, hMailServer) — yes
  • Corporate/hosted (Hostpoint, Infomaniak, OVH) — yes

One server, every mailbox.

Highlights

  • Universal — standard IMAP/SMTP, works everywhere
  • Simple setup — just IMAP_HOST, IMAP_USER, IMAP_PASS and you're connected
  • Safety first — email sending is disabled by default (SMTP_SEND_ENABLED=false). Your AI agent can read emails but can't send anything until you explicitly opt in
  • Lazy credentials — the server starts and exposes its tool list without requiring credentials. Auth is only needed when a tool is actually called
  • Real MIME parsing — handles multipart, HTML/text, attachments, reply threading

AIWerk hosted service — email_send and email_reply are local-only

If you use this server through the AIWerk hosted service at aiwerkmcp.com, the two outgoing-mail tools are not exposed:

  • email_send
  • email_reply

The other 8 read-side tools (email_list, email_read, email_search, email_folders, email_flag, email_move, email_delete, email_attachment) work normally on the hosted service.

Why? The hosted service shares an IP across all users. If outgoing mail went out from that shared IP, the IP would appear in every recipient's Received: headers — one bad actor could damage deliverability for every user. There is no shared-IP architecture where arbitrary user sends works safely.

How to send mail then? Run the server locally, where outgoing mail goes from your own IP and your own provider reputation. Three paths:

  • Ad-hoc one-email CLI — see the next section. Zero config, one-shot.
  • Direct stdio MCP server in your client (Cursor, Claude Desktop, OpenClaw) — point your client config at npx -y @aiwerk/mcp-server-imap with your IMAP_* and SMTP_* env vars including SMTP_SEND_ENABLED=true.
  • Local @aiwerk/mcp-bridgenpx -y @aiwerk/mcp-bridge install imap-email --catalog aiwerkmcp.com, then point your client at the local bridge endpoint.

In all three cases the mail goes from your home / office IP, not from the hosted service.

Ad-hoc one-email CLI

Note: On the AIWerk hosted service, the email_send and email_reply MCP tools are not exposed (the service shares an IP across all users, so allowing arbitrary sends would risk every user's deliverability). Use any of the three paths below to send email locally.

Need to send a single email from the command line — for example, to deliver a draft your AI agent composed? Use aiwerk-send-email:

SMTP_HOST=smtp.gmail.com \
SMTP_PORT=587 \
SMTP_USER=me@gmail.com \
SMTP_PASS='app-password' \
SMTP_FROM='Me <me@gmail.com>' \
npx -y @aiwerk/mcp-server-imap aiwerk-send-email \
  --to "alice@example.com" \
  --subject "Re: invoice" \
  --body "Got it, will pay Monday."

On success, exits 0 and prints JSON: {"ok":true,"messageId":"...","envelope":{...}}

On failure, exits 1 with the error on stderr. Credentials are never printed.

All CLI arguments

ArgumentRequiredDescription
--toYesRecipient(s), comma-separated
--subjectYesSubject line
--bodyOne of body/htmlPlain-text body
--htmlOne of body/htmlHTML body (both → multipart)
--in-reply-toNoMessage-ID of original message (thread preservation)
--referencesNoSpace-separated reference IDs
--ccNoCC recipients, comma-separated
--bccNoBCC recipients, comma-separated

CLI environment variables

VariableRequiredDefaultDescription
SMTP_HOSTYesSMTP server hostname
SMTP_PORTYes587 for STARTTLS, 465 for implicit TLS
SMTP_USERYesSMTP username / email address
SMTP_PASSYesPassword or app-specific password
SMTP_FROMYesSender address (Name <email> or plain email)
SMTP_TLSNofalsetrue for implicit TLS (port 465); false for STARTTLS (port 587)

Install

Three ways to get email tools — pick the one that fits.

1. Quick (single email)aiwerk-send-email CLI above: no MCP client needed, one command sends one email.

2. Direct stdio MCP server — all 10 email tools exposed to your AI agent:

npx -y @aiwerk/mcp-server-imap

3. Local bridge with catalog UX — install via the AIWerk catalog for a guided setup:

npx -y @aiwerk/mcp-bridge install imap-email --catalog bridge.aiwerk.ch

Option 1 — Hosted (zero setup)

No local runtime, no env vars on your machine — credentials are AES-256-GCM encrypted server-side via HashiCorp Vault.

  • Sign up at aiwerkmcp.com.
  • Install IMAP Email from the catalog and paste your IMAP/SMTP credentials.
  • Point your MCP client (Claude.ai, Cursor, Hermes, …) at your hosted endpoint:
    https://bridge.aiwerk.ch/u/<your-user-id>/mcp
    
    with your Bearer token.

All 10 tools appear immediately. Install other AIWerk recipes from the same bridge.

Option 2 — Self-hosted (npx)

Run directly — you manage the credentials:

IMAP_HOST="imap.example.com" \
IMAP_USER="user@example.com" \
IMAP_PASS="app-password" \
SMTP_HOST="smtp.example.com" \
npx @aiwerk/mcp-server-imap

The server starts immediately and responds to tools/list even without credentials — they're only required when a tool is actually called (lazy credentials).

Tools (10)

ToolPurpose
email_listList emails from a folder
email_readRead a single message with full body
email_searchSearch by from/to/subject/date/unread
email_foldersList all folders with message counts
email_moveMove messages between folders
email_flagSet read/star/flag status
email_deleteMove messages to Trash
email_sendSend a new email (requires opt-in)
email_replyReply to a message (requires opt-in)
email_attachmentList or download attachments

Configuration

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "email": {
      "command": "npx",
      "args": ["-y", "@aiwerk/mcp-server-imap"],
      "env": {
        "IMAP_HOST": "imap.example.com",
        "IMAP_USER": "you@example.com",
        "IMAP_PASS": "your-app-password",
        "SMTP_HOST": "smtp.example.com"
      }
    }
  }
}

Cursor / Windsurf / VS Code

Same config format in the respective MCP settings.

AIWerk hosted service

If you want zero-setup, install via aiwerkmcp.com — see Option 1 above.

Environment variables

IMAP (required)

VariableDefaultDescription
IMAP_HOSTIMAP server hostname
IMAP_USEREmail address or username
IMAP_PASSPassword or app-specific password
IMAP_PORT993IMAP port
IMAP_TLStrueUse TLS
IMAP_TIMEOUT30000Connection timeout (ms)

SMTP (optional, for sending)

VariableDefaultDescription
SMTP_HOST${IMAP_HOST}SMTP server hostname
SMTP_PORT465SMTP port
SMTP_USER${IMAP_USER}SMTP username
SMTP_PASS${IMAP_PASS}SMTP password
SMTP_TLStrueUse TLS
SMTP_FROM${IMAP_USER}Sender address
SMTP_SEND_ENABLEDfalseMust be true to enable sending

Debug

VariableDefaultDescription
IMAP_DEBUGfalseVerbose IMAP protocol logging

Security

  • Email sending is disabled by default — set SMTP_SEND_ENABLED=true to enable
  • Credentials are loaded lazily (only when a tool is called, not at startup)
  • No credentials are logged
  • Keep credentials in .env or a secret manager — never commit them to git

Supported providers

Tested with: Hostpoint, Gmail (app password), Outlook/Microsoft 365, Yahoo Mail, Fastmail, Dovecot, Postfix.

Works with any standards-compliant IMAP/SMTP server.

Build from source

git clone https://github.com/AIWerk/mcp-server-imap
cd mcp-server-imap
npm install
npm run build
node dist/server.js

Contributing

Issues and PRs are welcome! Please open an issue first for larger changes.

Changelog

See CHANGELOG.md for version history.

About AIWerk MCP

Part of the AIWerk MCP platform — curated, signed MCP recipes served either as npm packages for self-hosting or through our multi-tenant hosted service at aiwerkmcp.com.

Other AIWerk MCP servers:

Browse the full catalog (20+ recipes including GitHub, Linear, Notion, Stripe, …) at aiwerkmcp.com.

License

MIT — AIWerk

Keywords

mcp

FAQs

Package last updated on 02 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts