Overview
This guide covers advanced configuration options for timeout tuning, cursor pagination management, and performance optimization based on your deployment environment.Timeout Configuration
All timeout values are in milliseconds. Adjust based on network conditions, server performance, and workload characteristics.Connection Timeout
Time to establish TCP connection and complete TLS handshake.Default: 30,000 ms (30 seconds)When to increase:
- High-latency networks
- Slow TLS handshake on constrained systems
- Network congestion issues
Greeting Timeout
Time to receive IMAP server greeting after connection establishment.Default: 15,000 ms (15 seconds)When to increase:
- Overloaded IMAP servers
- Slow authentication backends
- Geographically distant servers
Socket I/O Timeout
Timeout for individual socket operations (idle, read, write). This is the timeout for most IMAP commands.Default: 300,000 ms (5 minutes)When to increase:
- Processing large mailboxes
- Slow message retrieval
- Complex search operations
- Need faster failure detection
- Implementing custom retry logic
Cursor Pagination Configuration
Cursor-based pagination enables efficient navigation through large search results. Cursors are stored in memory with TTL and LRU eviction.Cursor Time-to-Live
How long cursors remain valid after creation.Default: 600 seconds (10 minutes)Trade-offs:
- Shorter TTL: Less memory usage, more frequent re-searches needed
- Longer TTL: Better UX for slow workflows, higher memory usage
Cursor Storage Limit
Maximum number of cursors stored in memory. When exceeded, oldest unused cursors are evicted (LRU).Default: 512 entriesTrade-offs:
- Lower limit: Less memory usage, cursors may expire sooner
- Higher limit: Supports more concurrent searches, higher memory usage
Performance Tuning Profiles
High-Volume Workloads
For batch processing and large mailbox operations:- Processing large mailboxes (100k+ messages)
- Running batch operations
- Multiple concurrent search operations
- Slow, deliberate workflows
Low-Latency Interactive Use
For interactive use with quick response requirements:- Interactive user-facing applications
- Need fast error feedback
- Quick request-response cycles
- Limited search result pagination
Memory-Constrained Environments
For resource-limited deployments:- Running in containers with memory limits
- Embedded systems or edge devices
- Cost-sensitive cloud deployments
- Single-user or low-concurrency scenarios
Port and Security Configuration
Standard IMAPS (Recommended)
Implicit TLS on port 993:Only implicit TLS (IMAPS) is supported. STARTTLS is not supported.
TLS Enforcement
TLS is currently enforced totrue and cannot be disabled:
- TLS certificate verification is enforced
- Hostname verification is performed
- Connection fails if certificates cannot be validated
Multiple Accounts Configuration
Configure multiple accounts with unique identifiers:Account ID Rules
- Pattern:
^[A-Z0-9_]+$(uppercase in environment variables) - Normalized: Converted to lowercase for tool calls
- Length: 1-64 characters
- Must be unique across all accounts
Troubleshooting Performance Issues
Connection Timeouts
- Verify network connectivity to IMAP host
- Check firewall allows outbound on port 993
- Increase
MAIL_IMAP_CONNECT_TIMEOUT_MS - Try from different network to isolate issue
Socket Operation Timeouts
- Increase
MAIL_IMAP_SOCKET_TIMEOUT_MSfor large operations - Reduce search scope (narrower date ranges, filters)
- Check IMAP server performance
- Consider pagination with smaller
limitvalues
Cursor Expired Errors
- Increase
MAIL_IMAP_CURSOR_TTL_SECONDS - Increase
MAIL_IMAP_CURSOR_MAX_ENTRIESif many concurrent searches - Complete pagination faster
- Re-execute search to get new cursor
Memory Usage Issues
Symptoms: High memory usage, OOM errors Resolution:- Decrease
MAIL_IMAP_CURSOR_MAX_ENTRIES - Decrease
MAIL_IMAP_CURSOR_TTL_SECONDS - Limit concurrent operations
- Monitor cursor creation and eviction rates
Docker-Specific Configuration
When running in Docker, pass environment variables via--env-file or -e:
File-based env loading (
--env-file) takes precedence over -e flags.Monitoring and Observability
Logging Configuration
The server usestracing with environment-based filtering:
Response Metadata
All tool responses include timing metadata:duration_ms to identify slow operations and tune timeouts accordingly.
Configuration Validation
View current configuration and discovered accounts:- Discovered account sections from environment
- Current variable values (passwords redacted)
- Global policy defaults
- Write gate status
Best Practices
- Start with defaults - Only tune when necessary based on observed behavior
- Monitor performance - Use
duration_msmetadata to identify bottlenecks - Tune incrementally - Make small adjustments and measure impact
- Document changes - Keep notes on why specific values were chosen
- Environment-specific - Use different configs for dev/staging/production
- Review periodically - Re-evaluate settings as workload changes