Skip to main content
Glama
shellyz7107

mcp-mail-notifier

by shellyz7107
README.md
# mcp-mail-notifier Notification MCP Server

将 mcp-mail-notifier 项目的邮件通知功能转换为 Augment 可用的 MCP (Model Context Protocol) 工具。

## 功能特性

- 📧 **邮件通知**: 发送任务完成通知到指定邮箱
- ⏱️ **时间跟踪**: 自动计算任务耗时
- 🎯 **项目集成**: 专为 mcp-mail-notifier 项目定制
- 🔧 **MCP 兼容**: 完全兼容 Augment 的 MCP 协议
- ✅ **QQ邮箱优化**: 专门优化QQ邮箱SMTP配置
- ✅ **中文支持**: 中文时区和格式化支持

## 安装

### 1. 安装依赖

```bash
cd mcp-tools
npm install
```

### 2. 获取QQ邮箱授权码

1. 登录QQ邮箱 (https://mail.qq.com)
2. 点击"设置" -> "账户"
3. 找到"POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务"
4. 开启"IMAP/SMTP服务"
5. 获取授权码(不是QQ密码)

### 3. 配置环境变量(可选)

```bash
export QQ_EMAIL_USER="your-email@qq.com"
export QQ_EMAIL_AUTH_CODE="your-auth-code"
```

如果不设置环境变量,将使用默认配置。

## 使用方法

### 作为 MCP 服务器运行

```bash
npm start
```

### 直接使用命令行工具

```bash
node send-notification.js "任务标题" "任务结果" "详细信息" "开始时间"
```

示例:
```bash
node send-notification.js "iOS应用编译" "成功" "编译完成,所有测试通过" "2024-01-01 10:00:00"
```

### 配置 Augment

在 Augment 中配置 MCP 连接:

```json
{
  "mcpServers": {
    "mcp-mail-notifier": {
      "command": "node",
      "args": [
        "/path/to/your/project/mcp-tools/mcp-server.js"
      ],
      "env": {
        "QQ_EMAIL_USER": "your-qq-email@qq.com",
        "QQ_EMAIL_AUTH_CODE": "your-authorization-code"
      }
    }
  }
}
```

## MCP 工具说明

### 1. send_notification

发送任务完成通知邮件。

**参数:**
- `task_title` (必需): 任务标题
- `task_result` (必需): 任务结果
- `details` (可选): 详细信息
- `recipient` (可选): 收件人邮箱
- `start_time` (可选): 任务开始时间

**示例:**
```json
{
  "task_title": "iOS项目文件结构重构",
  "task_result": "成功完成",
  "details": "已成功重构项目文件结构,创建Core目录统一管理核心组件",
  "start_time": "2025-09-07 00:30:00"
}
```

### 2. set_task_start_time

设置任务开始时间,用于后续计算任务耗时。

**参数:**
- `start_time` (可选): 任务开始时间,不提供则使用当前时间

### 3. format_duration

格式化时间间隔显示。

**参数:**
- `seconds` (必需): 秒数

## 配置说明

### 项目配置

在 `send-notification.js` 中的 `PROJECT_CONFIG` 部分:

```javascript
const PROJECT_CONFIG = {
  name: 'mcp-mail-notifier',
  displayName: '📒【mcp-mail-notifier】',
  description: 'mcp-mail-notifier iOS应用'
};
```

### 邮件配置

在 `send-notification.js` 中的 `EMAIL_CONFIG` 部分:

```javascript
const EMAIL_CONFIG = {
  recipient: 'xxx@qq.com',
  sender: {
    user: process.env.QQ_EMAIL_USER || 'xxx@qq.com',
    authCode: process.env.QQ_EMAIL_AUTH_CODE || 'your-auth-code'
  }
};
```

## 在 Augment 中使用

1. 启动 MCP 服务器:
   ```bash
   npm start
   ```

2. 在 Augment 中配置 MCP 连接,指向这个服务器

3. 使用工具:
   - `send_notification`: 发送通知邮件
   - `set_task_start_time`: 设置任务开始时间
   - `format_duration`: 格式化时间显示

## 开发和调试

### 开发模式

```bash
npm run dev
```

### 测试

```bash
npm test
```

### 全局安装

```bash
npm run install-global
```

### 卸载

```bash
npm run uninstall-global
```

## 技术架构

- **MCP SDK**: 使用 @modelcontextprotocol/sdk 实现 MCP 协议
- **邮件服务**: 使用 nodemailer 发送邮件
- **ES6 模块**: 使用现代 JavaScript 模块系统
- **Node.js**: 要求 Node.js 18+ 版本

## 故障排除

### 常见问题

1. **535 Login Fail错误**
   - 确认已开启IMAP/SMTP服务
   - 确认使用的是授权码而不是QQ密码

2. **环境变量未设置**
   - 检查QQ_EMAIL_USER和QQ_EMAIL_AUTH_CODE是否正确设置

3. **网络连接问题**
   - 确认网络可以访问smtp.qq.com:587

4. **MCP 连接问题**
   - 确认 MCP 服务器正常启动
   - 检查 Augment 配置文件路径正确

### 调试模式

设置环境变量启用调试:
```bash
export DEBUG=nodemailer:*
```

## 安全注意事项

- 不要将授权码提交到版本控制系统
- 定期更换授权码
- 使用环境变量存储敏感信息

## 许可证

MIT License

## 贡献

欢迎提交 Issue 和 Pull Request!

TDQS

B3.1/5.0

Scored across 3 tools

Disambiguation5/5

The three tools have clearly distinct purposes: sending an email notification, setting a task start time, and formatting a duration. No two tools overlap in action or target resource.

Naming Consistency5/5

All tool names use a consistent snake_case verb_noun pattern: send_notification, set_task_start_time, format_duration. The convention is predictable and easy to parse.

Tool Count4/5

Three tools are a reasonable, lightweight surface for a mail notifier. Two are timing helpers rather than direct mail operations, so the set is slightly narrow but not inappropriate.

Completeness3/5

The core send_notification tool is present, and duration helpers exist, but there is no tool to retrieve or clear the stored start time or to calculate/embed elapsed duration into the notification. Other notification scenarios are also absent.

Maintenance

ActivityInactive
ResponsivenessNo issues