An IMAP Model Context Protocol (MCP) server to expose IMAP operations
imap-mcp
š§ An IMAP Model Context Protocol (MCP) server to expose IMAP operations as tools for AI assistants.
⨠Features
- Email Draft Creation: Create draft emails that are saved to your IMAP server's drafts folder
- IMAP Integration: Connect to any IMAP-compatible email server (Gmail, Outlook, etc.)
- Secure Authentication: Uses environment variables for secure credential management
- MCP Compatible: Works with Claude and other AI assistants that support the Model Context Protocol
- TypeScript: Full TypeScript support with proper type definitions
Setup
{
"mcpServers": {
...,
"imap": {
"command": "npx",
"args": [
"imap-mcp"
],
"env": {
"IMAP_HOST": "<IMAP host>",
"IMAP_PORT": "<IMAP port>",
"IMAP_USERNAME": "<IMAP username>",
"IMAP_PASSWORD": "<IMAP password>",
"IMAP_USE_SSL": "<true or false>"
}
}
}
}
Usage
- Compile TypeScript to JavaScript:
npx tsc
- Run the MCP server:
node dist/index.js
Available Tools
`create-draft`
Creates a draft email message and saves it to the IMAP server's drafts folder.
Parameters:
to(string, required): The recipient's email addresssubject(string, required): The email subject linebody(string, required): The email body contentfrom(string, optional): The sender's email address (defaults to IMAP_USERNAME)
Example:
{
"to": "recipient@example.com",
"subject": "Meeting Reminder",
"body": "Don't forget about our meeting tomorrow at 2 PM.",
"from": "sender@example.com"
}
The tool will attempt to save the draft to either "INBOX.Drafts" or "Drafts" folder, depending on your email server's folder structure.
License
MIT
Tools (1)
create-draftCreates a draft email message and saves it to the IMAP server's drafts folder.Environment Variables
IMAP_HOSTrequiredThe hostname of the IMAP serverIMAP_PORTrequiredThe port number for the IMAP serverIMAP_USERNAMErequiredThe username for email authenticationIMAP_PASSWORDrequiredThe password for email authenticationIMAP_USE_SSLrequiredWhether to use SSL for the connection (true or false)Configuration
{"mcpServers": {"imap": {"command": "npx", "args": ["imap-mcp"], "env": {"IMAP_HOST": "<IMAP host>", "IMAP_PORT": "<IMAP port>", "IMAP_USERNAME": "<IMAP username>", "IMAP_PASSWORD": "<IMAP password>", "IMAP_USE_SSL": "<true or false>"}}}}