mcp-imap-server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-imap-servershow me my unread emails from yesterday"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP IMAP Server
A Model Context Protocol (MCP) server that enables Claude and other LLM applications to read emails via the IMAP protocol. This server provides secure, read-only access to email accounts from popular providers like Gmail, Outlook, Yahoo, and custom IMAP servers.
Features
π Secure Authentication: Support for username/password authentication with secure credential handling
π§ Email Operations: Search, read, and manage emails with comprehensive filtering options
π Folder Management: List and navigate email folders/mailboxes
π·οΈ Email Status: Mark emails as read/unread
π Advanced Search: Search by sender, subject, date range, content, and read status
π Provider Support: Pre-configured for Gmail, Outlook, Yahoo, iCloud, and custom IMAP servers
π‘οΈ Security First: Read-only access, no email sending or deletion capabilities
β‘ Performance: Efficient connection pooling and error handling
Related MCP server: IMAP Email MCP Server
Quick Start
Installation
git clone <repository-url>
cd mcp-imap-server
npm install
npm run buildConfiguration
Create a .env file in the project root:
# Required: IMAP server configuration
IMAP_HOST=imap.gmail.com
IMAP_PORT=993
IMAP_USER=your-email@gmail.com
IMAP_PASSWORD=your-app-password
IMAP_TLS=true
# Optional: Connection settings
IMAP_AUTH_TIMEOUT=3000
IMAP_CONN_TIMEOUT=10000
IMAP_KEEPALIVE_INTERVAL=10000
IMAP_IDLE_INTERVAL=300000
IMAP_FORCE_NOOP=falsePopular Email Provider Settings
Gmail
IMAP_HOST=imap.gmail.com
IMAP_PORT=993
IMAP_TLS=trueOutlook/Hotmail
IMAP_HOST=outlook.office365.com
IMAP_PORT=993
IMAP_TLS=trueYahoo Mail
IMAP_HOST=imap.mail.yahoo.com
IMAP_PORT=993
IMAP_TLS=trueiCloud Mail
IMAP_HOST=imap.mail.me.com
IMAP_PORT=993
IMAP_TLS=trueRunning the Server
# Development mode
npm run dev
# Production mode
npm run build
npm startMCP Tools
The server exposes the following tools to MCP clients:
search_emails
Search for emails based on various criteria.
Parameters:
sender(optional): Filter by sender email address or namesubject(optional): Filter by subject line (partial match)dateFrom(optional): Start date for date range filter (ISO format: YYYY-MM-DD)dateTo(optional): End date for date range filter (ISO format: YYYY-MM-DD)content(optional): Search within email content/body textunread(optional): Filter by read status (true for unread only, false for read only)folder(optional): Folder to search in (defaults to INBOX)limit(optional): Maximum number of emails to return (1-100)
Example:
{
"name": "search_emails",
"arguments": {
"sender": "notifications@github.com",
"unread": true,
"limit": 10
}
}get_email
Retrieve the full content of a specific email by its message ID.
Parameters:
messageId(required): The message ID or UID of the email to retrievefolder(optional): Folder containing the email (defaults to INBOX)
Example:
{
"name": "get_email",
"arguments": {
"messageId": "12345",
"folder": "INBOX"
}
}list_folders
List all available email folders/mailboxes in the account.
Parameters:
includeSpecial(optional): Include special folders like Sent, Drafts, etc.
Example:
{
"name": "list_folders",
"arguments": {
"includeSpecial": true
}
}get_recent_emails
Get the most recent emails from a specific folder.
Parameters:
folder(optional): Folder to get emails from (defaults to INBOX)limit(optional): Number of recent emails to retrieve (1-50, default: 10)unreadOnly(optional): Only return unread emails
Example:
{
"name": "get_recent_emails",
"arguments": {
"folder": "INBOX",
"limit": 5,
"unreadOnly": true
}
}mark_as_read
Mark an email as read or unread.
Parameters:
messageId(required): The message ID or UID of the email to markfolder(optional): Folder containing the email (defaults to INBOX)read(optional): Mark as read (true) or unread (false). Default: true
Example:
{
"name": "mark_as_read",
"arguments": {
"messageId": "12345",
"read": true
}
}Security Considerations
Email Provider Setup
Gmail
Enable 2-factor authentication
Generate an App Password (not your regular password)
Use the App Password as
IMAP_PASSWORD
Outlook/Hotmail
Enable 2-factor authentication
Generate an App Password
Use the App Password as
IMAP_PASSWORD
Other Providers
Consult your email provider's documentation for IMAP access and app password setup.
Best Practices
Never log credentials: The server is designed to never log sensitive information
Use app passwords: Always use app-specific passwords, never your main account password
Read-only access: The server only provides read operations for security
Secure storage: Store credentials securely and never commit them to version control
Network security: Always use TLS/SSL connections (enabled by default)
Development
Project Structure
src/
βββ config/ # Configuration management
βββ services/ # IMAP connection and management
βββ tools/ # MCP tool implementations
βββ types/ # TypeScript type definitions
βββ index.ts # Main server entry pointAvailable Scripts
npm run build # Build TypeScript to JavaScript
npm run dev # Run in development mode with auto-reload
npm start # Run the built server
npm test # Run tests
npm run lint # Lint the code
npm run typecheck # Type check without building
npm run clean # Clean build directoryAdding New Tools
Define types in
src/types/index.tsAdd Zod validation schema
Implement the tool logic in
src/tools/index.tsRegister the tool in
src/index.ts
Error Handling
The server includes comprehensive error handling for:
Authentication failures: Clear messages for invalid credentials
Connection issues: Timeout and network error handling
IMAP protocol errors: Detailed error messages for debugging
Validation errors: Input validation with helpful error messages
Troubleshooting
Common Issues
Authentication Failed
Verify your email and app password are correct
Ensure 2FA is enabled and you're using an app password
Check if IMAP is enabled in your email provider settings
Connection Timeout
Verify the IMAP host and port settings
Check your firewall and network settings
Try increasing the connection timeout values
TLS/SSL Errors
Ensure
IMAP_TLS=truefor secure connectionsVerify your email provider supports the specified port with TLS
Debug Mode
Set NODE_ENV=development to enable debug logging:
NODE_ENV=development npm run devContributing
Fork the repository
Create a feature branch
Make your changes with proper tests
Ensure all tests pass and code is properly typed
Submit a pull request
License
MIT License - see LICENSE file for details.
Support
For issues and questions:
Check the troubleshooting section above
Review your email provider's IMAP documentation
Open an issue on GitHub with detailed error messages and configuration (without credentials)
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-quality-maintenanceEnables AI assistants to interact with Gmail accounts through IMAP/SMTP, supporting reading, sending, replying to emails, managing threads, downloading attachments, and searching with Gmail syntax using simple app password authentication.
- AlicenseAqualityFmaintenanceEnables AI assistants to read, search, compose, and send emails by connecting to any IMAP/SMTP provider. It supports comprehensive mailbox management, including draft handling and message deletion, directly through natural language.101529MIT
- FlicenseAqualityCmaintenanceEnables AI assistants to read recent emails and fetch full email content from an IMAP inbox, allowing natural language queries about email summaries.3
- AlicenseAqualityDmaintenanceEnables LLM clients to read and search email via IMAP with tools for listing folders, searching messages, and fetching message content. It supports pagination, snippets, and thread context, and is designed for local AI workflows.10MIT
Related MCP Connectors
Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflowβ¦
Read, search, send, organize, draft and schedule email across your inboxes from any MCP client.
Email OS for agents - real-inbox search, triage, commitments, and a verifiable BEC hard-stop.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/mattias242/mcp-imap-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server