yahoo-mail-mcp

yahoo-mail-mcp

MCP server for Yahoo Mail over IMAP+SMTP that enables AI assistants to manage emails fully—listing, reading, searching, threading, flagging, moving, archiving, handling attachments, and sending/reply/forward/draft—using an app-specific password.

Category
访问服务器

README

yahoo-mail-mcp

A Model Context Protocol (MCP) server for Yahoo Mail over IMAP + SMTP. Gives AI assistants full email management — list, read, search, thread, flag, move, delete/trash, archive, folders, attachments, and send/reply/forward/draft — using your Yahoo app-specific password.

Built with the official MCP SDK, imapflow, mailparser, nodemailer, and zod. TypeScript, MIT licensed.

Features (31 tools)

Read

  • list_folders – list all IMAP folders with special-use type
  • list_emails – paginated listing with UID, flags, attachment metadata
  • read_email – full text/html body, headers, attachment metadata
  • read_raw – raw RFC 822 source for header/inspection
  • search_emails – filter by subject/sender/body, recipient, date range, unread/flagged/answered
  • get_thread – reconstruct a conversation via In-Reply-To references
  • get_unsubscribe – List-Unsubscribe header (one-click URL / mailto address)
  • extract_contacts – most frequent senders from recent mail
  • extract_calendar – parse ICS calendar attachments

Manage

  • mark_read / mark_unread
  • flag_emails / unflag_emails
  • move_emails / delete_emails (to Trash) / archive_emails
  • cleanup_folder – bulk delete/archive by sender, age, unread, flagged
  • create_folder / rename_folder

Attachments

  • list_attachments – metadata only (no body download)
  • get_attachment – single attachment as base64 (max 5 MB)
  • get_attachments – all attachments as base64 (5 MB each, 25 MB total)

Send (SMTP)

  • send_email
  • reply_email – sets In-Reply-To / References, auto-marks original as answered
  • forward_email – quotes the original message
  • reply_draft / forward_draft – save a reply/forward as a draft (no send)
  • save_draft / send_draft

Stats

  • get_email_stats – per-folder message and unread counts
  • mailbox_stats – per-folder counts + size (when the server exposes it)

Requirements

  • Node.js >= 18
  • A Yahoo Mail account with 2-step verification enabled and an app-specific password. Generate it at Yahoo Account Security -> Manage app passwords (16 chars, no spaces).

Setup

cp .env.example .env
# edit .env: set YAHOO_EMAIL and YAHOO_APP_PASSWORD
npm install
npm run build

Optional overrides: YAHOO_IMAP_HOST, YAHOO_IMAP_PORT, YAHOO_SMTP_HOST, YAHOO_SMTP_PORT (465 for implicit TLS), YAHOO_MCP_HOST, YAHOO_MCP_PORT, YAHOO_MCP_TOKEN (Bearer token for remote/SSE access).

Usage

stdio (Claude Desktop / Claude Code / Cursor):

{
  "mcpServers": {
    "yahoo-mail": {
      "command": "node",
      "args": ["/absolute/path/to/yahoo-mcp/dist/index.js"],
      "env": {
        "YAHOO_EMAIL": "you@yahoo.com",
        "YAHOO_APP_PASSWORD": "your-app-password"
      }
    }
  }
}

SSE / remote (for Claude.ai or network clients):

YAHOO_MCP_TOKEN=secret npm run start:sse
# SSE endpoint: http://127.0.0.1:3000/sse

If YAHOO_MCP_TOKEN is set, all SSE requests must include Authorization: Bearer <token>.

Streamable HTTP (single endpoint, stateless — recommended for public/remote):

YAHOO_MCP_TOKEN=secret npm run start:http
# POST http://127.0.0.1:8080/  (MCP endpoint)
# GET  http://127.0.0.1:8080/health  (health probe)

Stateless mode works with any MCP client: no session handshake is required, so each request may be handled by a fresh connection/instance. Requests must carry Authorization: Bearer <token> (Bearer token set via YAHOO_MCP_TOKEN).

Deploy to Google Cloud Run (free tier)

The containerized server is designed to run cost-free on Cloud Run: min-instances=0, max-instances=1, requests billed only while serving.

  1. Fill in gcloud-env.yaml.example -> env.yaml (local, gitignored) with YAHOO_EMAIL, YAHOO_APP_PASSWORD, YAHOO_MCP_TOKEN.
  2. gcloud auth login && gcloud config set project <PROJECT>
  3. ./scripts/deploy-gcloud.sh us-central1

The script builds via Cloud Build and prints the service URL. Requests are forwarded to the container on port 8080 (the app reads the PORT env var).

Note: Cloud Run's own front end reserves the exact path /healthz on *.run.app and never forwards it; the app's health probe is therefore served at /health.

In Claude.ai, add a Remote MCP server: URL is the service URL, and add header Authorization: Bearer <YAHOO_MCP_TOKEN>.

Connecting to Claude

  • Claude.ai — native remote MCP server: URL = service URL, request header Authorization: Bearer <token>. The server is stateless, so it reconnects cleanly after any idle gap.
  • Claude Desktop — Desktop can't speak raw Streamable HTTP, so run the local stdio bridge (scripts/stdio-bridge.mjs) that forwards to the remote endpoint and attaches the Bearer token. Add this exact block to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
  "mcpServers": {
    "yahoo-mail": {
      "command": "node",
      "args": ["/ABS/PATH/TO/yahoo-mcp/scripts/stdio-bridge.mjs"],
      "env": {
        "MCP_URL": "https://YOUR-SERVICE-REGION.run.app/"
      }
    }
  }
}

The bridge reads YAHOO_MCP_TOKEN from the env block if present, otherwise from the project's env.yaml (auto-detected). Restart Claude Desktop after editing. See docs/CLAUDE_INTEGRATION.md for the full guide and troubleshooting.

Design history & gotchas

The notes on adapting this server to Claude / Streamable HTTP / Cloud Run — mcp-remote OAuth vs Bearer tokens, stateless enforceStrictCompliance, /healthz reserved by Cloud Run, concurrency=1 → 429, and more — live in docs/LEARNINGS.md.

Verify your credentials first

npm run check:auth

Read-only IMAP login check + SMTP verify() (no mail is ever sent). See scripts/check-auth.ts.

Development

npm run dev          # run src via tsx
npm run build        # tsc -> dist
npm run typecheck    # tsc --noEmit
npm test             # vitest
npm run smoke        # end-to-end: boot server, list tools, list folders

Layout

src/
  index.ts          # MCP server: stdio, --sse, or --http (Streamable HTTP) transport
  config.ts         # zod-validated environment config
  loadEnv.ts        # loads .env then .secrets.env (no dotenv dependency)
  http.ts           # stateless Streamable HTTP handler: bearer auth, /health
  tools.ts          # 24 tool definitions (zod input schemas)
  mail/
    imap.ts         # IMAP service (imapflow, single shared connection)
    smtp.ts         # SMTP service (nodemailer: send/reply/forward/draft)
    types.ts        # shared types
scripts/
  check-auth.ts     # feasibility/auth verification
  smoke.ts          # MCP end-to-end smoke test
  deploy-gcloud.sh  # build + deploy to Cloud Run (gcloud, uses env.yaml)
  verify-remote.ts  # SDK client end-to-end check of a remote HTTP server
  push-all.sh       # push to public + private remotes (see SECURITY.md)
test/               # vitest tests

Design notes (Yahoo realities)

  • Yahoo does not advertise IDLE, MOVE, UIDPLUS, or SPECIAL-USE. imapflow transparently emulates MOVE (COPY + delete + EXPUNGE) and special-use is resolved by folder name, so all tools work unchanged.
  • No IMAP IDLE watcher, OAuth, or CalDAV/CardDAV: Yahoo doesn't support them, and app passwords avoid OAuth entirely.
  • One shared IMAP connection with per-mailbox locks respects Yahoo's limit of ~5 concurrent connections per IP.

Security

  • Credentials are read from local .env / .secrets.env files that are never committed. The public repository contains zero secrets.
  • Delete is a soft delete (move to Trash); nothing is permanently expunged.

License

MIT. See LICENSE.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选