npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

jay-email-mcp

v1.0.1

Published

Email MCP 是一个基于 Node.js 的邮件服务模块,提供 IMAP、SMTP 协议的邮件查询和发送功能,支持通过 JSON-RPC 接口进行调用。

Readme

Email MCP

Email MCP 是一个基于 Node.js 的邮件服务模块,提供 IMAP、SMTP 协议的邮件查询和发送功能,支持通过 JSON-RPC 接口进行调用。

功能特性

  • 邮件接收:使用 IMAP 协议获取邮件列表和邮件详情
  • 邮件发送:使用 SMTP 协议发送邮件,支持纯文本和 HTML 内容
  • 邮件管理:标记邮件为已读/未读、删除邮件
  • 文件夹管理:获取邮箱文件夹列表
  • JSON-RPC 接口:提供标准化的接口调用方式

技术栈

  • Node.js
  • imap
  • mailparser
  • nodemailer

安装

# 克隆项目
git clone <repository-url>

# 进入项目目录
cd email-mcp

# 安装依赖
npm install

配置

项目使用环境变量进行配置,需要设置以下环境变量:

| 环境变量 | 描述 | 示例值 | |---------|------|-------| | ACCOUNT | 邮箱账号 | [email protected] | | PASSWORD | 邮箱密码 | your-password | | SMTP_URL | SMTP 服务器地址 | smtp.example.com | | SMTP_PORT | SMTP 服务器端口 | 465 | | SMTP_SSL | SMTP 是否使用 SSL | true | | IMAP_URL | IMAP 服务器地址 | imap.example.com | | IMAP_PORT | IMAP 服务器端口 | 993 | | IMAP_SSL | IMAP 是否使用 SSL | true | | POP3_URL | POP3 服务器地址 | pop3.example.com | | POP3_PORT | POP3 服务器端口 | 995 | | POP3_SSL | POP3 是否使用 SSL | true |

运行

# 直接运行
node email-mcp-server.js

# 或者使用环境变量运行
[email protected] PASSWORD=your-password SMTP_URL=smtp.example.com SMTP_PORT=465 SMTP_SSL=true IMAP_URL=imap.example.com IMAP_PORT=993 IMAP_SSL=true node email-mcp-server.js

MCP 配置

要将 Email MCP 集成到 MCP 系统中,需要在 MCP 配置文件中添加以下配置:

1. 配置示例

在 MCP 配置文件(通常是 mcp.jsonconfig.json)中添加以下内容:

{
  "services": {
    "email": {
      "type": "executable",
      "path": "node",
      "args": ["email-mcp-server.js"],
      "cwd": "/path/to/email-mcp",
      "env": {
        "ACCOUNT": "[email protected]",
        "PASSWORD": "your-password",
        "SMTP_URL": "smtp.example.com",
        "SMTP_PORT": "465",
        "SMTP_SSL": "true",
        "IMAP_URL": "imap.example.com",
        "IMAP_PORT": "993",
        "IMAP_SSL": "true",
        "POP3_URL": "pop3.example.com",
        "POP3_PORT": "995",
        "POP3_SSL": "true"
      }
    }
  }
}

2. 配置说明

  • type: 设置为 executable,表示这是一个可执行文件服务
  • path: 执行文件路径,这里使用 node
  • args: 执行参数,指定 email-mcp-server.js 文件
  • cwd: 工作目录,设置为 email-mcp 项目的路径
  • env: 环境变量,设置邮箱相关的配置信息

3. 验证配置

配置完成后,启动 MCP 系统,然后通过 MCP 客户端调用 Email MCP 的工具,验证服务是否正常运行。

4. 注意事项

  • 确保 MCP 系统有足够的权限执行 email-mcp-server.js
  • 确保环境变量中的邮箱配置信息正确
  • 确保邮箱账号开启了 IMAP/SMTP 服务
  • 部分邮箱需要使用应用专用密码(如 Gmail、Outlook 等)

API 接口

服务器提供以下 JSON-RPC 方法:

1. initialize

初始化服务器连接。

请求

{
  "jsonrpc": "2.0",
  "method": "initialize",
  "params": {},
  "id": 1
}

2. tools/list

获取可用工具列表。

请求

{
  "jsonrpc": "2.0",
  "method": "tools/list",
  "params": {},
  "id": 2
}

3. tools/call

调用具体工具。

3.1 list_emails - 获取邮件列表

参数

  • folder: 文件夹名称,默认为 INBOX
  • limit: 获取邮件数量,默认 20 封
  • unreadOnly: 是否只获取未读邮件,默认 false

请求

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "list_emails",
    "arguments": {
      "folder": "INBOX",
      "limit": 10,
      "unreadOnly": false
    }
  },
  "id": 3
}

3.2 get_email_detail - 获取邮件详情

参数

  • folder: 文件夹名称,默认为 INBOX
  • uid: 邮件 UID(必填)

请求

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "get_email_detail",
    "arguments": {
      "folder": "INBOX",
      "uid": "123"
    }
  },
  "id": 4
}

3.3 send_email - 发送邮件

参数

  • to: 收件人邮箱(必填)
  • subject: 邮件主题(必填)
  • text: 邮件纯文本内容
  • html: 邮件 HTML 内容
  • cc: 抄送邮箱
  • bcc: 密送邮箱

请求

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "send_email",
    "arguments": {
      "to": "[email protected]",
      "subject": "测试邮件",
      "text": "这是一封测试邮件",
      "html": "<h1>测试邮件</h1><p>这是一封测试邮件</p>",
      "cc": "[email protected]",
      "bcc": "[email protected]"
    }
  },
  "id": 5
}

3.4 mark_email_read - 标记邮件为已读/未读

参数

  • folder: 文件夹名称,默认为 INBOX
  • uid: 邮件 UID(必填)
  • read: true 标记为已读,false 标记为未读,默认 true

请求

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "mark_email_read",
    "arguments": {
      "folder": "INBOX",
      "uid": "123",
      "read": true
    }
  },
  "id": 6
}

3.5 delete_email - 删除邮件

参数

  • folder: 文件夹名称,默认为 INBOX
  • uid: 邮件 UID(必填)

请求

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "delete_email",
    "arguments": {
      "folder": "INBOX",
      "uid": "123"
    }
  },
  "id": 7
}

3.6 get_folders - 获取文件夹列表

请求

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "get_folders",
    "arguments": {}
  },
  "id": 8
}

项目结构

email-mcp/
├── email-client.js      # 邮件客户端实现
├── email-mcp-server.js  # MCP 服务器实现
├── email_config.js      # 配置文件
├── package.json         # 项目依赖
└── README.md            # 项目文档

依赖

  • imap: ^0.8.19
  • mailparser: ^3.9.4
  • nodemailer: ^6.10.1

注意事项

  1. 确保邮箱账号开启了 IMAP/SMTP 服务
  2. 部分邮箱需要使用应用专用密码(如 Gmail、Outlook 等)
  3. 生产环境中建议使用环境变量管理敏感信息
  4. 目前只支持基本的邮件操作功能

示例

示例 1: 获取邮件列表

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "list_emails",
    "arguments": {
      "folder": "INBOX",
      "limit": 5
    }
  },
  "id": 1
}

示例 2: 发送邮件

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "send_email",
    "arguments": {
      "to": "[email protected]",
      "subject": "周报",
      "html": "<h1>周报</h1><p>本周工作内容...</p>"
    }
  },
  "id": 2
}

许可证

MIT