Uses environment variables for configuration management, allowing users to securely store email credentials and service settings.
Provides email management functionality for Gmail accounts, including viewing emails, marking as read, deleting, moving to trash, and performing batch operations (currently in development).
Emulates Mozilla Thunderbird client for IMAP compatibility with email providers, specifically to solve authentication issues with 163 email.
MCP Email Service
一个基于MCP (Model Context Protocol) 的邮件管理服务,支持多邮箱提供商的完整邮件管理功能。目前已完美支持163邮箱,其他邮箱提供商正在开发中。
✨ 核心功能
- 📧 邮件管理: 查看、详情、标记已读、删除、移动到垃圾箱
- 🔄 批量操作: 批量标记已读、批量删除、批量移动到垃圾箱
- 📊 统计信息: 未读邮件数量、邮箱状态检查
- 🔧 技术突破: 解决各种邮箱提供商的技术限制 (如163邮箱IMAP "Unsafe Login")
- 🎯 MCP集成: 完美集成MCP协议客户端,支持10个MCP工具
🚀 快速开始
1. 环境要求
- Python 3.11+
- UV包管理器
2. 安装UV (如果尚未安装)
3. 克隆项目
4. 项目初始化
5. 邮箱配置
当前支持的邮箱提供商:
- ✅ 163邮箱 - 完全支持
- 🔄 Gmail - 开发中
- 🔄 Outlook - 开发中
- 🔄 QQ邮箱 - 开发中
5.1 配置163邮箱 (当前支持)
- 登录163邮箱: 访问 https://mail.163.com
- 进入设置: 点击右上角设置 → POP3/SMTP/IMAP
- 开启IMAP服务: 开启 IMAP/SMTP 服务
- 获取授权码: 完成手机验证后获取授权码
⚠️ 重要: 授权码不是邮箱密码!是专门用于第三方客户端的授权码。
5.2 配置环境变量
注意: 其他邮箱提供商的配置方式正在开发中,敬请期待!
6. 测试运行
成功显示类似信息表示配置正确:
🔧 MCP客户端集成
在MCP客户端配置文件中添加以下配置:
启动脚本说明:
run.sh
: 简单的启动脚本,包含以下功能:- 自动切换到项目目录
- 使用UV运行Python服务 (
uv run python src/main.py
) - 确保在正确的环境中启动MCP服务
只需修改配置中的路径为你的实际项目路径,重启MCP客户端即可使用!
📋 可用的MCP工具
基础功能 (4个)
check_connection
- 检查邮箱连接状态list_emails
- 获取邮件列表 (默认50封)get_unread_count
- 获取未读邮件数量get_email_detail
- 获取邮件详细内容
单个操作 (3个)
mark_email_read
- 标记邮件为已读delete_email
- 永久删除邮件move_email_to_trash
- 移动邮件到垃圾箱
批量操作 (3个)
batch_mark_read
- 批量标记已读batch_delete_emails
- 批量删除batch_move_to_trash
- 批量移动到垃圾箱
💡 使用示例
在MCP客户端中可以这样使用:
🔧 技术特性
核心技术:多提供商适配架构
针对不同邮箱提供商的技术特点,实现相应的解决方案。
163邮箱的IMAP ID解决方案: 通过实现RFC 2971 IMAP ID扩展,完美解决163邮箱的"Unsafe Login"限制:
特性亮点
- 🛡️ 完善的错误处理和批量操作失败恢复
- 🚀 默认获取50封邮件,提升用户体验
- 🌍 智能MIME解码,支持多语言邮件
- ⚡ 批量操作优化,减少网络连接次数
🐛 常见问题
Q: "❌ 邮箱登录失败"
A: 对于163邮箱,检查以下几点:
- 确认已开启IMAP服务
- 使用授权码而非邮箱密码
- 重新生成授权码
- 确认邮箱地址正确
对于其他邮箱: 请等待相应提供商的支持更新
Q: "❌ 连接超时"
A: 检查网络连接和防火墙设置
Q: MCP客户端中看不到邮件工具
A:
- 检查配置文件JSON格式是否正确
- 确认路径是否正确
- 重启MCP客户端
🎯 开发路线图
🔄 正在开发
- Gmail支持 - OAuth2认证和API集成
- Outlook支持 - Microsoft Graph API集成
- QQ邮箱支持 - 腾讯邮箱服务集成
📋 计划功能
- 邮件搜索功能 (按关键词、发件人、日期范围)
- 邮件发送功能 (支持附件)
- 邮件文件夹管理 (创建、删除、移动)
- 邮件附件处理 (下载、预览)
- 邮件模板系统
- 邮件规则和过滤器
🚀 长期规划
- 企业邮箱支持 (Exchange, POP3等)
- 多账户管理
- 邮件备份和导出功能
📄 许可证
MIT License
注意: 请不要将包含敏感信息的.env
文件提交到版本控制系统中。
Tools
A Model Context Protocol service for comprehensive email management that supports multiple email providers, with complete functionality for viewing, organizing, and batch processing emails.
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that provides a seamless email management interface through Claude, allowing users to search, read, and send emails directly through natural language conversations.Last updated -40PythonMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that provides tools for interacting with Gmail and Calendar APIs, enabling programmatic management of emails and calendar events.Last updated -813JavaScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables AI assistants like Claude to interact with Gmail through natural language, providing comprehensive email management capabilities including sending, reading, organizing, searching, and managing drafts and labels.Last updated -PythonGPL 3.0
- -securityAlicense-qualityA Model Context Protocol server that enables LLMs to compose and send emails with attachments, as well as search for files in specified directories that match given patterns.Last updated -22PythonMIT License