Mail Agent MCP
Summary: A local-first stdio MCP server that gives an AI agent a controlled Gmail/QQ/generic IMAP–SMTP mailbox interface for search, reading, organization, attachments, and preview-confirmed sending.
Account management: add, update, list, remove, connect, disconnect, and test IMAP accounts (Gmail, QQ Mail, or generic IMAP/SMTP).
Search & read: search by sender/recipient/subject/body/date/read/flagged/custom keywords across one folder or all folders; fetch full bodies as Markdown/text/HTML (bounded), raw headers, latest emails, thread members, and lookup by RFC822 Message-ID.
Organize mail: mark read/unread, flag/unflag, add/remove custom keywords/labels, move messages (single or bulk), create and inspect folders (special-use aware), and count unread per folder.
Delete: guarded single delete, bulk delete by UID, and delete-by-search (requires criteria, supports dryRun).
Attachments: upload files to the attachment root (size/TTL capped) and download attachments confined to a configured directory, with inline images and PDF text extraction.
Drafts & safe sending: save drafts; preview send/reply/forward to freeze a draft, then send once via
imap_confirm_sendwithconfirmed: true.Spam tooling: spam inspection (sender-domain + header/DMARC/SPF/DKIM heuristics), sender-domain stats, delete spam/all-from-domain (dryRun default), and manage spam/whitelist domain lists.
Safety controls: read-only mode and explicit tool allowlists, attachment path confinement, no legacy direct-send handlers registered.
Caveat: the supplied schema exposes only the
imap_-prefixed tools (nogmail_api_*toolset or Gmail API reply/forward previews described in the README), so Gmail HTTPS-only reading is not represented here.
Provides tools for AI agents to search, read, organize, and manage Gmail mailboxes over IMAP, including folders, flags, attachments, drafts, and preview-confirmed sending through SMTP with OAuth 2.0 authentication.
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., "@Mail Agent MCP Search my Gmail for unread emails from my boss and summarize them."
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.
Mail Agent MCP
Mail Agent MCP is a local-first TypeScript stdio MCP server that gives AI agents a controlled Gmail and QQ Mail interface for IMAP search/read/organization, attachments, and preview-confirmed SMTP sending.
Gmail uses OAuth 2.0; QQ Mail uses provider authorization codes. On Windows, provider secrets stay in Windows Credential Manager instead of account JSON.
Release status: v0.1.1 Public Preview / Beta. Install from this GitHub repository; the package is not published to npm or the MCP Registry.
Features
Gmail OAuth 2.0 installed-app enrollment with PKCE, state validation, refresh-token support, and sanitized provider errors.
QQ Mail IMAP/SMTP enrollment with hidden authorization-code input and rollback-safe credential repair.
IMAP search, read, recent mail, folders, flags, keywords, move, guarded delete, drafts, and attachments.
Gmail HTTPS API tools for labels, search, metadata, bounded text/Markdown bodies, and bounded attachment downloads when Gmail IMAP is unavailable.
Preview-confirmed sending, including Gmail API-ID reply/forward previews when Gmail IMAP is unavailable.
Read-only mode and explicit MCP tool allowlists.
Attachment path confinement with a configurable local root.
Local stdio transport; no hosted service and no telemetry in project code.
Related MCP server: Gmail MCP Pro
Supported providers
Provider | Authentication | Receive | Send | Enrollment |
Gmail / Google Workspace | OAuth 2.0 desktop client, PKCE, refresh token | Gmail API read tools or IMAP | SMTP OAuth2; Gmail saves its own Sent copy, so no IMAP append by default | Windows CLI |
QQ Mail | QQ authorization code | IMAP | SMTP | Windows CLI |
Other IMAP/SMTP providers | Legacy password/app-password account path | IMAP | SMTP | Legacy tools/web setup |
The hardened Credential Manager enrollment path is currently Windows-only. Generic-provider compatibility remains available, but its legacy password store is not equivalent to Windows Credential Manager; see Security model.
MCP tools
The server exposes 48 tools in full mode. Existing tools use the imap_ prefix; Gmail HTTPS tools use gmail_api_.
Accounts: imap_add_account, imap_update_account, imap_list_accounts, imap_remove_account, imap_connect, imap_disconnect, imap_test_account.
Read/search: imap_search_emails, imap_get_email, imap_get_latest_emails, imap_find_thread_messages, imap_find_email_by_message_id.
Gmail HTTPS read: gmail_api_list_labels, gmail_api_search_messages, gmail_api_get_message, gmail_api_list_attachments, gmail_api_download_attachment. Gmail API string IDs must never be passed as IMAP UIDs. Message bodies are bounded text or Markdown; attachment downloads are limited to 5 MiB per file and saved only inside the configured root.
Folders and state: imap_list_folders, imap_folder_status, imap_create_folder, imap_get_unread_count, mark/read, flags, keywords, move and guarded delete tools.
Attachments and drafts: imap_upload_file, imap_download_attachment, imap_save_draft.
Safe sending: imap_preview_send_email, imap_preview_reply_to_email, imap_preview_forward_email, gmail_api_preview_reply_to_message, gmail_api_preview_forward_message, imap_confirm_send. The Gmail API previews read by opaque API ID; they do not send and are hidden in read-only mode.
Spam helpers: inspection, domain lists, and explicitly enabled mutation tools.
imap_send_email, imap_reply_to_email, and imap_forward_email are legacy handlers and are never registered. Sending requires a server-side frozen preview and a separate imap_confirm_send call with confirmed: true. See docs/agent-integration.md for a machine-readable contract and read/write boundaries.
Quick start
Requirements: Windows 10/11 and Node.js 22.12 or newer for hardened Gmail/QQ enrollment.
Clone the repository and enter it:
git clone https://github.com/SinoEdwards/mail-agent-mcp.git Set-Location mail-agent-mcpInstall locked dependencies and build:
npm ci npm run buildCheck the enrollment commands:
node dist/enroll.js --helpEnroll at least one provider in an interactive PowerShell terminal:
node dist/enroll.js gmail node dist/enroll.js qqRegister the local build with Codex CLI:
codex mcp add mail-agent -- node "$PWD\dist\index.js" codex mcp list
For read-only discovery:
codex mcp add --env IMAP_MCP_READ_ONLY=true mail-agent-readonly -- node "$PWD\dist\index.js"For other MCP clients, configure a stdio server whose command is node and whose only argument is the absolute path to dist/index.js. Do not copy author-specific paths.
Gmail setup
In Google Cloud Console, create or select a project and enable the Gmail API.
Configure the OAuth consent screen. In Testing mode, add the Gmail address as a test user; Google may reject users who are not listed.
Create an OAuth client of type Desktop app. Copy its client ID and client secret.
Run node dist/enroll.js gmail in an interactive Windows terminal.
Enter the Gmail address, local account name, client ID, and client secret when prompted. The secret prompt is hidden.
Complete the browser consent flow. The callback binds to a random 127.0.0.1 port and the same redirect URI and PKCE verifier are used for token exchange.
The refresh token and client secret are stored under provider/account-bound Windows Credential Manager targets. accounts.json stores only non-secret metadata and target references. Gmail never falls back to password authentication.
Google issues refresh tokens that expire after seven days when an external OAuth app remains in Testing mode and requests Gmail access. Plan to reauthorize with node dist/enroll.js gmail-repair ACCOUNT_ID_OR_NAME during testing. Each installation uses its own Google Cloud OAuth client; making this repository public does not publish or verify that OAuth app. Broader production use of restricted Gmail scopes may require Google's verification process. See Google's refresh-token rules and restricted-scope verification guidance.
Reauthorization: run node dist/enroll.js gmail-repair ACCOUNT_ID_OR_NAME. It obtains a fresh refresh token through browser OAuth, verifies authentication without reading mail, and restores the previous credential if verification fails.
Common failures:
OAuth test user rejected: add the account under OAuth consent-screen test users or publish the app according to Google's rules.
client_secret_required: use the client secret belonging to the same Desktop client ID.
invalid_grant: restart enrollment; authorization codes are single-use and expire.
no refresh token: revoke the app grant if necessary, then rerun consent with offline access.
token refresh fails: verify proxy connectivity, client configuration, and that the grant was not revoked.
Credential Manager failure: run in the same Windows user session and do not paste secrets into command arguments.
QQ Mail setup
Enable IMAP and SMTP in QQ Mail settings.
Generate a QQ Mail authorization code. Do not use the normal QQ password.
Run node dist/enroll.js qq in an interactive Windows terminal.
Enter the address, account name, and hidden authorization code.
Repair an existing credential-backed QQ account:
node dist/enroll.js qq-repairWith multiple QQ accounts, select one by account ID, exact name, or email:
node dist/enroll.js qq-repair ACCOUNT_ID_OR_NAMEReauthorize Gmail through the browser without recreating account metadata:
node dist/enroll.js gmail-repair ACCOUNT_ID_OR_NAMERepair uses the account's exact Credential Manager targets, performs authentication-only verification, and restores the previous credential if verification fails. It does not read mail or test SMTP. Never pipe or pass a QQ authorization code, OAuth code, refresh token, or client secret on the command line.
Generic IMAP/SMTP setup (legacy)
Providers other than Gmail and QQ Mail use the inherited generic account path. From a built clone, start the local setup UI without changing an MCP client configuration:
node dist/setup.js --skip-claude --no-openOpen the localhost URL printed by the command, enter the provider's IMAP/SMTP hosts, ports, TLS settings, username, and provider-issued password or app password, then stop the setup process. The UI binds only to 127.0.0.1: do not expose it through LAN binding, port forwarding, tunnels, or a reverse proxy. It is a local setup aid, not a remote administration panel. The imap_add_account and imap_update_account tools can also configure this path, but doing so sends credentials through the MCP client/model; the local setup UI or startup environment overrides are safer.
This compatibility path does not use Windows Credential Manager. Its password may be AES-encrypted in ~/.imap-mcp/accounts.json with a key stored under the same directory, so an attacker who can read both files can recover it. Gmail and QQ Mail users should use dist/enroll.js instead.
Proxy setup
Gmail authorization opens in the browser; the token endpoint request is made by Node. Configure standard variables before starting enrollment or the MCP server:
$env:HTTPS_PROXY = "http://proxy-host:proxy-port"
$env:HTTP_PROXY = "http://proxy-host:proxy-port"
$env:NO_PROXY = "127.0.0.1,localhost"
$env:IMAP_MCP_MAIL_PROXY = "http://proxy-host:proxy-port"HTTP_PROXY and HTTPS_PROXY are inherited by Gmail OAuth/token requests and, unless IMAP_MCP_MAIL_PROXY is set, by IMAP/SMTP transports launched from the same CLI or MCP process. IMAP_MCP_MAIL_PROXY remains the explicit mail-transport override. NO_PROXY applies to provider hosts and should include the loopback OAuth callback. Do not commit credential-bearing proxy URLs; TLS validation remains enabled.
Configuration reference
Existing process environment values take precedence over values loaded from .env. Provider-bound Gmail/QQ authentication uses Windows Credential Manager; generic password overrides below apply only to legacy accounts. A non-empty IMAP_MCP_ENABLED_TOOLS allowlist takes precedence over IMAP_MCP_READ_ONLY.
Variable | Purpose |
| Comma-separated MCP tool allowlist; names may omit the |
| Truthy values ( |
| Root for uploaded and downloaded attachment files. |
| Optional account-metadata directory override for isolated profiles and clean-room testing; defaults to |
| Maximum decoded attachment upload size in bytes; default 25 MiB. |
| Lifetime of uploaded temporary attachment files; default 24 hours. |
| Gmail OAuth/token/API HTTP proxy settings; lowercase variants are also accepted. |
| Optional explicit HTTP CONNECT, HTTPS, or SOCKS proxy override shared by IMAP and SMTP transports. |
| Per-folder cross-folder-search deadline; defaults to 10000 ms. |
| Overall cross-folder-search deadline, including folder discovery; defaults to 30000 ms. |
| Startup-only generic IMAP credential overrides. |
| Startup-only generic SMTP credential overrides using the same normalized name. |
| Comma-separated local spam and allowlist domain additions. |
| Port for the legacy local setup UI only; default 3000. |
IPQUALITYSCORE_API_KEY is referenced by a legacy internal reputation helper, but no currently registered MCP tool calls that helper. Setting it does not enable an advertised capability.
Security model
Gmail refresh tokens, Gmail client secrets, and QQ authorization codes use Windows Credential Manager on the hardened provider path.
New entries use the MailAgentMCP namespace. Exact legacy CodexLab targets remain readable for compatibility; arbitrary target references are rejected.
Removing a provider-bound account deletes its bound Credential Manager entries transactionally; a persistence failure restores both account metadata and credentials when possible.
accounts.json contains provider/account metadata and credential target references, not those provider secrets.
The connected MCP client and model can receive email bodies returned by read tools. Review that client's data policy.
Sending is preview-confirmed. Within one running server process, each frozen draft permits at most one send attempt; an ambiguous SMTP outcome is not retried automatically. Draft IDs and state are in memory and do not survive a restart. Delete, move, flag, folder, account, spam-mutation, and draft tools still modify state.
Set IMAP_MCP_READ_ONLY=true for a 21-tool mailbox-read-only surface, or IMAP_MCP_ENABLED_TOOLS for an explicit allowlist. This mode is not filesystem-read-only: attachment download tools may save files inside the attachment root.
Attachment paths are confined to IMAP_DOWNLOAD_DIR or, by default, the current user's Downloads/imap-attachments directory.
The legacy generic-provider account path may store an AES-encrypted password in ~/.imap-mcp/accounts.json with a colocated local key. This protects against casual plaintext disclosure, not an attacker who can read both files. Use hardened provider enrollment for Gmail and QQ Mail.
The server does not intentionally write mail bodies to persistent storage, but pending safe-send content remains in process memory and your MCP client may retain tool results.
No claim of complete security is made. A malicious process running as the same OS user can access many of the same local resources.
See SECURITY.md for threat boundaries and responsible disclosure.
Architecture
MCP client
|
| stdio JSON-RPC
v
MCP tool registry
|-- AccountManager + credential resolver
|-- GmailApiService (HTTPS read-only)
|-- ImapService / SmtpService
|-- SafeSendService
|-- attachment-root boundary
v
Gmail API or Gmail/QQ Mail IMAP/SMTPConfiguration metadata lives under ~/.imap-mcp. Provider secrets are resolved into memory only when needed.
Troubleshooting
node or npm fails: confirm node --version is at least 22.12 and use npm ci.
mail-agent-enroll prompts instead of showing help: rebuild with npm run build.
Gmail token endpoint cannot connect: set HTTP_PROXY/HTTPS_PROXY before launching, keep 127.0.0.1 in NO_PROXY, and verify the proxy accepts HTTPS CONNECT.
Gmail or QQ IMAP/SMTP cannot connect while OAuth works: set
IMAP_MCP_MAIL_PROXYto a trusted HTTP CONNECT or SOCKS proxy.Gmail IMAP fails while Gmail API works: use Gmail API tools to read messages and download bounded attachments. Gmail API reply/forward previews can freeze a draft, but sending still requires SMTP and a separate
imap_confirm_sendconfirmation. Gmail SMTP normally places its own Sent copy; the server skips a second IMAP append unlesssaveToSentis explicitly true. API read success is not delivery proof.IMAP From/To/Subject search returns no match even though a recent message exists: the server checks message headers locally for metadata-only searches when the folder has at most 500 messages. Larger folders and body searches still depend on the provider's SEARCH behavior; use a recent-mail listing to cross-check an unexpected empty result.
QQ authentication fails: generate a new authorization code and run qq-repair, adding an account selector when more than one QQ account exists.
Gmail authorization or refresh fails: run gmail-repair for the affected account; the command obtains a fresh refresh token through browser OAuth.
Credential target mismatch: do not edit accounts.json or reuse another account's target. Re-enroll locally.
Attachment path rejected: use a path inside IMAP_DOWNLOAD_DIR.
MCP client sees no tools: run npm run build, use the absolute dist/index.js path, and inspect IMAP_MCP_READ_ONLY or IMAP_MCP_ENABLED_TOOLS.
FAQ
Does this upload my mailbox to a hosted service?
No hosted mail service is part of this repository. The local MCP process connects to the configured provider. Tool results are still sent to your chosen MCP client/model.
Can I use Gmail app passwords?
Not on the hardened Gmail path. It requires OAuth 2.0 and intentionally disables password fallback.
Can an agent send without confirmation?
No through registered production tools. It must preview, receive a draft ID, and call imap_confirm_send with confirmed: true.
Does it support macOS or Linux?
The MCP server and generic IMAP features may run there, but hardened Gmail/QQ enrollment currently requires Windows Credential Manager.
Is the npm package available?
No. Version 0.1.1 is installed from GitHub; npm and MCP Registry publishing remain separate future release decisions.
Roadmap
Cross-platform secure credential backends.
Migrate the legacy generic IMAP/SMTP password store to system credential backends.
Signed releases and provider smoke workflows that never expose real credentials to public CI.
Additional provider adapters only when they add real security or usability value.
Contributing
Read AGENTS.md and CONTRIBUTING.md when present. Keep tool schemas, descriptions, docs, and tests synchronized. Use mocks and localhost fixtures; never put real mailbox credentials in tests or issues.
License
MIT. See LICENSE.
Available Tools
41 toolsimap_add_accountC
Add a new IMAP account configuration
Inputs: host (required), name (required), user (required), password (required), +8 more.
imap_add_keywordA
Set an arbitrary custom (non-system) IMAP keyword/label on an email — e.g. a provider color label like Open-Xchange's $cl_1..$cl_10, Apple Mail's $MailFlagBit0..$MailFlagBit2, or an app tag such as $promotion. Unlike imap_flag_email (which only ever sets the system \Flagged flag), this passes the keyword through verbatim, but rejects backslash-prefixed system flags (e.g. \Flagged, \Seen, \Deleted) — use the dedicated flag/read tools for those. Not every IMAP server permits custom keywords (see the mailbox's PERMANENTFLAGS) — if the server rejects or silently ignores the change, this call fails rather than reporting success.
Inputs: uid (required), keyword (required), folder, accountId, +1 more.
imap_add_spam_domainA
Add a domain to the custom spam list. Emails from this domain will be flagged as spam.
Inputs: domain (required).
imap_add_whitelist_domainA
Add a domain to the whitelist. Emails from whitelisted domains will never be flagged as spam.
Inputs: domain (required).
imap_bulk_deleteB
Delete multiple emails at once with chunking and auto-reconnection. Processes deletions in batches to prevent connection timeouts.
Inputs: uids (required), folder, accountId, chunkSize, +1 more.
imap_bulk_delete_by_searchA
Search for emails matching criteria and delete them all. Useful for cleaning up spam or unwanted emails. At least one concrete criterion (from, to, subject, before, or since) is REQUIRED — a call with no criteria is refused so it can never wipe an entire folder. Supports dryRun to preview matches first.
Inputs: to, from, since, before, +6 more.
imap_check_spamA
Check emails in a folder for spam. Combines sender-domain checks (known spam/disposable domains, suspicious patterns) with deterministic raw-header analysis: bulk-mailer X-Mailer/User-Agent signatures, Precedence: bulk, DMARC/SPF/DKIM failures in Authentication-Results, and List-Unsubscribe / Reply-To domains that do not match the sender. Header checks catch scam mail from fresh, unlisted domains that pass the domain check. Returns domain-based spam, a separate list of header-flagged mails, and domain statistics.
Inputs: accountId (required), from, limit, since, +2 more.
imap_confirm_sendA
Send a previously frozen safe-send draft exactly once.
Inputs: draftId (required), confirmed (required).
imap_connectC
Connect to an IMAP account
Inputs: accountId, accountName.
imap_create_folderA
Create a new IMAP folder/mailbox. Most servers also create any missing parent folders (e.g. creating "Archives/2026/2026-05" auto-creates "Archives" and "Archives/2026"). Returns success even if the folder already exists.
Inputs: folder (required), accountId, accountName.
imap_delete_by_domainB
Delete all emails from a specific domain. Useful for cleaning up unwanted newsletters or spam.
Inputs: domain (required), accountId (required), dryRun, folder.
imap_delete_emailA
Delete ONE email by folder + uid (moves to Trash or expunges, server-dependent). Destructive and not easily undone — confirm the user means this specific message. To remove many at once use imap_bulk_delete (known uids) or imap_bulk_delete_by_search (by criteria, supports dryRun). To file an email away instead of deleting, use imap_move_email.
Inputs: uid (required), folder, accountId, accountName.
imap_delete_spamC
Find and delete emails from known spam/disposable email domains.
Inputs: accountId (required), limit, dryRun, folder, +1 more.
imap_disconnectB
Disconnect from an IMAP account
Inputs: accountId (required).
imap_domain_statsA
Get statistics about sender domains in a folder. Useful for identifying bulk senders or spam patterns.
Inputs: accountId (required), limit, folder, minCount.
imap_download_attachmentA
Download a single attachment from an email (folder + uid + attachment filename/contentId, as listed by imap_get_email). Images are returned inline for viewing; PDFs and other files are saved only inside the configured download directory. Use when the user wants the actual file contents, not just the message body.
Inputs: uid (required), filename (required), folder, savePath, +3 more.
imap_find_email_by_message_idA
Locate an email by its RFC822 Message-ID across folders and return its current { folder, uid } plus basic envelope. Robust to the message having been moved or archived (IMAP UIDs are folder-relative). Pass the returned folder + uid to imap_reply_to_email or imap_get_email. Without folders, searches Gmail \All Mail when present, else INBOX → Archive → Sent → remaining folders.
Inputs: accountId (required), messageId (required), folders.
imap_find_thread_messagesA
Find messages in searchFolder that belong to the same conversation threads as messages already in sourceFolder. Useful for catching replies that arrived after a thread was sorted. Works on any IMAP server (uses RFC 3501 HEADER search on In-Reply-To and References). Set includeBody=true to also return the parsed body for each found thread message in one round-trip — avoids the N+1 cost of calling imap_get_email per thread member.
Inputs: sourceFolder (required), accountId, bodyFormat, accountName, +4 more.
imap_flag_emailA
Flag an email — sets the IMAP \Flagged system flag (shows as a star in Gmail / a flag in Apple Mail). Use this tool when a user asks to star, flag, or mark a message as important.
Inputs: uid (required), folder, accountId, accountName.
imap_folder_statusC
Get status information about a folder
Inputs: folder (required), accountId, accountName.
imap_get_emailA
Read the FULL content of a single email by its UID (body, sender/recipients, date, attachment list, optional raw headers and text-attachment previews). By default the body is returned as clean Markdown in markdownContent and raw HTML is omitted so it never crosses the boundary; set bodyFormat to "html" for the legacy raw htmlContent, or "text" for plain text only. Use after imap_search_emails or imap_get_latest_emails gives you a uid. Body text is truncated to maxContentLength to protect the context window — raise it for long messages. To fetch attachment bytes, use imap_download_attachment.
Inputs: uid (required), folder, accountId, bodyFormat, +5 more.
imap_get_latest_emailsA
Get the most recent emails from a folder, newest first. Use this for "what just came in?" / "show my latest inbox messages" when no search filter is needed. By default returns lightweight headers (uid, from, subject, date); set includeBody=true to also return the parsed body in one round-trip instead of paying the N+1 cost of calling imap_get_email per message. To filter by sender/subject/date instead, use imap_search_emails.
Inputs: count, folder, accountId, bodyFormat, +3 more.
imap_get_unread_countA
Count unread (unseen) emails per folder, plus a total. Use for "how many unread do I have?" overviews. Defaults to all folders; pass a folders list to limit scope and speed it up.
Inputs: folders, accountId, accountName.
imap_list_accountsA
List all configured IMAP accounts
Inputs: no named parameters.
imap_list_foldersA
List all folders/mailboxes for an account (names, hierarchy delimiter, attributes, RFC 6154 special-use role). Use this first to discover exact folder names before searching, moving, or creating subfolders — folder naming varies by provider (e.g. "Archive" vs "[Gmail]/All Mail" vs "INBOX.Archive"). The specialUse field ("\Sent", "\Drafts", "\Trash", "\Junk", "\Archive") identifies a folder's role independent of its localized name (e.g. "Gesendet" is the Sent folder when specialUse is "\Sent").
Inputs: accountId, accountName.
imap_list_spam_domainsA
List all known spam domains (built-in and custom).
Inputs: no named parameters.
imap_mark_as_readA
Mark one or many emails as read. Accepts a single UID or an array — pass an array to flag N messages in one IMAP STORE round-trip (useful when triaging).
Inputs: uid (required), folder, accountId, accountName.
imap_mark_as_unreadA
Mark one or many emails as unread. Accepts a single UID or an array — pass an array to flag N messages in one IMAP STORE round-trip.
Inputs: uid (required), folder, accountId, accountName.
imap_move_emailA
Move an email from one folder to another (e.g., INBOX to Taxes, or INBOX to Archive). Optionally creates the destination folder if it does not exist.
Inputs: uid (required), targetFolder (required), folder, accountId, +2 more.
imap_preview_forward_emailA
Preview and freeze a forward without sending it. Confirm the returned draftId with imap_confirm_send.
Inputs: to (required), uid (required), bcc, body, +5 more.
imap_preview_reply_to_emailA
Preview and freeze a threaded reply without sending it. Confirm the returned draftId with imap_confirm_send.
Inputs: uid (required), bcc, body, html, +6 more.
imap_preview_send_emailA
Preview and freeze a new email without sending it. Confirm the returned draftId with imap_confirm_send.
Inputs: to (required), subject (required), cc, bcc, +7 more.
imap_remove_accountB
Remove an IMAP account configuration
Inputs: accountId (required).
imap_remove_keywordA
Remove an arbitrary custom (non-system) IMAP keyword/label from an email — e.g. a provider color label like Open-Xchange's $cl_1..$cl_10, Apple Mail's $MailFlagBit0..$MailFlagBit2, or an app tag such as $promotion. Unlike imap_unflag_email (which only ever clears the system \Flagged flag), this passes the keyword through verbatim, but rejects backslash-prefixed system flags (e.g. \Flagged, \Seen, \Deleted) — use the dedicated flag/read tools for those. Not every IMAP server permits custom keywords (see the mailbox's PERMANENTFLAGS) — if the server rejects or silently ignores the change, this call fails rather than reporting success.
Inputs: uid (required), keyword (required), folder, accountId, +1 more.
imap_remove_spam_domainA
Remove a domain from the custom spam list.
Inputs: domain (required).
imap_save_draftA
Save an email as a draft in the Drafts folder (no send). Takes the same fields as imap_send_email (including account defaultBcc when configured).
Inputs: cc, to, bcc, body, +10 more.
imap_search_emailsA
Note: on some servers a 'flagged' or starred message carries a custom keyword (e.g. an Open-Xchange color label or Apple's $MailFlagBit*) instead of, or in addition to, the \Flagged system flag. After any flagged search, inspect each result's customKeywords field before concluding a message is or isn't flagged — do not rely on the flagged filter alone. Search for emails matching criteria (sender, recipient, subject, body text, date range, read/flagged status). Use this to FIND messages when you know something about them but not their UID — e.g. "emails from amazon last week", "unread invoices". By default searches a single folder (INBOX). Set searchAllFolders=true to scan every mailbox at once — this catches messages filed away by rules (e.g. a receipt routed to a custom folder); Trash/Spam/Drafts are skipped unless you opt in. By default returns lightweight headers (uid, from, subject, date, and folder when searching across folders); set includeBody=true to also return the parsed body in one round-trip instead of paying the N+1 cost of calling imap_get_email per match. For the newest messages without criteria, prefer imap_get_latest_emails.
Inputs: to, body, from, seen, +18 more.
imap_test_accountA
Test an existing account connection without re-entering credentials. Validates IMAP connectivity and returns folder count and message count.
Inputs: accountId (required).
imap_unflag_emailA
Unflag an email — removes the IMAP \Flagged system flag (the star in Gmail, the flag in Apple Mail). Note: some servers (e.g. Open-Xchange / Network Solutions) and Apple Mail also write a separate custom keyword such as $cl_N or $MailFlagBit* when a message is flagged in their client. Removing \Flagged alone does not clear that keyword, so the message may still display as flagged. If it does, check the message's customKeywords via imap_get_email and remove the lingering label with imap_remove_keyword.
Inputs: uid (required), folder, accountId, accountName.
imap_update_accountA
Update an existing IMAP account. Useful for fixing SMTP settings without removing and re-adding the account.
Inputs: accountId (required), tls, host, name, +12 more.
imap_upload_fileA
Upload a file to the attachment root and return a path for imap_preview_send_email attachments. Preview the message, then use imap_confirm_send only after explicit user confirmation. This avoids putting large attachment bytes in the context window. Max size: 26214400 bytes (configurable via IMAP_MAX_UPLOAD_SIZE). Uploads are auto-deleted after 86400000 ms (configurable via IMAP_UPLOAD_TTL_MS).
Inputs: content (required), filename (required), contentType.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 41 tools
Most tools target a distinct resource and action, with descriptions that cross-reference lookalikes (search vs latest, flag vs keyword, single vs bulk delete). A few clusters such as delete_spam/delete_by_domain/bulk_delete_by_searcch and the preview_send/reply/forward variants could still cause misselection.
The imap_ prefix and generally verb_noun structure help, but conventions are mixed: delete vs remove (delete_email vs remove_keyword), get/find/search for lookup tools, folder_status and doman_stats are noun phrases, and connect/disconnect lack an explicit object.
41 tools is well above the 25+ threshold for a heavy toolset. The broad email domain justifies some sprawl, but the many delete, spam, folder, and flag variants make the surface feel overly large and harder for an agent to navigate efficiently.
Core mail workflows such as search, read, send via preview/confim, delete, move, and flagging are well covered. However, whitelist management has no remove counterpart, folders cannot be renamed or deleted, and there is no copy-email tool, leaving some obvious dead ends.
Maintenance
Related MCP Connectors
Email for AI agents: read, search and send from your Gmail, Outlook, Yahoo, iCloud or IMAP inbox.
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 infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI to send, read, search, delete and reply to emails through SMTP or Gmail API, supporting common email services like QQ, 163, Gmail and Outlook with HTML/text formats and attachments.1ISC
- AlicenseNot gradedqualityNot gradedmaintenanceEnables 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.-
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with email accounts via IMAP and SMTP, supporting mailbox listing, email search, retrieval, sending, and management.MIT
- FlicenseBqualityCmaintenanceEnables AI models to send, receive, search, and manage emails via SMTP/IMAP, including support for attachments, contacts, and advanced search.18-