Usage Guide
This guide covers practical workflows, operating modes, and automation patterns for tai-mcp. Learn how to make the most of your AI email agent.
Operating Modes
tai-mcp operates in three distinct modes, each optimized for different use cases:
MCP Mode (Default)
Provides email tools to MCP-compatible clients like Claude Desktop.
npx tai-mcpUse Cases:
- Interactive email management with Claude Desktop
- Manual email processing and responses
- On-demand email workflows
- Testing and development
Live Mode
Automatically monitors for new emails and invokes Claude Code to process them.
npx tai-mcp liveUse Cases:
- Automated email assistant
- 24/7 email monitoring
- Hands-free email processing
- Customer support automation
Registration Mode
Creates new user accounts and configures email addresses.
npx tai-mcp register [username]Use Cases:
- Initial setup
- Creating multiple accounts
- Account management
Email Workflows
Basic Email Sending
Scenario: Send a notification email with markdown content.
Send an email to [email protected] with the subject "Project Update" and this content:
# Weekly Project Update
## Completed Tasks
- Feature implementation ✅
- Testing phase ✅
- Documentation updates ✅
## Next Week
- Deployment preparation
- User training sessions
Best regards,
Your AI Assistanttai-mcp automatically:
- Converts markdown to HTML
- Sends email with proper formatting
- Returns confirmation with message ID
Reading Incoming Emails
Scenario: Check for and process new emails.
Check my inbox for new emails and show me any unread messages.tai-mcp will:
- List unread emails in a formatted table
- Show sender, subject, date, and status
- Provide email IDs for further processing
Follow-up: Process a specific email.
Fetch and read email ID 12345tai-mcp will:
- Retrieve the full email content
- Convert HTML to markdown for AI processing
- Mark the email as read
- Display formatted content
Email Conversations
Scenario: Reply to an email with context.
Reply to email ID 12345 with:
Thank you for your inquiry. I've reviewed your request and here's the information you need:
## Product Information
- **Model:** XYZ-Pro
- **Price:** $299.99
- **Availability:** In stock
Would you like me to process your order?tai-mcp will:
- Maintain proper email threading
- Add RFC-compliant headers (In-Reply-To, References)
- Convert markdown to HTML
- Send reply with conversation context
Live Mode Workflows
Live mode enables fully automated email processing. Here's how it works:
Setup Live Mode
Configure Environment:
bashexport NAME=your-username export PASSWORD=your-password export INSTANCE=assistant export LOG_LEVEL=infoStart Live Mode:
bashnpx tai-mcp liveMonitor Logs:
🚀 Email poller starting... 📧 Instance email: [email protected] ⏰ Polling every 5 seconds ✅ Ready for incoming emails
Automated Processing Flow
When a new email arrives:
- Detection: tai-mcp polls every 5 seconds for new emails
- Trigger: New email detected, logs message details
- Invocation: Executes
claude-codewith processing prompt - Processing: Claude Code uses MCP tools to read and respond
- Completion: Response sent, conversation archived
Live Mode Example
Incoming Email:
From: [email protected]
Subject: Question about product return
Body: Hi, I bought product XYZ last week but it's not working properly. Can I return it?Automated Response Process:
- tai-mcp detects new email
- Invokes Claude Code with prompt: "Please resolve the unread email and send the response back to the user after the email is resolved"
- Claude Code reads email content
- Generates appropriate response
- Sends reply with return policy information
Live Mode Configuration
Adjust Polling Frequency:
# Check every 2 seconds (more responsive)
export POLL_INTERVAL=2000
# Check every 30 seconds (less resource intensive)
export POLL_INTERVAL=30000Customize Processing Prompt: The default prompt can be customized in the email-poller service for specific use cases.
Advanced Workflows
Multi-Instance Email Management
Manage multiple email contexts with different instances:
Customer Support Instance:
export INSTANCE=support
npx tai-mcp live
# Emails: [email protected]Personal Assistant Instance:
export INSTANCE=personal
npx tai-mcp live
# Emails: [email protected]Development Instance:
export INSTANCE=dev
npx tai-mcp
# Emails: [email protected]Batch Email Processing
Scenario: Process multiple emails efficiently.
1. List all unread emails in my inbox
2. For each unread email, read the content and categorize it as:
- Support request
- Business inquiry
- Newsletter/promotional
- Personal message
3. Provide a summary of each categoryEmail Filtering and Organization
Scenario: Intelligent email management.
Check my inbox and:
1. Identify urgent emails (keywords: urgent, asap, important)
2. Categorize by sender domain
3. Flag emails that need immediate response
4. Create a priority action listContent Processing Workflows
Scenario: Extract and process email content.
Read the latest email and:
1. Extract any dates mentioned
2. Identify action items or tasks
3. Create a follow-up reminder
4. Draft a response acknowledging receiptIntegration Patterns
With Claude Desktop
tai-mcp integrates seamlessly with Claude Desktop, providing natural email interactions:
Example Conversations:
- "Send a meeting reminder to the team"
- "Check if there are any urgent emails"
- "Reply to Sarah's email about the project deadline"
- "Forward the budget report to finance team"
With External Systems
Webhook Integration: Trigger external systems based on email events.
CRM Integration: Automatically create support tickets from customer emails.
Calendar Integration: Extract meeting requests and create calendar events.
Error Handling and Recovery
Common Scenarios
Authentication Failure:
Error: Invalid credentialsRecovery: Verify NAME and PASSWORD environment variables
Network Issues:
Error: Unable to connect to APIRecovery: Check internet connection and API_BASE_URL
Rate Limiting:
Error: Too many requestsRecovery: Increase POLL_INTERVAL to reduce API calls
Debugging Workflows
Enable Debug Logging:
export LOG_LEVEL=debug
npx tai-mcpMonitor API Calls: Debug logs show detailed API request/response information.
Test Connectivity:
curl https://tai.chat/api/v1/healthPerformance Optimization
Email Processing Performance
Optimize Polling:
- Use appropriate POLL_INTERVAL (default: 5000ms)
- Monitor system resources
- Adjust based on email volume
Content Processing:
- tai-mcp automatically converts HTML to markdown for faster AI processing
- Large emails are handled efficiently with streaming
Resource Management
Memory Usage:
- tai-mcp uses minimal memory footprint
- JWT tokens stored in memory only
- No persistent local storage
Network Usage:
- Efficient API calls with automatic retry
- Compressed responses when supported
- Connection pooling for multiple requests
Security Considerations
Email Security
Content Safety:
- All email content is processed securely
- No content stored locally
- Automatic HTML sanitization
Authentication Security:
- JWT tokens with automatic refresh
- No credentials logged or exposed
- Secure environment variable handling
Best Practices
- Use Strong Passwords: 8+ characters with mixed types
- Secure Environment Variables: Never commit credentials
- Regular Updates: Keep tai-mcp updated via npx
- Monitor Logs: Watch for unusual activity
- Network Security: Use HTTPS endpoints only
Troubleshooting
Common Issues
Emails Not Sending:
- Check authentication credentials
- Verify recipient email address
- Check network connectivity
- Review error logs
Live Mode Not Working:
- Verify polling interval configuration
- Check Claude Code installation
- Monitor system resources
- Review process permissions
Content Not Processing:
- Check email content format
- Verify markdown conversion
- Test with simple content first
- Review API response logs
Getting Help
- Enable Debug Logging:
LOG_LEVEL=debug - Review Error Messages: Full error context in logs
- Check Network Connectivity: Test API endpoints
- File GitHub Issues: Include logs and reproduction steps
Next Steps
Master tai-mcp with these advanced resources:
- API Reference - Complete tool documentation with examples
- Development Guide - Architecture and implementation details
- GitHub Repository - Source code and issue tracking