🤼♂️ Damien Email Wrestler
The AI-Powered Email Intelligence Platform
Damien Email Wrestler is an enterprise-grade AI email intelligence platform that transforms how you manage email through natural language AI assistants like Claude. Built with hybrid CLI + AWS Lambda architecture, advanced AI intelligence, cost optimization, and seamless MCP integration.
✨ Current Status: Enhanced Workflow Complete v0.4.2 🎉
🏆 Complete AI Email Intelligence Platform with Natural Language Interface
- 48 Optimized Tools: Enhanced email management suite with natural language organization and smart cleanup
- ✅ ENHANCED WORKFLOW VALIDATED: 282 marketing emails processed with 100% precision across production tests
- Hybrid Architecture: CLI reliability + AWS Lambda AI enhancement when configured
- Real-World Tested: 100-500 emails analyzed with 83-86% confidence pattern detection
- Precision Targeting: AI analysis → Email IDs → Precise bulk operations (zero false positives)
- Privacy-First Design: Metadata-only storage with automatic TTL cleanup (30-90 days)
- Cost-Effective: $0.01 per 100-email analysis, ~$1/month for single user
- Enterprise Grade: Privacy protection, scalable architecture, graceful fallback
🚀 What Makes Damien Special
- Natural Language Email Management: "Create a rule to archive newsletters" → Done automatically
- Hybrid AI Processing: CLI reliability + AWS Lambda enhancement for enterprise-grade analysis
- Real-World Validated: 83% automation coverage with 92% confidence pattern detection
- Privacy-First Architecture: Metadata-only storage, zero email content exposure
- Cost-Optimized: $0.01 per 100-email analysis with pay-per-request AWS Lambda
- Enterprise Scalability: Handles 66k+ email datasets with intelligent batching
- Real-time Intelligence: 14.49 seconds for 100-email analysis with Lambda enhancement
🎯 Core Capabilities
🧠 AI Intelligence Suite
- 📊 Email Analysis: Detect patterns, sentiment, and business impact across thousands of emails
- 🤖 Smart Automation: Natural language rule creation - "Archive emails from newsletters"
- 💡 Intelligent Insights: Trend analysis, efficiency metrics, and optimization recommendations
- ⚡ Inbox Optimization: AI-powered decluttering and organization strategies
- 🔍 Advanced Search: Semantic search with RAG-enhanced context understanding
📧 Complete Email Management
- Thread Management: Conversation-level operations with full context
- Draft Lifecycle: Create, edit, send, and manage drafts seamlessly
- Bulk Operations: Process thousands of emails efficiently with progress tracking
- Smart Filtering: Sophisticated rule-based automation with ML enhancement
- Label Management: Intelligent categorization and organization
🛡️ Enterprise Features
- Privacy Protection: 99.9% accurate PII detection with reversible tokenization
- Cost Monitoring: Real-time token usage tracking with configurable alerts
- Performance Optimization: Smart model routing (gpt-4o-mini vs gpt-4o)
- Audit Compliance: GDPR/CCPA/HIPAA ready with immutable audit trails
- Scalable Architecture: Handle enterprise workloads with intelligent batching
🏗️ Hybrid Architecture Overview
Damien Email Wrestler consists of integrated components with hybrid CLI + AWS Lambda processing:
┌─────────────────┐ ┌─────────────────────┐ ┌──────────────────┐ ┌─────────────┐
│ │ │ │ │ │ │ │
│ AI Assistant │◄──►│ Smithery Adapter │◄──►│ Damien MCP │◄──►│ Gmail API │
│ (Claude) │ │ (Port 8081) │ │ Server │ │ │
│ │ │ │ │ (Port 8892) │ │ │
└─────────────────┘ └─────────────────────┘ └──────────────────┘ └─────────────┘
│ │
│ ▼
▼ ┌─────────────────────┐
┌─────────────────┐ │ Hybrid Processing │
│ │ │ Layer │
│ Smithery │ │ • Standard CLI │◄──────┐
│ Registry │ │ • Privacy Guard │ │
│ │ │ • Smart Router │ │
└─────────────────┘ │ • Batch Processor │ │
└─────────────────────┘ │
│ │
▼ │
┌──────────────────────────┐ │
│ AWS Lambda Enhancement │ │
│ (When Credentials Set) │ │
│ • Email Processor │ │
│ • AI Analyzer (85%+) │ │
│ • Rule Engine │ │
└──────────────────────────┘ │
│ │
▼ │
┌──────────────────────────┐ │
│ Privacy-First Storage │ │
│ • Metadata Only │ │
│ • TTL Auto-Cleanup │──────┘
│ • DynamoDB Tables │
│ • No Content Storage │
└──────────────────────────┘
Component Breakdown
🤖 Damien MCP Server (Port 8892)
- 48 Optimized MCP Tools: Focused email management toolkit following Pareto principle
- Hybrid Processing: Standard CLI analysis + AWS Lambda AI enhancement (when configured)
- Graceful Fallback: Full functionality without AWS - Lambda enhances but never required
- FastAPI Backend: High-performance async API with comprehensive monitoring
- Enterprise Security: OAuth 2.0, rate limiting, audit logging
🔗 Smithery Adapter (Port 8081)
- MCP Protocol Bridge: Seamless integration with AI assistants
- Tool Discovery: Dynamic tool registration and capability advertisement
- Error Handling: Graceful fallbacks and retry mechanisms
- Performance Optimization: Connection pooling and caching
🧠 Hybrid AI Intelligence Layer
- Standard Processing: Always-available CLI-based analysis with pattern detection
- Lambda Enhancement: Enterprise-grade AI classification when AWS credentials configured
- Privacy Guardian: Enterprise-grade PII protection and tokenization
- Intelligence Router: ML-powered model selection for cost optimization
- RAG Engine: Semantic search with vector embeddings for contextual understanding
- Batch Processor: Scalable processing of large email volumes with progress tracking
☁️ AWS Lambda Enhancement Layer
- Email Processor: Privacy-safe metadata extraction and storage
- AI Analyzer: High-confidence email classification (85%+ accuracy)
- Rule Engine: Intelligent rule execution with conflict resolution
- DynamoDB Storage: Metadata-only storage with automatic TTL cleanup (30-90 days)
- Cost Optimization: Pay-per-request model (~$1/month for single user)
🚀 Quick Start
Prerequisites
- Python 3.11+ with Poetry
- Node.js 18+ with npm
- Gmail API credentials (Setup Guide)
- OpenAI API key (for AI features)
- AWS Credentials (optional - for Lambda enhancement) (Setup Guide)
1. Installation (2 minutes)
# Clone repository
git clone https://github.com/your-org/damien-email-wrestler.git
cd damien-email-wrestler
# Configure environment
cp .env.example .env
# Add your Gmail credentials and OpenAI API key to .env
# Install dependencies
cd damien-cli && poetry install && cd ..
cd damien-mcp-server && poetry install && cd ..
cd damien-smithery-adapter && npm install && cd ..
2. Start Services (30 seconds)
# Start all services with one command
./scripts/start-all.sh
Expected Output: ✅ All services running with health checks passed
3. Connect Claude Desktop (2 minutes)
Add to your ~/.claude/claude_desktop_config.json
:
{
"mcpServers": {
"damien-email-wrestler": {
"command": "node",
"args": ["./damien-smithery-adapter/dist/index.js"],
"cwd": "/path/to/damien-email-wrestler",
"env": {
"DAMIEN_MCP_SERVER_URL": "http://localhost:8892",
"DAMIEN_MCP_SERVER_API_KEY": "your-api-key-from-.env"
}
}
}
}
4. Test Integration (1 minute)
# Authenticate with Gmail
cd damien-cli && poetry run damien login
# Run validation tests
cd .. && ./run_e2e_tests.sh
🎉 You're ready! Try in Claude Desktop: "List my recent emails and suggest 3 automation rules"
💡 Usage Examples
Natural Language Email Management
You: "Analyze my emails from the last week and find patterns"
Claude: [Uses damien_ai_analyze_emails] Found 3 key patterns:
• 15 newsletter emails (suggest auto-archive rule)
• 8 meeting requests (suggest calendar integration)
• 12 customer support emails (suggest priority labeling)
You: "Create a rule to automatically archive newsletters"
Claude: [Uses damien_ai_create_rule] Created rule with 95% confidence:
✅ Auto-archive emails containing "unsubscribe" from marketing domains
You: "Optimize my inbox for better productivity"
Claude: [Uses damien_ai_optimize_inbox] Completed optimization:
• Archived 47 old newsletters
• Labeled 23 emails as "Action Required"
• Created 3 smart filters for automatic organization
Advanced Email Operations
# CLI Usage
poetry run damien emails list --query "from:boss@company.com" --max-results 10
poetry run damien ai analyze-emails --days 30 --min-confidence 0.8
poetry run damien rules suggest --categories "productivity,automation"
# Bulk Operations
poetry run damien emails bulk-label --query "is:unread older_than:30d" --label "Archive"
poetry run damien emails bulk-trash --query "category:promotions older_than:90d" --dry-run
📊 Performance & Cost Optimization
Cost Efficiency
- Smart Model Routing: Automatically uses gpt-4o-mini (90% cheaper) for simple tasks
- AWS Lambda: Pay-per-request model with automatic scaling
- Token Optimization: include_headers parameter reduces API calls by 80%+
- Query Optimization: Smart targeting of specific email categories
- Real-time Monitoring: Track costs with configurable alerts
- Actual Costs: $0.01 for 100-email analysis, ~$1/month for single user
Performance Metrics (Real-World Tested)
- Email Analysis: 100 emails in 14.49 seconds (6.9 emails/second) ✅
- ✅ ENHANCED WORKFLOW: 282 marketing emails precisely targeted and trashed across 100/200/500 email tests ✅
- Precision Targeting: 100% accuracy - every AI-identified email successfully processed ✅
- Pattern Detection: 83-86% confidence in newsletter/promotional classification with statistical validation ✅
- Scalable Processing: Seamless handling of 100-500 emails with async workflow ✅
- Lambda Enhancement: 85%+ accuracy for high-confidence classification ✅
- Lambda Processing: Sub-300ms per function call ✅
- Gmail API Response: < 2 seconds ✅
- MCP Tool Execution: < 5 seconds per operation ✅
- Memory Usage: < 1GB during normal operation ✅
Scalability
- Batch Processing: Handle 100K+ emails with intelligent chunking
- Progressive Operations: Real-time feedback for long-running tasks
- Parallel Operations: Multi-threaded processing with progress tracking
- Resource Management: Automatic cleanup and garbage collection
- Service Health: Comprehensive monitoring with automatic restarts
🛡️ Security & Privacy
Privacy Protection
- Metadata-Only Storage: No email content stored, only privacy-safe metadata
- AWS Lambda Privacy: Cloud processing with zero content exposure
- Automatic Data Expiration: TTL-based cleanup (30-90 days)
- 99.9% PII Detection: Advanced pattern recognition for sensitive data
- Reversible Tokenization: Secure processing while maintaining recoverability
- Audit Trails: Immutable logging for compliance and debugging
Enterprise Compliance
- GDPR Ready: Data processing consent management and right-to-deletion
- CCPA Compliant: California privacy law compliance built-in
- HIPAA Considerations: Healthcare data protection patterns
- Access Control: Role-based permissions and API key management
Security Features
- OAuth 2.0: Industry-standard authentication with Google APIs
- Rate Limiting: Prevent abuse and ensure fair usage
- Error Handling: Graceful failures without exposing sensitive data
- Encrypted Storage: All credentials and tokens securely stored
📚 Documentation
- Quick Start Guide - Get running in 15 minutes
- API Reference - Complete tool documentation
- Troubleshooting - Common issues and solutions
- E2E Testing Guide - Production validation checklist
🔧 Advanced Configuration
Environment Variables
# AI Intelligence Configuration
AI_MODEL_STRATEGY="cost_optimized" # cost_optimized | performance_optimized | balanced
USE_OPENAI_API=true # Use OpenAI API vs local models
TRACK_TOKEN_USAGE=true # Enable cost monitoring
COST_ALERT_THRESHOLD_USD=10.00 # Alert when costs exceed threshold
# Performance Tuning
MAX_TOKENS_PER_REQUEST=4000 # Token limit per API call
SIMPLE_TASK_MAX_TOKENS=1000 # Threshold for gpt-4o-mini usage
COMPLEX_TASK_MIN_CONFIDENCE=0.8 # Threshold for gpt-4o usage
# Privacy & Security
PII_DETECTION_ENABLED=true # Enable PII protection
AUDIT_LOGGING_ENABLED=true # Enable compliance logging
CONSENT_REQUIRED=false # Require explicit consent for processing
Service Management
# Start/Stop Services
./scripts/start-all.sh # Start all services
./scripts/stop-all.sh # Stop all services
# Service Health
curl http://localhost:8892/health # MCP Server health
curl http://localhost:8081/health # Smithery Adapter health
# Logs
tail -f logs/damien-mcp-server.log # MCP Server logs
tail -f logs/smithery-adapter.log # Adapter logs
tail -f logs/token_usage.json # Cost tracking logs
🏆 Why Choose Damien?
🎯 For Individuals
- Time Savings: Automate 80% of routine email tasks
- Intelligence: AI-powered insights and pattern detection
- Control: Natural language commands with precise control
- Privacy: Enterprise-grade protection for personal emails
🏢 For Teams & Organizations
- Scalability: Handle thousands of emails across team members
- Compliance: Built-in audit trails and privacy protection
- Cost Efficiency: Optimized AI usage saves 80% on API costs
- Integration: Seamless connection with existing workflows
🚀 For Developers
- MCP Protocol: Standard integration with AI assistants
- Extensible: 48 tools with easy customization options
- AWS Integration: Serverless Lambda functions with DynamoDB storage
- Hybrid Architecture: CLI + Cloud processing for optimal performance
- Enterprise Ready: Production-grade architecture and monitoring
📈 Roadmap
Current (v0.4.2) - ✅ Enhanced Workflow Complete
- ✅ ENHANCED EMAIL PROCESSING: 3-week implementation of precise email ID targeting system
- ✅ PRODUCTION VALIDATED: 282 marketing emails processed with 100% precision across test scales
- ✅ Smart Caching: LRU/LFU eviction with TTL optimization for repeat operations
- ✅ Async Job Processing: Seamless handling of large datasets with real-time progress tracking
- ✅ Enhanced MCP tool suite (48 tools total: 39 core + 2 enhanced trash + 5 organization tools + 2 smart cleanup tools)
- ✅ Hybrid CLI + AWS Lambda AI enhancement architecture
- ✅ Privacy-first metadata-only storage with TTL cleanup
- ✅ Real-world validation: 100-500 emails with 83-86% confidence pattern detection
- ✅ Precision targeting: AI analysis → Email IDs → Precise bulk operations
- ✅ Cost-effective: $0.01 per 100-email analysis
- ✅ Enterprise scalability: Handles 66k+ email datasets
- ✅ Graceful fallback: Full functionality without AWS dependency
Next Release (v0.5.0) - Q1 2025
- 🔄 Real-time collaboration features
- 🔄 Advanced analytics dashboard
- 🔄 Multi-account Gmail support
- 🔄 Custom AI model training
- 🔄 Enhanced mobile compatibility
Development Phase (v0.6.0 - v0.9.x) - Q2-Q4 2025
- 📅 Multi-provider support (Outlook, Yahoo)
- 📅 Slack and Teams integration
- 📅 Advanced workflow automation
- 📅 Predictive email management
- 📅 Enterprise admin console
- 📅 Production hardening and optimization
Public Release (v1.0.0) - Q1 2026
- 🚀 First public release
- 🚀 Complete documentation and support
- 🚀 Enterprise deployment ready
- 🚀 Community and ecosystem launch
🤝 Support & Community
- Issues: GitHub Issues
- Documentation: This repository and linked guides
- Discussions: GitHub Discussions
- Security: Email security@damien-platform.com for security issues
📄 License
NO License - see LICENSE for details.
🙏 Acknowledgments
Built with:
- Model Context Protocol (MCP) - AI assistant integration standard
- Smithery - MCP tool registry and discovery
- FastAPI - High-performance Python web framework
- OpenAI - AI language models and embeddings
- Gmail API - Email service integration
Transform your email experience with AI-powered intelligence. Welcome to the future of email management. 🚀