Email Intelligence MCP Server
README.md
# Email Intelligence MCP Server
AI-powered email intelligence and analysis server for the Model Context Protocol (MCP). Provides Claude with tools to automatically analyze, categorize, prioritize, and extract actionable intelligence from your emails.
**GitHub**: [Kolaborate-Platforms/kola-mail](https://github.com/Kolaborate-Platforms/kola-mail)
## ๐ Quick Start
### Installation
```bash
# Clone the repository
git clone https://github.com/Kolaborate-Platforms/kola-mail.git
cd kola-mail
# Install dependencies and build
bun install
bun run build
```
### Configure Claude Desktop
Add to your Claude Desktop config file:
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
- **Linux**: `~/.config/Claude/claude_desktop_config.json`
```json
{
"mcpServers": {
"email-intelligence": {
"command": "bun",
"args": [
"run",
"/ABSOLUTE/PATH/TO/kola-mail/src/index.ts"
],
"env": {
"EMAIL_INTELLIGENCE_LOG_LEVEL": "info",
"EMAIL_USER": "your-email@example.com",
"EMAIL_PASSWORD": "your-password",
"IMAP_HOST": "imap.example.com",
"IMAP_PORT": "993",
"IMAP_TLS": "true",
"SMTP_HOST": "smtp.example.com",
"SMTP_PORT": "465",
"SMTP_SECURE": "true",
"USE_DEMO_EMAILS": "false"
}
}
}
}
```
**Note**: Replace `/ABSOLUTE/PATH/TO/kola-mail` with the actual path where you cloned the repository.
### Restart Claude Desktop
**IMPORTANT**: Completely quit (Cmd+Q) and restart Claude Desktop for changes to take effect.
### Test the Server
In Claude Desktop, say:
```
Test the email intelligence server
```
Expected response:
```json
{
"status": "ok",
"message": "Email Intelligence MCP Server is running successfully!",
"version": "1.0.0"
}
```
## โจ Features
- **๐ง Real Email Integration** - Fetches emails via IMAP from your email server
- **๐ฏ Smart Categorization** - 5 categories (urgent/important/routine/fyi/spam)
- **โก Priority Scoring** - 0-10 intelligent priority based on 7+ factors
- **โ
Action Item Extraction** - Automatically detects tasks and deadlines
- **๐ Sentiment Analysis** - Positive, neutral, or negative classification
- **๐ฌ Response Suggestions** - AI-generated contextual replies
- **๐ค Email Sending** - Send emails via SMTP
- **๐ Fast Caching** - In-memory LRU cache with 5-minute TTL
- **๐ Secure** - SSL/TLS encryption, no permanent storage
## ๐ ๏ธ Available Tools
### 1. `test_server`
Health check to verify server is running.
**Usage**:
```
Test the email intelligence server
```
### 2. `analyze_emails`
Analyzes emails from your inbox with AI intelligence.
**Parameters**:
- `emailSource`: "inbox", "unread", "recent", or "custom"
- `limit` (optional): Max emails to analyze (default: 50, max: 200)
- `since` (optional): ISO date, only analyze emails after this date
- `includeBody` (optional): Include full body (default: false)
- `filter` (optional): Filter by from/subject/keywords
**Usage Examples**:
```
Analyze my unread emails
```
```
Analyze my emails from the last 7 days
```
```
Show me all urgent emails in my inbox
```
**Returns**:
```json
{
"emails": [
{
"id": "msg_123",
"from": "ceo@company.com",
"subject": "Urgent: Q4 Report Needed",
"analysis": {
"category": "urgent",
"priority": 9.5,
"sentiment": "neutral",
"actionItems": [
{
"text": "Send the Q4 report",
"priority": 9.5,
"deadline": "2025-10-22T17:00:00Z"
}
],
"hasDeadline": true,
"keyTopics": ["report", "deadline"],
"reasoning": "Category: contains urgent keywords..."
}
}
],
"summary": {
"totalAnalyzed": 1,
"urgentCount": 1,
"actionItemCount": 1,
"avgPriority": 9.5
}
}
```
### 3. `get_priority_emails`
Returns priority-sorted emails with optional response suggestions.
**Parameters**:
- `count` (optional): Number of emails (default: 10, max: 50)
- `minPriority` (optional): Minimum priority 0-10 (default: 7)
- `categories` (optional): Filter by categories
- `includeSuggestions` (optional): Include AI response suggestions
**Usage Examples**:
```
Show me my top 5 most important emails
```
```
Get my urgent emails with response suggestions
```
### 4. `send_email`
Sends an email from your configured email account via SMTP.
**Parameters**:
- `to`: Recipient email(s)
- `subject`: Email subject
- `body`: Email body (plain text)
- `html` (optional): HTML body
- `inReplyTo` (optional): Message-ID for threading
- `references` (optional): Thread references
**Usage Example**:
```
Send an email to john@example.com saying:
Subject: Meeting Follow-up
Body: Thanks for the meeting today. I'll send the report by Friday.
```
## ๐ฏ Intelligence Engine
### Category Classification
| Category | Description | Indicators |
|----------|-------------|------------|
| **๐ด Urgent** | Immediate action required | urgent, asap, critical keywords; CEO sender |
| **๐ก Important** | High priority, timely response | action items, deadlines, VIP senders |
| **๐ข Routine** | Normal business email | Standard communication |
| **๐ต FYI** | Informational only | newsletters, updates, CC'd |
| **โซ Spam** | Low value/promotional | unsubscribe links, promotional content |
### Priority Scoring (0-10)
**Base Score**: 5 (neutral)
**Modifiers**:
- **Category**: urgent +4, important +2, fyi -2, spam -5
- **Action Items**: +1.5 per item (max +6)
- **Deadline Proximity**:
- Today: +3
- 1-3 days: +2
- 4-7 days: +1
- **Sender Importance**:
- CEO/C-suite: +3
- Manager: +2
- Client: +2
- VIP list: +1
- **Email Age**: >48h unread +2, >24h unread +1
- **Keywords**: "decision needed" +2, "please respond" +1
**Priority Ranges**:
- **9-10**: ๐ฅ Drop everything, respond now
- **7-8**: โก High priority, respond today
- **5-6**: ๐ Normal, respond within 2 days
- **3-4**: ๐ Low priority, respond when convenient
- **0-2**: ๐๏ธ Very low, may ignore
### Action Item Detection
Automatically extracts action items using 20+ patterns:
- Direct requests: "please...", "could you...", "can you..."
- Formal requests: "kindly...", "request that you..."
- Explicit items: "action item:", "to-do:", "task:"
- Deadline-based: "by Friday...", "due...", "deadline..."
### Sentiment Analysis
Keyword-based classification:
- **Positive**: thank, appreciate, excellent, great, success
- **Negative**: problem, issue, error, disappointed, failed
- **Neutral**: update, information, meeting, schedule
## ๐ง Configuration
### Environment Variables
Set in `.env` file or Claude Desktop config:
```bash
# Email Account (Required for real emails)
EMAIL_USER=your-email@example.com
EMAIL_PASSWORD=your-password
# IMAP Configuration (Incoming)
IMAP_HOST=imap.example.com
IMAP_PORT=993
IMAP_TLS=true
# SMTP Configuration (Outgoing)
SMTP_HOST=smtp.example.com
SMTP_PORT=465
SMTP_SECURE=true
# Server Settings
EMAIL_INTELLIGENCE_LOG_LEVEL=info # debug, info, warn, error
ANALYSIS_CACHE_TTL=300 # seconds (5 minutes)
ANALYSIS_MAX_EMAILS=200
# Mode
USE_DEMO_EMAILS=false # true = demo data, false = real emails
```
**Common Email Providers**:
- **Gmail**: IMAP: `imap.gmail.com:993`, SMTP: `smtp.gmail.com:465` (requires app password)
- **Outlook/Office 365**: IMAP: `outlook.office365.com:993`, SMTP: `smtp.office365.com:587`
- **Custom/cPanel**: Use your hosting provider's IMAP/SMTP settings
### Customization
Edit `src/config.ts` to customize:
- Priority scoring weights
- Classification keywords
- VIP sender list
- Cache settings
## ๐ Architecture
```
src/
โโโ index.ts # MCP server entry point
โโโ types.ts # TypeScript type definitions
โโโ config.ts # Configuration and constants
โโโ email/
โ โโโ client.ts # IMAP/SMTP email client
โโโ intelligence/
โ โโโ analyzer.ts # Main analysis orchestrator
โ โโโ categorizer.ts # Category classification
โ โโโ prioritizer.ts # Priority scoring
โ โโโ action-extractor.ts # Action item detection
โ โโโ sentiment.ts # Sentiment analysis
โ โโโ response-generator.ts # Response suggestions
โโโ tools/
โ โโโ test-server.ts # Health check tool
โ โโโ analyze-emails.ts # Email analysis tool
โ โโโ get-priorities.ts # Priority emails tool
โ โโโ send-email.ts # Email sending tool
โโโ utils/
โโโ cache.ts # LRU cache with TTL
โโโ logger.ts # Logging utility
```
## ๐ป Usage Examples
### Example 1: Morning Email Triage
**You**: "Good morning! What are my most urgent emails?"
**Claude**:
1. Calls `get_priority_emails(minPriority=8)`
2. Fetches your real emails via IMAP
3. Returns: "You have 2 urgent emails:
- CEO requesting Q4 report (Priority: 10/10)
- Client bug report (Priority: 9/10)"
### Example 2: Action Items
**You**: "What action items do I have from my emails?"
**Claude**:
1. Calls `analyze_emails(emailSource="unread")`
2. Extracts action items with deadlines
3. Returns organized list by priority
### Example 3: Send Response
**You**: "Reply to that CEO email saying I'll have the report by EOD"
**Claude**:
1. Generates appropriate response
2. Calls `send_email` with professional reply
3. Sends via SMTP from your configured email account
## ๐งช Testing
### Run Unit Tests
```bash
bun test
```
### Type Check
```bash
bun run type-check
```
### Manual Test
```bash
# Run server in dev mode
bun run dev
# In another terminal, you can test MCP protocol
```
## ๐ Troubleshooting
### Server Not Connecting
**Symptoms**: "No result received" or connection errors
**Solutions**:
1. **Restart Claude Desktop** - Must completely quit (Cmd+Q on macOS, or Exit on Windows/Linux) and reopen
2. **Check logs**:
- **macOS**: `~/Library/Logs/Claude/mcp-server-email-intelligence.log`
- **Windows**: `%APPDATA%\Claude\Logs\mcp-server-email-intelligence.log`
- **Linux**: `~/.config/Claude/logs/mcp-server-email-intelligence.log`
3. **Verify config path** in `claude_desktop_config.json`
4. **Check credentials** in env variables
### IMAP/SMTP Connection Errors
**Check**:
1. Credentials are correct in `.env` or config
2. IMAP/SMTP servers are reachable:
```bash
telnet your-imap-host.com 993
telnet your-smtp-host.com 465
```
3. For Gmail: Use an App Password instead of your regular password
4. Firewall allows connections
### No Emails Found
**Possible causes**:
- Inbox is empty
- Filter criteria too restrictive
- Demo mode enabled (`USE_DEMO_EMAILS=true`)
**Try**:
```
Analyze all emails in my inbox (limit 10)
```
### Demo Mode vs Real Mode
**Real Mode** (Production):
- Set `USE_DEMO_EMAILS=false`
- Fetches actual emails from IMAP
- Sends real emails via SMTP
**Demo Mode** (Testing):
- Set `USE_DEMO_EMAILS=true`
- Uses 6 built-in demo emails
- No real email connections
## ๐ Security
- โ
Credentials stored in environment variables (gitignored)
- โ
SSL/TLS encryption for IMAP and SMTP
- โ
No email content permanently stored
- โ
Analysis cached temporarily (5-min TTL)
- โ
Logs go to stderr (not interfering with MCP protocol)
## ๐ Performance
- **Target**: Analyze 50 emails in < 1 second
- **Cache**: LRU with 5-minute TTL
- **Memory**: < 100MB for 1000 emails
- **Throughput**: 1000+ emails/minute
## ๐ Development
### Project Setup
```bash
bun install
bun run build
```
### Watch Mode
```bash
bun --watch run src/index.ts
```
### Build
```bash
bun run build
```
## ๐ Resources
The server exposes these MCP resources:
- `email://intelligence/rules` - Current classification rules and keywords
- `email://intelligence/stats` - Cache statistics and performance metrics
## ๐ What Makes This Special
### Intelligent Analysis
- Goes beyond simple keyword matching
- Multi-factor priority scoring
- Context-aware categorization
- Deadline detection and tracking
### Real Email Integration
- Direct IMAP/SMTP connection
- No third-party APIs needed
- Full control over your data
- Works with any email provider
### Claude Integration
- Native MCP protocol
- Seamless conversation flow
- Natural language queries
- Contextual responses
## ๐ License
MIT
## ๐จโ๐ป Author
[Calvin Magezi](https://github.com/CalvinMagezi) & Claude
---
**Version**: 1.0.0
**Status**: โ
Production Ready
**License**: MIT
## ๐ Support
For issues or questions:
1. Check the [troubleshooting section](#-troubleshooting) above
2. Review logs in your Claude logs directory (see troubleshooting section for paths)
3. Verify configuration in `claude_desktop_config.json`
4. Test with demo mode first: `USE_DEMO_EMAILS=true`
5. [Open an issue](https://github.com/Kolaborate-Platforms/kola-mail/issues) on GitHub
## ๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
---
**Last Updated**: October 22, 2025
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues