# MCP Email Server Configuration
# Copy this file to .env and configure your settings
# ==============================================
# ENCRYPTION CONFIGURATION (REQUIRED)
# ==============================================
# Secret key for encrypting IMAP passwords
# Generate a strong, unique key and keep it secure
# IMPORTANT: Changing this key will invalidate all encrypted passwords
EMAIL_ENCRYPTION_KEY=your-secret-encryption-key-here
# ==============================================
# GMAIL OAUTH2 CONFIGURATION
# ==============================================
# Get these from Google Cloud Console:
# 1. Create project
# 2. Enable Gmail API
# 3. Create OAuth2 credentials (Desktop application)
GMAIL_CLIENT_ID=your-gmail-client-id
GMAIL_CLIENT_SECRET=your-gmail-client-secret
GMAIL_REDIRECT_URI=http://localhost:3000/oauth2callback
# ==============================================
# GMAIL ACCOUNT TOKENS
# ==============================================
# Obtain these through OAuth2 flow
# Each account needs access_token and refresh_token
# Account names should be descriptive (e.g., personal, work, etc.)
# Example: Personal Gmail account
GMAIL_REFRESH_TOKEN_personal=your-refresh-token
# Example: Work Gmail account
GMAIL_REFRESH_TOKEN_business=your-refresh-token-2
# Example: Additional Gmail account (add as many as needed)
GMAIL_REFRESH_TOKEN_worker=your-refresh-token-3
GMAIL_REFRESH_TOKEN_info=your-refresh-token-4
# ==============================================
# IMAP CONFIGURATION (Generic IMAP servers)
# ==============================================
# Configure multiple IMAP accounts using the pattern:
# IMAP_HOST_accountname, IMAP_PORT_accountname, etc.
# Example: Generic IMAP account
IMAP_HOST_myimap=imap.example.com
IMAP_PORT_myimap=993
IMAP_SECURE_myimap=true
IMAP_USER_myimap=user@example.com
# Encrypt password using: node -e "console.log(require('./dist/crypto').encrypt('password', process.env.EMAIL_ENCRYPTION_KEY))"
IMAP_PASSWORD_myimap=encrypted_password_here
# Example: Another IMAP account
# IMAP_HOST_company=mail.company.com
# IMAP_PORT_company=993
# IMAP_SECURE_company=true
# IMAP_USER_company=john@company.com
# IMAP_PASSWORD_company=another_encrypted_password_here
# Example: Non-SSL IMAP (less secure, not recommended)
# IMAP_HOST_oldserver=mail.oldserver.com
# IMAP_PORT_oldserver=143
# IMAP_SECURE_oldserver=false
# IMAP_USER_oldserver=user@oldserver.com
# IMAP_PASSWORD_oldserver=encrypted_password_for_old_server
# ==============================================
# XSERVER CONFIGURATION (Japanese hosting)
# ==============================================
# Simplified configuration for xserver.jp accounts
# Automatically configures IMAP settings for xserver
# Example: XServer account
XSERVER_DOMAIN_info_h_fpo_com=h-fpo.com
XSERVER_USERNAME_info_h_fpo_com=info
# Encrypt password using the same method as IMAP passwords
XSERVER_PASSWORD_info_h_fpo_com=encrypted_password_here
XSERVER_DOMAIN_kh_h_fpo_com=h-fpo.com
XSERVER_USERNAME_kh_h_fpo_com=kh
XSERVER_PASSWORD_kh_h_fpo_com=encrypted_password_here
XSERVER_DOMAIN_worker_h_fpo_com=h-fpo.com
XSERVER_USERNAME_worker_h_fpo_com=worker
XSERVER_PASSWORD_worker_h_fpo_com=encrypted_password_here
# ==============================================
# OPTIONAL CONFIGURATION
# ==============================================
# Node.js environment
NODE_ENV=development
# Debug mode (uncomment to enable detailed logging)
DEBUG=false
# Custom timeout settings (in milliseconds)
# EMAIL_TIMEOUT=30000
# IMAP_CONNECTION_TIMEOUT=10000
# Maximum number of emails to return in searches (default: 20)
# MAX_SEARCH_RESULTS=50
# ==============================================
# EMAIL FETCHING LIMITS
# ==============================================
# Control how many emails are fetched for performance
# Maximum emails to fetch for content/details (default: 500)
# This applies to listEmails, searchEmails methods
MAX_EMAIL_CONTENT_LIMIT=500
# For unread count accuracy vs performance (Gmail only)
# Maximum pages to fetch when counting unread emails (default: 2)
# Each page = 500 emails, so 2 pages = up to 1000 emails counted
MAX_EMAIL_FETCH_PAGES=2
# Maximum emails per page for Gmail API (default: 500, max: 500)
MAX_EMAIL_FETCH_PER_PAGE=500
# ==============================================
# SECURITY NOTES
# ==============================================
# 1. Never commit this file with real credentials to version control
# 2. Use strong, unique encryption keys
# 3. Regularly rotate OAuth2 tokens
# 4. Store this file securely with appropriate file permissions
# 5. Consider using a secrets management system in production
# ==============================================
# SETUP INSTRUCTIONS
# ==============================================
# 1. Copy this file to .env
# 2. Replace all example values with your actual configuration
# 3. Encrypt all passwords using the crypto utility
# 4. Test configuration with: node test-connection.js
# 5. Build the project: npm run build
# 6. Configure Cursor MCP settings with absolute path to dist/index.js
# ==============================================
# タイムアウト設定 (ミリ秒)
# ==============================================
# Gmail APIタイムアウト(デフォルト: 60000ms = 60秒)
GMAIL_TIMEOUT_MS=60000
# IMAP接続タイムアウト(デフォルト: 30000ms = 30秒)
IMAP_CONNECTION_TIMEOUT_MS=30000
# IMAP操作タイムアウト(デフォルト: 60000ms = 60秒)
IMAP_OPERATION_TIMEOUT_MS=60000
# 統合検索タイムアウト(デフォルト: 25000ms = 25秒)
SEARCH_ALL_TIMEOUT_MS=25000
# ==============================================
# タイムゾーン設定
# ==============================================
# デフォルトタイムゾーン(優先順位:TZ環境変数 > EMAIL_DEFAULT_TIMEZONE > システム検出 > Asia/Tokyo)
# 日時指定時にタイムゾーン情報がない場合に使用されます
# 例: Asia/Tokyo, America/New_York, Europe/London, UTC
# EMAIL_DEFAULT_TIMEZONE=Asia/Tokyo
# システムのTZ環境変数も利用可能です(最優先)
# TZ=Asia/Tokyo