IMAP MCP Server for AI Assistants
Enable AI assistants to access and manage email via an IMAP MCP server that exposes IMAP operations as callable tools for automation and integration.
npx -y @dominik1001/imap-mcpOverview
This MCP (Model Context Protocol) server exposes IMAP operations as callable tools so AI assistants can access and manage email programmatically. It is implemented in TypeScript and designed to run as an MCP-compatible subprocess, presenting IMAP functionality (currently drafting) as tool endpoints that assistants such as Claude can call during workflows.
You can use the server to create and save draft messages directly on an IMAP account, enabling assistants to prepare emails for review or automation pipelines without requiring direct mailbox credentials in the assistant. The server is lightweight and intended to be added to an MCP server list or launched as a standalone process that reads IMAP credentials from environment variables.
Source code and issues: https://github.com/dominik1001/imap-mcp
Features
- Create email drafts and save them to the IMAP server’s Drafts folder
- Compatible with any IMAP-compliant server (Gmail, Outlook, self-hosted servers)
- Environment-driven configuration for credentials and host settings
- MCP-compatible tool interface so AI assistants can call IMAP operations
- Implemented in TypeScript with shipped type definitions for easier extension
Installation / Configuration
Install and run via npx or compile from TypeScript. Example MCP server registration (snippet of a larger MCP config):
Local development (TypeScript -> JavaScript):
# Install dependencies
# Compile TypeScript
# Run the built server
You can also run directly with npx (if published) or via a package manager script:
Environment variables
| Variable | Required | Description |
|---|---|---|
| IMAP_HOST | yes | IMAP server hostname (e.g., imap.gmail.com) |
| IMAP_PORT | yes | IMAP server port (e.g., 993 for SSL) |
| IMAP_USERNAME | yes | Username or email address for IMAP login |
| IMAP_PASSWORD | yes | Password or application-specific password / OAuth token |
| IMAP_USE_SSL | yes | true or false — whether to use SSL/TLS for IMAP connection |
Keep credentials out of source control and use secure environment provisioning in production. If using OAuth or tokens, ensure the token is valid for IMAP access and supported by your email provider.
Running the server
- Ensure required environment variables are set.
- Start the server via the CLI or as an MCP subprocess.
- The server listens for MCP tool calls and performs IMAP operations using the provided credentials.
Behavior notes:
- The server attempts to save drafts in common drafts folders (for example “INBOX.Drafts” or “Drafts”) depending on what the IMAP server exposes.
- Errors from the IMAP server are surfaced to the calling assistant/tool consumer as structured responses.
Available Tools
Currently exposed tool:
- create-draft — Creates a draft email and stores it in the IMAP drafts folder.
Parameters (JSON):
| Parameter | Type | Required | Description |
|---|---|---|---|
| to | string | yes | Recipient email address (single address) |
| subject | string | yes | Email subject line |
| body | string | yes | Email body content (plain text or HTML depending on usage) |
| from | string | no | Sender address; defaults to IMAP_USERNAME if omitted |
Example tool call payload:
Example response (success):
If the server cannot find a drafts mailbox, it will attempt common variations and return an error if none are available.
Use Cases
- Assistant-assisted drafting: An AI assistant composes an email for a user and uses create-draft to save it on the user’s IMAP account for later review and sending from a client.
- Workflow automation: Automated processes generate templated messages (e.g., sales follow-ups) and store them as drafts for a human to verify before sending.
- Integration with CRMs or ticketing: When a CRM action requires a human-crafted response, the system can save prepared drafts into the user’s mailbox to ensure traceability and easy editing.
- Safe credential boundaries: Run the MCP server in a controlled environment so the assistant can request email operations without directly handling raw mailbox credentials in the assistant session.
Extending the server
The project is implemented in TypeScript and provides a clear starting point for adding additional IMAP operations (search, move, fetch messages, etc.). Contributing or extending should follow the existing MCP tool pattern: add a new handler, define parameter schema, and map the handler to IMAP client actions.
For code, issues, and contribution guidelines, see the repository: https://github.com/dominik1001/imap-mcp
License
MIT — see the repository for license details.
Common Issues & Solutions
You received an automated notification that your project is listed on Spark and a link to claim the listing. The issue asks you to sign in with GitHub and verify push access to claim, which may be unexpected or require org/admin approval.
I ran into this too! Spark auto-created a listing for one of my repos and opened an issue with a claim URL. I followed the steps: visited the claim link, signed in with GitHub, and authorized only the required OAuth scopes while confirming I had push/admin access to the repo. The claim completed immediately and I could edit metadata and add the "Listed on Spark" badge to the README. If your org restricts OAuth, ask an admin to approve the app or have a repo admin claim it; if anything looks off, don’t grant permissions and contact Spark support.