Damien Email Wrestler
An AI-powered email intelligence platform that integrates with Gmail and OpenAI. It can be run as a CLI tool or deployed on AWS Lambda for enhanced capabilities.
š¤¼āāļø 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. š
Related Servers
Instagram DMs
Send Instagram DMs via your LLM
Coreflux MQTT MCP Server
Connects to a Coreflux MQTT broker, offering tools for Coreflux commands and integration with AI assistants.
Unichat
A unified interface for various chat AI models including OpenAI, MistralAI, Anthropic, and Google AI, requiring vendor API keys.
FastIntercom
A high-performance MCP server for analyzing Intercom conversations with fast, local access via caching and background sync.
Dad Jokes MCP Server
Generates dad jokes with multiple styles and topics, complete with ratings and fun statistics.
Gmail MCP
Manage your Gmail account, including sending, reading, and organizing emails.
MCP-Pushover Bridge
Enables AI assistants to send push notifications via the Pushover service.
Inbox Zero
AI personal assistant for email Inbox Zero
PubNub
Access PubNub SDK documentation and API resources for real-time communication applications.
Ntfy
An ntfy MCP server for sending/fetching ntfy notifications to your self-hosted ntfy server from AI Agents š¤ (supports secure token auth & more - use with npx or docker!)