Enterprise Mail MCP Server
This server lets you manage, analyze, and automate email through MCP, combining reading, search, security scanning, AI triage, drafting, and calendar/unsubscribe features.
Read & search emails: List inbox, search by sender/subject/date/query, and read full MIME content with attachments.
Organize mailboxes: List folders, move emails, flag/star/read-unread, and delete or trash messages.
Send & reply: Send new emails with HTML/text, CC/BCC, reply with proper threading, or create drafts for review.
Download attachments securely: Automatic Windows Defender/heuristic antivirus scan, quarantine, and SHA-256 verification.
Analyze emails intelligently: Get urgency scores, intent classification, sentiment, action items, financial details, and phishing/security warnings.
Automate inbox triage: Scan recent mail and produce grouped summaries for security, finance, urgent tasks, and newsletters.
Extract calendar events: Generate RFC 5545 .ics invite payloads from meeting emails.
Find unsubscribe links: Detect List-Unsubscribe headers and in-body opt-out links.
Monitor in real time: Use IMAP IDLE to be notified instantly when new emails arrive.
Verify configuration: Test SMTP credentials/connectivity.
Enables the MCP server to connect to Gmail accounts via IMAP/SMTP, allowing AI agents to read, search, organize, send, and reply to emails, manage attachments with antivirus scanning, and perform inbox triage.
Click on "Deploy 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., "@Enterprise Mail MCP Server triage my inbox and summarize urgent emails"
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.
π¬ Enterprise Mail MCP Server
An enterprise-ready, autonomous Model Context Protocol (MCP) server that connects Large Language Model (LLM) agentsβincluding Antigravity IDE, Claude Desktop, and other MCP-compliant clientsβto email accounts via standard IMAP and SMTP protocols.
Equipped with autonomous mailbox triage, thread-aware smart drafting, RFC 5545 calendar event generation, marketing unsubscribe link detection, and a zero-trust multi-layer antivirus engine that scans all attachments before disk persistence.
π Key Capabilities
π‘οΈ Zero-Trust Security, Sanitization & Antivirus Protection
HTML/CSS Zero-Day & PortSwigger Exploit Neutralization: Automatically detects and strips dangerous CSS font exfiltration (
@font-face,unicode-range,descent-override), Label Hijacking (<label for="...">attacking webmail UI buttons), and remote IP tracking (image-set(),@import, remote stylesheets).AI Prompt Injection & Steganography Shield: Detects stealth text hidden via CSS (
opacity: 0,font-size: 0,display: none,::before/::afterpseudo-elements) intended to deceive AI readers, and blocks indirect prompt injection payloads attempting to compromise credentials.Outbound Data Loss Prevention (DLP): Monitors all outgoing messages (
send_email,reply_email) to guarantee environment secrets (e.g.IMAP_PASS,SMTP_PASS, API tokens) can never be exfiltrated via email.Mandatory Antivirus Scanning: Every file attachment requested for download is first isolated in a secure quarantine staging area (
.quarantine/) and scanned by Microsoft Defender Antivirus (MpCmdRun.exe) and heuristic engines.Malware & Double Extension Defense: Detects executable tricks (
.pdf.exe,.docx.scr), script blocks, and standard malware signatures.Instant Destruction on Threat: Any flagged attachment is immediately expunged from storage and blocked with a
VirusThreatDetectedError. Safe files are verified with SHA-256 hashes.
π¬ Complete Mailbox Operations & Organization
Read & Search: List recent emails (
check_inbox), search with multi-criteria filters (search_emails), and inspect complete MIME details (read_email).Folder & Label Management: Enumerate mailboxes (
list_folders), move messages between folders (move_email), star/flag/read-unread (flag_email), and safely trash or delete (delete_email).Attachment Downloader: Verified, secure attachment extraction (
download_attachment).
βοΈ Intelligent Dispatch & Smart Drafts
Direct Send & Reply: RFC 2822-compliant message delivery with HTML, CC, BCC, and thread-aware headers (
In-Reply-To,References).Non-Destructive AI Drafts (
create_draft): Generates proposed emails directly inside the server'sDraftsfolder, allowing human-in-the-loop review before sending.
π§ Semantic Email Intelligence & Triage
Heuristic Analysis (
analyze_email): Computes urgency scores (0β100), extracts action items, classifies intent (BILLING_INVOICE,SECURITY_ALERT,SUPPORT, etc.), detects financial entities, and checks phishing indicators.Autonomous Inbox Triage (
triage_inbox): Scans the latest messages and compiles an executive triage report highlighting critical tasks, pending payments, security events, and newsletters.
π Calendar & Productivity Tools
Meeting Extractor (
extract_calendar_event): Parses dates, times, attendees, and virtual meeting links (Google Meet, Zoom, Microsoft Teams) to generate RFC 5545 standard.icsiCalendar payloads.Unsubscribe Assistant (
find_unsubscribe_links): Extracts RFC 2369List-Unsubscribeheaders (one-click URLs and mailto) along with in-body unsubscribe links.Real-Time Notification (
watch_new_emails): Leverages IMAP IDLE for instant arrival notifications without polling overhead.
Related MCP server: mcp-imap
ποΈ Architecture Overview
ββββββββββββββββββββββββββββββ
β LLM Agent / MCP Client β
β (Antigravity / Claude / AI)β
βββββββββββββββ¬βββββββββββββββ
β JSON-RPC (stdio)
βΌ
ββββββββββββββββββββββββββββββ
β Mail MCP Core Server β
ββββββββ¬βββββββββββββββ¬βββββββ
β β
βββββββββββββββββββββββ΄ββββ ββββββ΄βββββββββββββββββββββ
β IMAP / SMTP Services β β Security & Intelligence β
β (ImapFlow & Nodemailer) β β (Analyzer & Antivirus) β
βββββββββββββββ¬ββββββββββββ ββββββ¬βββββββββββββββββββββ
β β
ββββββββββββββββββ΄ββββββββββββββββ βββΊ Microsoft Defender (MpCmdRun)
β Mail Providers (TLS / SSL) β βββΊ Double-Extension Defense
β β’ Gmail β βββΊ EICAR & Heuristic Checks
β β’ Microsoft Outlook / 365 β βββΊ Quarantine Staging Area
β β’ Custom IMAP/SMTP Servers β βββΊ SHA-256 Hash Verification
ββββββββββββββββββββββββββββββββββπ οΈ Tool Catalog Reference
Tool Name | Scope | Description |
| Reading | Retrieves recent message headers with pagination and unread filtering. |
| Reading | Searches emails by query, sender, recipient, subject, body, or dates. |
| Reading | Fetches and parses complete MIME email details (HTML, text, headers, attachments). |
| Organization | Lists all account mailboxes, special-use flags, and paths. |
| Organization | Moves an email by UID to a destination folder or label. |
| Organization | Adds, removes, or sets IMAP flags ( |
| Organization | Moves message to Trash or permanently purges it. |
| Attachments | Scans with Windows Defender and saves verified attachments to disk. |
| Dispatch | Sends a new email via SMTP with HTML/Text support. |
| Dispatch | Replies to an existing thread maintaining message references. |
| Dispatch | Saves an email draft to the |
| Diagnostic | Validates SMTP server credentials and connectivity. |
| Intelligence | Computes urgency, intent, sentiment, action items, and security warnings. |
| Intelligence | Audits recent inbox activity into grouped actionable categories. |
| Calendar | Converts meeting text/dates/links into standard |
| Unsubscribe | Identifies |
| Monitoring | Holds an IMAP IDLE connection to wait for incoming mail. |
| Management | Checks and syncs with latest GitHub master security patches and releases. |
π Getting Started
1. Prerequisites
Node.js:
v20.0.0or higherPackage Manager:
npm(v9+)An active email account supporting IMAP/SMTP (e.g. Gmail, Outlook, Yahoo, or private webmail)
2. Installation
git clone https://github.com/yusuf-polat/mail-mcp.git
cd mail-mcp
npm install3. Environment Configuration
Copy the provided .env.example file to .env:
cp .env.example .envEdit .env with your email account configuration:
# --- IMAP Configuration (Reading & Real-Time Monitoring) ---
IMAP_HOST=imap.gmail.com
IMAP_PORT=993
IMAP_SECURE=true
IMAP_USER=your_email@example.com
IMAP_PASS=your_16_digit_app_password
# --- SMTP Configuration (Sending & Replying) ---
SMTP_HOST=smtp.gmail.com
SMTP_PORT=465
SMTP_SECURE=true
SMTP_USER=your_email@example.com
SMTP_PASS=your_16_digit_app_password
# --- Sender Info ---
SMTP_FROM_NAME="AI Mail Assistant"
# SMTP_FROM_ADDRESS=your_email@example.com
# --- Debug Mode ---
DEBUG=falseGmail Users: Do not use your personal password. Enable 2-Step Verification on your Google Account, generate a 16-character App Password, and verify that IMAP Access is enabled.
4. Build
Compile TypeScript to production-ready JavaScript in dist/:
npm run build5. Verification Test
Validate that the services, MIME parsers, and heuristic analyzer initialize properly:
npx tsx test/smoke.test.tsπ MCP Client Integration
Antigravity IDE
Add the server definition to %USERPROFILE%\.gemini\config\mcp_config.json (Windows) or ~/.gemini/config/mcp_config.json (macOS / Linux):
{
"mcpServers": {
"mail": {
"command": "node",
"args": [
"C:\\path\\to\\mail-mcp\\dist\\index.js"
]
}
}
}Claude Desktop
Add the server definition to your claude_desktop_config.json:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"mail": {
"command": "node",
"args": [
"/absolute/path/to/mail-mcp/dist/index.js"
]
}
}
}π Security and Privacy Best Practices
Strict Secrets Isolation: The
.envfile is excluded via.gitignore. Never commit credentials, tokens, or app passwords to version control.Read-Only Option: If sending or message deletion capabilities are not required in your environment, permissions can be restricted at the mail provider level.
Quarantine Execution: Downloaded attachments are placed in
.quarantine/and scanned prior to delivery.Draft-First Workflows: For critical correspondence, use
create_draftinstead ofsend_emailto maintain human review.
π License
This project is licensed under the MIT License.
Available Tools
17 toolsanalyze_emailA
Bir e-postanΔ±n iΓ§eriΔini derinlemesine analiz eder: aciliyet derecesi, niyet/kategori, ton/duygu, aksiyon maddeleri, tarihler, para tutarlarΔ±, ΓΆzet ve phishing/spam riskleri.
Inputs: uid, folder, subject, bodyText.
check_inboxB
Gelen kutusundaki (veya belirtilen klasΓΆrdeki) en son e-postalarΔ± ΓΆzet bilgilerle listeler.
Inputs: limit, folder, unreadOnly.
create_draftA
E-postayΔ± hemen gΓΆndermez; Taslaklar (Drafts) klasΓΆrΓΌne yapay zeka tarafΔ±ndan oluΕturulmuΕ bir taslak olarak kaydeder.
Inputs: subject (required), bodyText (required), cc, to, +3 more.
delete_emailB
E-postayΔ± Γ§ΓΆp kutusuna taΕΔ±r veya kalΔ±cΔ± olarak siler.
Inputs: uid (required), folder, permanent.
download_attachmentA
Belirtilen e-postadaki eki indirir. GΓVENLΔ°K ZORUNLULUΔU: Dosya kesinlikle indirilmeden ΓΆnce Windows Defender ve Γ§ok katmanlΔ± sezgisel virΓΌs taramasΔ±ndan geΓ§irilir. Tehdit bulunursa dosya derhal imha edilir ve indirme iptal edilir.
Inputs: uid (required), attachmentIdentifier (required), folder, targetDir.
extract_calendar_eventB
E-postadaki toplantΔ±, randevu ve etkinlik bilgilerini (tarih, saat, link, katΔ±lΔ±mcΔ±lar) Γ§Δ±karΔ±r ve standart .ics (iCalendar) formatΔ± ΓΌretir.
Inputs: uid, folder, subject, bodyText.
find_unsubscribe_linksA
BΓΌlten ve tanΔ±tΔ±m e-postalarΔ±ndaki abonelikten Γ§Δ±kma (List-Unsubscribe baΕlΔ±klarΔ± veya gΓΆvdedeki iptal baΔlantΔ±larΔ±) yollarΔ±nΔ± tespit eder.
Inputs: uid (required), folder.
flag_emailA
E-postaya bayrak ekler, kaldΔ±rΔ±r veya gΓΌnceller (ΓΆrn: yΔ±ldΔ±zlama '\Flagged', okundu '\Seen').
Inputs: uid (required), flags (required), action, folder.
list_foldersB
Posta kutusundaki tΓΌm klasΓΆrleri, etiketleri ve ΓΆzel kullanΔ±m yollarΔ±nΔ± listeler.
Inputs: no named parameters.
move_emailB
Belirtilen e-postayΔ± (UID) hedef klasΓΆre veya etikete taΕΔ±r.
Inputs: uid (required), destinationFolder (required), sourceFolder.
read_emailC
UID numarasΔ± verilen belirli bir e-postayΔ± gΓΆvdesi, ek bilgileri ve baΕlΔ±klarΔ±yla eksiksiz okur.
Inputs: uid (required), folder, markAsSeen.
reply_emailA
Gelen bir e-postaya RFC standartlarΔ±na uygun baΕlΔ±klar (In-Reply-To, References, Re:) ve orijinal alΔ±ntΔ±yla yanΔ±t verir.
Inputs: bodyText (required), originalUid (required), folder, bodyHtml, +1 more.
search_emailsC
GeliΕmiΕ arama kriterleri ile e-postalarΔ± arar (gΓΆnderen, konu, gΓΆvde, tarih, okunmamΔ±ΕlΔ±k vb.).
Inputs: to, from, limit, query, +5 more.
send_emailC
Belirtilen alΔ±cΔ±(lar)a yeni bir e-posta gΓΆnderir.
Inputs: to (required), subject (required), bodyText (required), cc, +3 more.
triage_inboxA
Gelen kutusundaki son e-postalarΔ± topluca tarar, ΓΆnem derecesine gΓΆre gruplar (GΓΌvenlik, Finans, Acil GΓΆrevler, BΓΌltenler) ve eyleme dΓΆnΓΌΕtΓΌrΓΌlebilir ΓΆzet rapor sunar.
Inputs: limit, folder.
verify_smtp_connectionA
SMTP sunucu yapΔ±landΔ±rmasΔ±nΔ± ve baΔlantΔ±sΔ±nΔ± test eder.
Inputs: no named parameters.
watch_new_emailsB
IMAP IDLE protokolΓΌnΓΌ kullanarak gelen kutusunu anlΔ±k olarak dinler. Yeni bir e-posta dΓΌΕtΓΌΔΓΌ anda veya zaman aΕΔ±mΔ± sΓΌresi dolduΔunda sonucu dΓΆner.
Inputs: folder, timeoutSeconds.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 17 tools
Each tool has a clearly distinct purpose: listing, searching, reading, sending, replying, drafting, real-time watching, analyzing, triaging, folders, moving, flagging, deleting, attachments, and calendar extraction do not meaningfully overlap. Even similarly scoped tools like check_inbox, search_emails, and triage_inbox are differentiated by intent and output.
All tool names follow a consistent snake_case verb_noun pattern such as check_inbox, send_email, move_email, and delete_email. This makes the API predictable and easy to navigate for an agent.
At 17 tools, the server is slightly above the ideal 3-15 range but every tool appears to serve a legitimate mail-related function. The count is reasonable for a broad enterprise mail feature set and does not feel bloated.
The tool surface covers core email workflows: send, reply, draft, read, search, delete, move, flag, attachment download, folder listing, and real-time monitoring. Minor gaps exist, such as no explicit forward_email tool, no folder creation/management, and no clearly described attachment support when sending or creating drafts.
Related MCP Connectors
Email inboxes and calendars for AI agents: send, receive, search, draft and schedule.
Email inboxes and calendars for AI agents: send, receive, search, draft and schedule.
Email for AI agents: read, search and send from your Gmail, Outlook, Yahoo, iCloud or IMAP inbox.
Email infrastructure for AI agents β send, receive, search, and reply to email over MCP.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables 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.10206 npm11MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with email accounts via IMAP and SMTP, supporting mailbox listing, email search, retrieval, sending, and management.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to read, send, organize, and search emails across multiple IMAP/SMTP mailboxes.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to read, search, send, and manage emails via IMAP/SMTP with OAuth 2.1 authentication, supporting folders, drafts, replies, and forwarding.1MIT