Skip to main content
This page covers the most frequently encountered errors and their solutions.

Write Operations Disabled

Error Code: invalid_inputFull Message:
Error: invalid input: write tools are disabled; set MAIL_IMAP_WRITE_ENABLED=true
Cause: Write operations (copy, move, delete, flag updates) are disabled by default for safety.Solution:
  1. Add MAIL_IMAP_WRITE_ENABLED=true to your environment configuration
  2. Restart the MCP server
  3. Verify the setting is applied by running imap_verify_account
Example Configuration:
{
  "mcpServers": {
    "mail-imap": {
      "command": "npx",
      "args": ["-y", "@bradsjm/mail-imap-mcp-rs@latest"],
      "env": {
        "MAIL_IMAP_DEFAULT_HOST": "imap.gmail.com",
        "MAIL_IMAP_DEFAULT_USER": "[email protected]",
        "MAIL_IMAP_DEFAULT_PASS": "app-password",
        "MAIL_IMAP_WRITE_ENABLED": "true"
      }
    }
  }
}

Cursor and Pagination Errors

Error Code: invalid_inputFull Message:
Error: invalid input: cursor is invalid or expired
Cause:
  • Cursor has expired (default TTL: 10 minutes)
  • Cursor was evicted from the LRU cache (default max: 512 cursors)
  • Server was restarted
Solution: Rerun the search without a cursor parameter to start a fresh search:
{
  "account_id": "default",
  "mailbox": "INBOX",
  "limit": 20
}
To Increase Cursor Lifetime:
MAIL_IMAP_CURSOR_TTL_SECONDS=1800  # 30 minutes
MAIL_IMAP_CURSOR_MAX_ENTRIES=1024  # More cursors
Error Code: invalid_inputFull Message:
Error: invalid input: search matched 25000 messages; narrow filters to at most 20000 results
Cause: Search query matched too many messages (limit: 20,000 UIDs per cursor snapshot).Solution: Add more specific search filters:
  1. Use date ranges:
    {
      "account_id": "default",
      "mailbox": "INBOX",
      "last_days": 30
    }
    
  2. Filter by sender:
    {
      "account_id": "default",
      "mailbox": "INBOX",
      "from": "example.com"
    }
    
  3. Combine multiple filters:
    {
      "account_id": "default",
      "mailbox": "INBOX",
      "last_days": 60,
      "subject": "Invoice",
      "from": "billing@"
    }
    
  4. Use unread filter:
    {
      "account_id": "default",
      "mailbox": "INBOX",
      "unread_only": true
    }
    

Mailbox Errors

Error Code: not_foundFull Message:
Error: not found: cannot examine mailbox 'Archive/2024': ...
Cause:
  • Mailbox does not exist
  • Mailbox name is misspelled
  • Incorrect delimiter used in hierarchical mailbox names
Solution:
  1. List all mailboxes to verify the exact name:
    {
      "tool": "imap_list_mailboxes",
      "arguments": {
        "account_id": "default"
      }
    }
    
  2. Use the exact mailbox name from the list (case-sensitive)
  3. Pay attention to the delimiter (. vs / vs other)
Common Mailbox Names:
  • Gmail: INBOX, [Gmail]/Sent Mail, [Gmail]/Trash
  • Office 365: INBOX, Sent Items, Deleted Items
  • Generic IMAP: INBOX, Sent, Trash, Drafts
Error Code: not_foundFull Message:
Error: not found: account 'work' is not configured
Cause: The specified account ID was not found in the environment configuration.Solution:
  1. List configured accounts:
    {
      "tool": "imap_list_accounts"
    }
    
  2. Add the missing account to your environment:
    MAIL_IMAP_WORK_HOST=outlook.office365.com
    MAIL_IMAP_WORK_USER=[email protected]
    MAIL_IMAP_WORK_PASS=app-password
    
  3. Restart the MCP server
Account ID Rules:
  • Lowercase conversion: WORKwork, PERSONALpersonal
  • Special case: DEFAULTdefault
  • Non-alphanumeric characters become underscores

Message Errors

Error Code: not_foundFull Message:
Error: not found: message uid 12345 not found
Cause:
  • Message was deleted
  • Message was moved to another mailbox
  • UID is incorrect
  • UIDVALIDITY changed (mailbox was reset)
Solution:
  1. Search for the message again to get current UID:
    {
      "account_id": "default",
      "mailbox": "INBOX",
      "subject": "Meeting Notes"
    }
    
  2. Use the message ID from search results (not raw UIDs)
  3. If the message was moved, search in other mailboxes
Error Code: invalid_inputFull Message:
Error: invalid input: message_id must start with 'imap'
Cause: Invalid message ID format provided.Solution: Use the complete message ID returned by imap_search_messages:Correct Format:
imap://{account_id}/{mailbox}?uidvalidity={uidvalidity}&uid={uid}
Example:
imap://default/INBOX?uidvalidity=1234567890&uid=4567
Common Mistakes:
  • Using raw UID instead of full message ID
  • Copying partial message ID
  • Manually constructing message ID with wrong format

Configuration Errors

Error Code: invalid_inputFull Message:
No IMAP accounts configured. Set MAIL_IMAP_<ID>_HOST/USER/PASS.
mail-imap-mcp-rs startup error: missing HOST.
Cause: Required environment variables are not set or are empty.Solution: Configure at least one IMAP account:
{
  "mcpServers": {
    "mail-imap": {
      "command": "npx",
      "args": ["-y", "@bradsjm/mail-imap-mcp-rs@latest"],
      "env": {
        "MAIL_IMAP_DEFAULT_HOST": "imap.gmail.com",
        "MAIL_IMAP_DEFAULT_USER": "[email protected]",
        "MAIL_IMAP_DEFAULT_PASS": "your-app-password"
      }
    }
  }
}
Required Variables:
  • MAIL_IMAP_<ID>_HOST - IMAP server hostname
  • MAIL_IMAP_<ID>_USER - Username/email
  • MAIL_IMAP_<ID>_PASS - Password (use app-specific password)
Optional Variables:
  • MAIL_IMAP_<ID>_PORT - Default: 993
  • MAIL_IMAP_<ID>_SECURE - Default: true
Error Code: invalid_inputFull Message:
Error: invalid input: insecure IMAP is not supported; set MAIL_IMAP_<ACCOUNT>_SECURE=true
Cause: MAIL_IMAP_<ACCOUNT>_SECURE=false was set, but the server enforces TLS-only connections.Solution: Remove the SECURE=false setting or set it to true:
# Remove this line:
MAIL_IMAP_DEFAULT_SECURE=false

# Or explicitly set to true:
MAIL_IMAP_DEFAULT_SECURE=true
Security Note: Insecure connections are permanently disabled to prevent password exposure over unencrypted connections.

Validation Errors

Error Code: invalid_inputCause: Date format is incorrect or values are out of range.Solution: Use ISO 8601 date format (YYYY-MM-DD):Correct Examples:
{
  "since_date": "2024-01-15",
  "before_date": "2024-12-31"
}
Invalid Examples:
// Wrong format
"since_date": "01/15/2024"  // ❌
"since_date": "15-01-2024"  // ❌
"since_date": "2024-13-01"  // ❌ Month > 12
Error Code: invalid_inputCause: Input parameter is outside the allowed range.Solution: Use values within the documented bounds:
ParameterMinimumMaximum
body_max_chars10020,000
snippet_max_chars50500
attachment_text_max_chars10050,000
max_bytes (raw message)1,0241,000,000
limit (search)150
Example:
{
  "message_id": "imap://default/INBOX?uidvalidity=123&uid=456",
  "body_max_chars": 5000,  // ✓ Valid
  "include_html": true
}

Build docs developers (and LLMs) love