@marlinjai/email-mcp
Provides tools for managing Gmail accounts, including searching, reading, sending, replying, forwarding, organizing labels, and batch operations via the Gmail REST API.
Provides tools for managing iCloud email accounts via IMAP, including searching, reading, sending, moving, deleting, and marking messages.
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., "@@marlinjai/email-mcpfind unread emails from yesterday in my inbox"
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.
@marlinjai/email-mcp
A unified MCP server for email access across Gmail, Outlook, iCloud, and generic IMAP providers.
Features
Multi-provider support -- Gmail (REST API), Outlook (Microsoft Graph), iCloud (IMAP), and generic IMAP/SMTP
OAuth2 authentication -- Browser-based OAuth flows for Gmail and Outlook, with automatic token refresh
Full email client -- Search, read, send, reply, forward, organize, and manage drafts
Batch operations -- Delete, move, or mark hundreds of emails in a single call
Lightweight search -- Compact search results by default (~20KB vs ~1.4MB) with optional full body retrieval
Encrypted credential storage -- AES-256-GCM encryption at rest with machine-derived keys
Provider-native APIs -- Uses Gmail API and Microsoft Graph where available for richer features, falls back to IMAP for universal compatibility
Related MCP server: @aiwerk/mcp-server-imap
Installation
Install globally from npm:
npm install -g @marlinjai/email-mcpOr run directly with npx (no install needed):
npx @marlinjai/email-mcpQuick Start
Run the interactive setup wizard to add your email accounts:
npx -y -p @marlinjai/email-mcp@latest email-mcp-setupThe
-p/--packageflag is required. This package declares two binaries (email-mcpfor the MCP server,email-mcp-setupfor this wizard). Without-p, npx runs the bin matching the package's own name (email-mcp, the server) and silently passesemail-mcp-setupto it as an ignored argument — the server then sits waiting for MCP protocol input on stdin forever, producing no output at all. It looks exactly like a hang.-ptells npx explicitly which package to resolve and which of its binaries to actually run.
The wizard will walk you through provider selection and authentication. After each account, it asks if you'd like to add another — so you can set up Gmail, Outlook, and iCloud all in one go.
Add the server to your MCP configuration (
.mcp.json):
{
"mcpServers": {
"email": {
"command": "npx",
"args": ["@marlinjai/email-mcp"]
}
}
}Start using email tools in Claude Code — search your inbox, send emails, organize messages, and more.
Provider Setup Guides
Gmail
No configuration needed — the setup wizard handles everything using built-in OAuth credentials (PKCE):
npx -y -p @marlinjai/email-mcp@latest email-mcp-setup
# Select "Gmail" when prompted
# Choose "Full" or "Restricted" permission scope when asked
# A browser window opens for Google authorization
# Grant the requested permissions and return to the terminalThe wizard asks which Gmail permission scope to authorize:
Full (default) — everything below, plus immediate, Trash-bypassing permanent deletion (
https://mail.google.com/, Gmail's maximum-permission scope).Restricted — read, send, label, archive, and move-to-trash (
gmail.modify+gmail.settings.basic), but no permanent deletion. Every tool in this server works identically under Restricted except an explicitpermanent: truedelete, which fails with a Gmail API error instead of succeeding.
Pass --scope full or --scope restricted to skip the prompt, or set EMAIL_MCP_GMAIL_SCOPE=restricted in the environment the wizard runs in.
Note: If you prefer to use your own OAuth app instead of the shared one this package ships with, create a Desktop OAuth 2.0 Client in the Google Cloud Console with the Gmail API enabled, then set
EMAIL_MCP_GMAIL_CLIENT_IDandEMAIL_MCP_GMAIL_CLIENT_SECRETin the environment before running the setup wizard (and in the MCP server's environment, since re-authentication uses the same variables). This gives you your own token lifecycle, independent of the publisher's Cloud project, and sidesteps Google's unverified-app warning and 100-test-user cap for your own account(s) once you add yourself as a test user on your own app.
Outlook
No configuration needed — the setup wizard handles everything using built-in OAuth credentials (PKCE):
npx -y -p @marlinjai/email-mcp@latest email-mcp-setup
# Select "Outlook" when prompted
# A browser window opens for Microsoft authorization
# Sign in and grant the requested permissionsNote: If you prefer to use your own OAuth app, register one in the Azure Portal with
Mail.ReadWrite,Mail.Send,MailboxSettings.ReadWrite(needed foremail_create_block_rule), andoffline_accesspermissions, then setEMAIL_MCP_OUTLOOK_CLIENT_IDin the environment before running the setup wizard.
iCloud
Go to appleid.apple.com and sign in.
Navigate to App-Specific Passwords and generate a new password.
Run the setup wizard:
npx -y -p @marlinjai/email-mcp@latest email-mcp-setup
# Select "iCloud" when prompted
# Enter your iCloud email address
# Enter the app-specific password you generatedGeneric IMAP
Run the setup wizard with your IMAP/SMTP server details:
npx -y -p @marlinjai/email-mcp@latest email-mcp-setup
# Select "Other IMAP" when prompted
# Enter your IMAP host, port, and credentials
# Optionally enter SMTP host and port for sendingAvailable Tools (32)
Account Management (4)
Tool | Description |
| List all configured accounts with connection status |
| Add a new IMAP or iCloud account (Gmail/Outlook require setup wizard) |
| Remove an account and its stored credentials |
| Test connection to an account |
Reading & Searching (6)
Tool | Description |
| List all folders/labels for an account |
| Search emails with filters. Returns compact results by default ( |
| Get full email content by ID (headers, body, attachment metadata) |
| Get an entire email thread/conversation |
| Download a specific attachment by ID (returns base64 data) |
| Download an attachment directly to disk, returning metadata only — avoids the token cost of round-tripping large files as base64. |
Sending & Drafts (6)
Tool | Description |
| Compose and send a new email (to, cc, bcc, subject, body) |
| Reply to an email (supports reply-all, preserves threading) |
| Forward an email to new recipients |
| Save a draft without sending |
| Update an existing draft in place. On Gmail/Outlook the draft id is unchanged; on iCloud/generic IMAP there's no in-place update (IMAP messages are immutable), so the old draft is deleted and a new one appended — the returned id is a new id, always use it going forward |
| List all drafts |
Organization (8)
Tool | Description |
| Move an email to a different folder. Supports |
| Move or copy emails between accounts, preserving the original message (sender, date, threading) via raw MIME transfer. |
| Delete an email (trash or permanent). Supports |
| Mark as read/unread, starred, or flagged. Supports |
| Add/remove labels (Gmail only) |
| Create a new folder |
| List all labels with counts (Gmail only) |
| List all categories (Outlook only) |
Batch Operations (3)
Tool | Description |
| Delete multiple emails at once (up to 1000 for Gmail, batches of 20 for Outlook, UID ranges for IMAP) |
| Move multiple emails to a folder in a single call |
| Mark multiple emails read/unread, starred, or flagged at once |
All batch tools accept a sourceFolder parameter for IMAP/iCloud and include a sequential fallback for maximum compatibility.
Spam Moderation (5)
Tool | Description |
| Report an email as spam/junk, training the provider's own filter — the same signal the "Report Junk" button sends in Gmail/Outlook. This is different from |
| Report multiple emails as spam/junk at once |
| Create a standing rule that intercepts future mail matching a pattern (sender domain/address, subject, or arbitrary header content) and either deletes it or moves it. Use |
| List the standing block rules on an account, for auditing or before deleting one |
| Delete a standing block rule — use to undo a rule that turned out too broad |
Gmail and Outlook only for the rule tools; email_report_spam/email_batch_report_spam work on every provider (iCloud/IMAP fall back to a best-effort move into the account's Junk-typed folder, with no vendor ML training signal since generic IMAP has none to train).
Usage with Claude Code
Add the following to your .mcp.json file (project-level or global ~/.claude/.mcp.json):
{
"mcpServers": {
"email": {
"command": "npx",
"args": ["@marlinjai/email-mcp"]
}
}
}Once configured, you can ask Claude to interact with your email:
"Check my inbox for unread messages"
"Search for emails from alice@example.com in the last week"
"Reply to the latest email from Bob and thank him"
"Move all newsletters to the Archive folder"
"Delete all spam emails" (uses batch operations for speed)
"Draft a follow-up email to the team about the meeting"
Development
# Install dependencies
pnpm install
# Build the project
pnpm build
# Run in development mode (watch for changes)
pnpm dev
# Run tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run integration tests (requires real email accounts)
pnpm test:integrationCredential Storage
Account credentials are encrypted at rest with AES-256-GCM in ~/.email-mcp/credentials.enc.
By default the encryption key is derived from a stable, machine-specific identifier
(the hardware UUID on macOS, /etc/machine-id on Linux, or the MachineGuid on
Windows), falling back to the hostname when none is available.
Set the EMAIL_MCP_KEY environment variable to supply your own passphrase instead.
This is recommended when the machine identifier may change (for example in
containers or CI), or when you want to move credentials.enc between machines:
export EMAIL_MCP_KEY="your-strong-passphrase"When EMAIL_MCP_KEY is set, existing credential files are transparently
re-encrypted with the passphrase the next time they are read.
Support
If this project is useful to you, consider supporting its development:
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
A MCP server for Gmail that lets you search, read, and draft emails and replies.
Email inboxes for AI agents: send, receive, reply, search, and manage threaded email over MCP.
An MCP server that provides email capabilities, hosted on Alpic platform
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA comprehensive MCP server for unified email management that supports both Gmail and IMAP accounts via a single interface. It enables users to search across multiple accounts, list, read, send, and archive emails with integrated health monitoring and secure authentication.1-
- AlicenseBqualityCmaintenanceUniversal IMAP/SMTP MCP server that works with any email provider, providing tools to read, search, send, and manage emails.10103 npm1MIT
- AlicenseAqualityBmaintenanceMCP server that enables email management (send, read, search, delete, etc.) via IMAP/SMTP, compatible with Gmail, Outlook, Yahoo, iCloud, and other standard mail servers.11MIT
- AlicenseNot gradedqualityDmaintenanceA high-fidelity IMAP/SMTP MCP server that enables reading, searching, and sending emails from providers like iCloud and Gmail, handling real-world IMAP quirks automatically.MIT