Overview
The Mail IMAP MCP Server uses a structured error model that maps application errors to MCP protocol error codes. Understanding error types and their recovery patterns is essential for robust integration.Error Categories
All errors are categorized into six types, each with specific causes and recovery strategies.Invalid Input
Code:invalid_inputMCP Type:
invalid_paramsRetryable: No Input validation failed. The request contains malformed data, missing required fields, or values outside acceptable ranges.
Common causes
Common causes
- Invalid
account_id(not configured) - Malformed
message_idformat limitoutside 1-50 rangebody_max_charsoutside 100-20,000 range- Search matched > 20,000 messages
- Cursor invalid or expired
- Write operations disabled but write tool called
- Delete operation missing
confirm: true
- Validate input parameters before submission
- Check configuration for valid account IDs
- Add more specific filters to narrow search results
- Ensure write operations are enabled when needed
Not Found
Code:not_foundMCP Type:
resource_not_foundRetryable: No The requested resource does not exist or is not accessible.
Common causes
Common causes
- Mailbox name doesn’t exist
- Message UID no longer exists (deleted)
- Account not configured
- Mailbox not accessible with current permissions
- Use
imap_list_mailboxesto verify mailbox names - Check if message still exists before fetching
- Verify account configuration with
imap_list_accounts
Authentication Failed
Code:auth_failedMCP Type:
invalid_requestRetryable: No (until credentials updated) IMAP authentication failed due to incorrect credentials or account restrictions.
Common causes
Common causes
- Incorrect username or password
- Using account password instead of app-specific password
- IMAP access disabled for account
- Account locked or suspended
- Two-factor authentication required
Example: Authentication failure
- Verify credentials are correct
- Generate app-specific password for Gmail/Outlook
- Enable IMAP access in email provider settings
- Check account status with provider
Timeout
Code:timeoutMCP Type:
internal_errorRetryable: Yes Operation exceeded configured timeout duration.
Common causes
Common causes
- TCP connect timeout (default: 30s)
- TLS handshake timeout
- IMAP server not responding
- Network connectivity issues
- Large mailbox operations taking too long
- Retry the operation (transient network issue)
- Increase timeout values via environment variables:
- Check network connectivity
- Reduce scope of operation (smaller search, fewer messages)
Conflict
Code:conflictMCP Type:
invalid_requestRetryable: Yes (with new request) The resource state changed since it was last accessed, making the current operation invalid.
Common causes
Common causes
- Mailbox UIDVALIDITY changed during pagination
- Mailbox was deleted and recreated
- Message moved/deleted between operations
- Cursor references outdated mailbox state
Example: Mailbox snapshot changed
- Discard cursor and restart search from beginning
- Refresh mailbox list before operations
- Handle gracefully in pagination loops
Internal Error
Code:internalMCP Type:
internal_errorRetryable: Sometimes Unexpected server error or external dependency failure.
Common causes
Common causes
- IMAP server error responses
- TLS handshake failure
- Message parsing failure
- Unexpected IMAP protocol behavior
Example: Internal error
- Retry with exponential backoff
- Check IMAP server status
- Report persistent errors to maintainers
Tool-Level Issues
Some tools return successful responses with anissues array instead of throwing errors. This allows partial success scenarios.
Issue Structure
Each issue includes:code- Error code (matches error categories)stage- Operation stage where error occurredmessage- Human-readable descriptionretryable- Whether operation can be retrieduid- Message UID (when applicable)message_id- Message identifier (when applicable)
Example: Partial search failure
Status Values
Tools return astatus field indicating operation outcome:
ok- Fully successful, no issuespartial- Partially successful, some issues encounteredfailed- Failed completely, checkissuesarray
Recovery Patterns
Exponential Backoff for Retryable Errors
Handling Cursor Expiration
Handling Mailbox Conflicts
Processing Partial Successes
Error Response Examples
Connection Errors
TCP connect timeout
TCP connect timeout
MAIL_IMAP_CONNECT_TIMEOUT_MS or check network connectivity.TLS handshake failed
TLS handshake failed
Validation Errors
Write operations disabled
Write operations disabled
MAIL_IMAP_WRITE_ENABLED=true in environment.Delete confirmation missing
Delete confirmation missing
"confirm": true in delete request.Invalid message ID format
Invalid message ID format
imap:{account}:{mailbox}:{uidvalidity}:{uid}.Best Practices
Next Steps
Multi-Account Setup
Configure multiple IMAP accounts
API Reference
View complete tool documentation