@aiwerk/mcp-server-imap

@aiwerk/mcp-server-imap

Universal IMAP/SMTP MCP server that works with any email provider, providing tools to read, search, send, and manage emails.

Category
访问服务器

README

@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:

  1. Ad-hoc one-email CLI — see the next section. Zero config, one-shot.
  2. 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.
  3. 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

Argument Required Description
--to Yes Recipient(s), comma-separated
--subject Yes Subject line
--body One of body/html Plain-text body
--html One of body/html HTML body (both → multipart)
--in-reply-to No Message-ID of original message (thread preservation)
--references No Space-separated reference IDs
--cc No CC recipients, comma-separated
--bcc No BCC recipients, comma-separated

CLI environment variables

Variable Required Default Description
SMTP_HOST Yes SMTP server hostname
SMTP_PORT Yes 587 for STARTTLS, 465 for implicit TLS
SMTP_USER Yes SMTP username / email address
SMTP_PASS Yes Password or app-specific password
SMTP_FROM Yes Sender address (Name <email> or plain email)
SMTP_TLS No false true 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.

  1. Sign up at aiwerkmcp.com.
  2. Install IMAP Email from the catalog and paste your IMAP/SMTP credentials.
  3. 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)

Tool Purpose
email_list List emails from a folder
email_read Read a single message with full body
email_search Search by from/to/subject/date/unread
email_folders List all folders with message counts
email_move Move messages between folders
email_flag Set read/star/flag status
email_delete Move messages to Trash
email_send Send a new email (requires opt-in)
email_reply Reply to a message (requires opt-in)
email_attachment List 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)

Variable Default Description
IMAP_HOST IMAP server hostname
IMAP_USER Email address or username
IMAP_PASS Password or app-specific password
IMAP_PORT 993 IMAP port
IMAP_TLS true Use TLS
IMAP_TIMEOUT 30000 Connection timeout (ms)

SMTP (optional, for sending)

Variable Default Description
SMTP_HOST ${IMAP_HOST} SMTP server hostname
SMTP_PORT 465 SMTP port
SMTP_USER ${IMAP_USER} SMTP username
SMTP_PASS ${IMAP_PASS} SMTP password
SMTP_TLS true Use TLS
SMTP_FROM ${IMAP_USER} Sender address
SMTP_SEND_ENABLED false Must be true to enable sending

Debug

Variable Default Description
IMAP_DEBUG false Verbose 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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选