Enables management of Gmail accounts including reading, searching, sending, and organizing emails, with support for attachments, folders, and contact analysis.
Provides workflow automation for email monitoring with AI-powered filtering and multi-platform notifications through n8n workflow templates.
Powers AI-based email filtering, translation, summarization, and intelligent monitoring to identify important emails and generate automated responses.
Sends rich formatted email notifications and alerts to Slack channels with block-based formatting for monitored emails.
Delivers styled email notifications to WeChat Work with color coding for AI-monitored important emails.
MCP Email Service
A unified MCP email service supporting multi-account management with AI-powered intelligent monitoring and notifications.
New Feature: Email translation & summarization with n8n automation - automatically translate non-Chinese emails, generate summaries, and send to Feishu/Lark!
New Feature: n8n + AI Email Monitoring
Automatically monitor emails, filter important ones with AI, and send real-time notifications to your team chat!
AI Smart Filtering: Uses OpenAI/Claude to intelligently identify important emails
Multi-platform Notifications: Supports Feishu/DingTalk/WeChat Work/Slack
Automated Monitoring: n8n workflow runs every 5 minutes automatically
Deduplication: Prevents duplicate notifications
Production Ready: Comprehensive error handling and fallback mechanisms
Quick Start with AI Monitoring
Documentation: See N8N_EMAIL_MONITORING_GUIDE.md for complete setup guide.
Supported Email Providers
163 Mail (mail.163.com / mail.126.com)
QQ Mail (mail.qq.com)
Gmail (mail.google.com)
Outlook/Hotmail
Custom IMAP servers
Quick Start
Option 1: Install via Smithery (Recommended)
After installation, you'll need to configure your email accounts:
Option 2: Manual Installation
Requires Python 3.11+ and UV.
2. Configure Email Accounts
Email Configuration Guide
Provider | Configuration Steps |
163 Mail | Login to mail.163.com → Settings → Enable IMAP → Get authorization code (use code, not password) |
QQ Mail | Settings → Account → Enable IMAP → Generate authorization code |
Gmail | Enable 2FA → |
Outlook | Use email password directly |
3. Add to MCP Client (Manual Installation Only)
If you installed manually, add to your MCP client (e.g., Claude Desktop) config:
4. How to Use MCP Commands
After configuration, you can use email features directly in MCP clients (like Claude Desktop):
Start MCP Client: Ensure the MCP service is properly configured and running
Use in Conversations: Request email operations directly in conversations, for example:
"Show me unread emails"
"Search for emails containing 'meeting'"
"Mark email 123 as read"
"Send email to user@example.com"
Command-line Client: If you prefer not to use MCP clients, you can use the command-line client:
# Interactive mode uv run python -m clients.mailbox_client # Command-line mode uv run python -m clients.mailbox_client list-emails --limit 10
Default behavior (cache, sync, version)
list_emailsdefaults to cache (use_cache=true) withlimit=100andfolder=all. Setuse_cache=falseto hit live IMAP, and adjustlimitas needed.Local cache is de-duplicated via unique key
(account_id, folder_id, uid)with upsert; cache queries also useDISTINCTto avoid repeats.Sync scheduler times are shown in local time; intervals support 5-minute cadence. Use
sync_emails status/forceto inspect or trigger sync.Service version comes from
src/config/version.pyand is exposed via the MCPget_versiontool and the CLI “Version” menu.
Main Features
Note: The following commands are used within MCP clients (like Claude Desktop), not as command-line commands.
View Emails
Search Emails
Email Operations
Send Emails
Contact Analysis ⭐ NEW
Available Commands
Basic Email Operations
list_emails- List emailsget_email_detail- View email detailssearch_emails- Search emailsmark_emails- Mark as read/unreaddelete_emails- Delete emailsflag_email- Star/unstar emailssend_email- Send new emailreply_email- Reply to emailforward_email- Forward emailmove_emails_to_folder- Move emailslist_folders- View foldersget_email_attachments- Get attachmentscheck_connection- Test connectionsanalyze_contacts⭐ - Analyze contact frequencyget_contact_timeline⭐ - Get communication timeline
AI Monitoring System
The AI monitoring system includes several powerful scripts:
Core Scripts
scripts/call_email_tool.py- Bridge between n8n and MCP toolsscripts/ai_email_filter.py- AI-powered email importance filteringscripts/notification_service.py- Multi-platform notification servicescripts/email_monitor.py- Main monitoring controllerscripts/setup_n8n_monitoring.py- Automated setup script
Usage Examples
Command-line Mailbox Client
A standalone CLI lives under clients/mailbox_client, allowing you to browse emails across all configured accounts without launching an MCP client.
Interactive Mode (Recommended for beginners)
Interactive menu now covers: list/search emails, sync status/force sync, health, version, and DB maintenance (vacuum/clear cache). Listing defaults to cache with limit 100; pass --limit to expand or --use-cache false to hit live IMAP.
Command-line Mode (For scripting)
Each command accepts --json for machine-readable output. See clients/mailbox_client/README.md for more details.
Supported Notification Platforms
Feishu/Lark - Rich card notifications with interactive elements
DingTalk - Markdown formatted messages with @mentions
WeChat Work - Styled messages with color coding
Slack - Block-based rich formatting
Custom Webhooks - Flexible JSON payload support
Troubleshooting
Basic Email Issues
Login Failed: 163/QQ Mail use authorization codes, Gmail uses app passwords
Can't Find Emails: Default shows unread only, use
unread_only=falseConnection Timeout: Check network and firewall settings
Duplicates or stale cache: Cache uses unique key
(account_id, folder_id, uid)with upsert; if DB is corrupted, removedata/email_sync.dband re-sync. Usesync_emails statusto confirm scheduler (local time, 5-minute cadence supported).
AI Monitoring Issues
AI Filtering Failed: System automatically falls back to keyword filtering if AI API fails
Webhook Not Working: Verify webhook URL and test with
python scripts/test_lark_webhook.pyn8n Workflow Errors: Check environment variables (
FEISHU_WEBHOOK,OPENAI_API_KEY)Script Permission Denied: Run
chmod +x scripts/*.pyto make scripts executableNo Notifications: Check notification config and test with
python scripts/notification_service.py test
Quick Diagnostics
Project Structure
Key Features
Auto-start Background Sync: Synchronization starts automatically with MCP server
Centralized Data Management: All runtime data in
data/directoryUID-based Operations: Stable email identification across operations
Smart Caching: 100-500x faster than live IMAP queries
Multi-account Support: Manage multiple email accounts with proper isolation
Performance Optimized: Shared connections for batch operations (5x faster)
Well Tested: 71/72 tests passing, ~65% code coverage
Documentation
Quick Start Guides
docs/guides/EMAIL_TRANSLATE_WORKFLOW_GUIDE.md - Email translation & summarization workflow
docs/guides/HTTP_API_QUICK_START.md - HTTP API quick start
docs/guides/N8N_EMAIL_MONITORING_GUIDE.md - n8n email monitoring guide
docs/guides/LARK_SETUP_GUIDE.md - Feishu/Lark webhook setup
Deployment & Security
docs/guides/FINAL_DEPLOYMENT_CHECKLIST.md - Deployment checklist
docs/guides/PRODUCTION_DEPLOYMENT_GUIDE.md - Production deployment guide
docs/guides/SECURITY_SETUP_GUIDE.md - Security configuration
Technical Documentation
docs/README.md - Complete documentation index
docs/ARCHITECTURE.md - System architecture and design
docs/database_design.md - Database schema and design
n8n/README.md - n8n workflow details
config_templates/ - Configuration templates and examples
data/README.md - Data directory usage guide
Support This Project
If you find this project helpful, please consider:
Star this repository to show your support
Report bugs or suggest features via Issues
Contribute code or documentation via Pull Requests
Sponsor the development via GitHub Sponsors
Support via WeChat Pay / Alipay
If you'd like to support this project, you can use WeChat Pay or Alipay:
Your support helps maintain and improve this project! Thank you!
Contributing
We welcome contributions! Please feel free to submit issues and pull requests.
Development Setup
Running Tests
Code Quality
Option 1: Install dev dependencies (recommended)
Option 2: Use uv tool (no installation needed)
Features Roadmap
Multi-account email management
AI-powered email filtering
Email translation & summarization (OpenAI)
Multi-platform notifications
n8n workflow automation
Production-ready error handling
Email auto-reply with AI
Smart email categorization
Advanced analytics dashboard
Mobile app notifications
Security
API Key Protection
All sensitive endpoints are protected with API key authentication. See SECURITY_SETUP_GUIDE.md for details.
Environment Variables
Never commit sensitive information. Always use environment variables:
.envfiles are automatically ignored by gitUse
.env.exampletemplates for documentationRotate API keys regularly
Reporting Security Issues
Please report security vulnerabilities to the repository maintainers privately before public disclosure.
License
This project is licensed under the MIT License - see the LICENSE file for details.