gmail-mcp
Provides email management (list, search, send, mark as read, delete) and label management (create, rename, move, delete, apply) for Gmail accounts using IMAP/SMTP with app password authentication.
Click on "Install 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., "@gmail-mcpShow me my unread emails from yesterday"
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.
Gmail MCP
A Model Context Protocol (MCP) server for Gmail operations using IMAP/SMTP with app password authentication.
Features
Email Management
listMessages: List the last 10 messages (or more if specified)
listUnread: List unread messages (default: last 10)
findMessage: Search for messages containing specific words or phrases (supports folder search:
in:sent,in:trash, etc.)sendMessage: Send emails with HTML formatting and multiple CC/BCC recipients
markAsRead: Mark messages (by ID) as read
deleteMessage: Delete messages (move to Trash)
Label Management
listLabels: List all available labels in your mailbox
createLabel: Create a new label (supports sub-labels like
Parent/Child)renameLabel: Rename an existing label
moveLabel: Move a label to nest it under another parent label
deleteLabel: Delete a label
moveMessage: Move a message to a different label/folder
labelMessage: Apply labels to a message
Related MCP server: Gmail MCP Server
Simple Setup (No OAuth Required!)
1. Gmail App Password Setup
Enable 2-Factor Authentication on your Gmail account
Go to Google Account Settings → Security → App passwords
Generate an App password for "Mail"
Copy the 16-character app password
2. Local Development
Install dependencies:
npm installCreate a
.envfile:EMAIL_ADDRESS=your_email@gmail.com EMAIL_PASSWORD=your_16_char_app_password IMAP_HOST=imap.gmail.com IMAP_PORT=993 SMTP_HOST=smtp.gmail.com SMTP_PORT=587Build and start:
npm run build npm start
3. Docker Usage
Create your
.envfile (as above)Build and run:
npm run docker:build docker run --rm -i --env-file .env gmail-mcp
MCP Client Integration
Simple Docker Configuration
Add this to your MCP client settings:
{
"mcpServers": {
"email": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"--env-file", ".env",
"gmail-mcp"
]
}
}
}Using with Docker Compose
{
"mcpServers": {
"email": {
"command": "docker-compose",
"args": ["run", "--rm", "gmail-mcp"]
}
}
}Supported Email Providers
Gmail (Default)
IMAP:
imap.gmail.com:993(SSL)SMTP:
smtp.gmail.com:587(TLS)Requires: App password (not regular password)
Outlook/Hotmail
Update .env:
IMAP_HOST=outlook.office365.com
SMTP_HOST=smtp-mail.outlook.comOther Providers
Just update the IMAP/SMTP settings in your .env file!
Usage Examples
List Recent Messages
{
"count": 20
}Search Messages
{
"query": "important meeting"
}Send Email
{
"to": "recipient@example.com",
"subject": "Hello from MCP!",
"body": "This email was sent via the Email MCP Server"
}Why IMAP/SMTP vs Gmail API?
✅ IMAP/SMTP Advantages:
Simple app password authentication
Works with any email provider
No OAuth2 complexity
No Google Cloud Console setup
Immediate setup (2 minutes)
❌ Gmail API Disadvantages:
Complex OAuth2 flow
Google Cloud Console configuration
Token management and refresh
Gmail-only (vendor lock-in)
Usage with Claude Desktop
Configuration
Add the MCP server configuration to your Claude Desktop config file:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Add this configuration:
{
"mcpServers": {
"gmail-mcp": {
"command": "node",
"args": ["C:\\path\\to\\your\\Gmail-MCP\\dist\\index.js"],
"cwd": "C:\\path\\to\\your\\Gmail-MCP",
"env": {
"NODE_ENV": "production",
"EMAIL_ADDRESS": "your-email@gmail.com",
"EMAIL_PASSWORD": "your-app-password",
"IMAP_HOST": "imap.gmail.com",
"IMAP_PORT": "993",
"SMTP_HOST": "smtp.gmail.com",
"SMTP_PORT": "587"
}
}
}
}Update the paths and credentials with your actual values
Restart Claude Desktop
Test with commands like:
"List my recent emails"
"Search for emails from john@example.com"
"Send an email to test@example.com with subject 'Test' and message 'Hello!'"
Docker Usage
npm run docker:build
npm run docker:up
# Check logs:
npm run docker:logsTroubleshooting
Authentication Errors
Ensure 2FA is enabled on Gmail
Use App Password, not your regular password
Check that IMAP is enabled in Gmail settings
Connection Issues
Verify IMAP/SMTP settings for your provider
Check firewall/network restrictions
Ensure ports 993 (IMAP) and 587 (SMTP) are open
Docker Issues
Make sure
.envfile exists and is properly formattedBuild the image first:
npm run docker:buildCheck Docker logs:
npm run docker:logs
Usage
The server provides the following tools:
listMessages
Lists recent messages from your Gmail inbox.
Parameters:
count(optional, default: 10, max: 100) - Number of messages to retrieve
Example:
{
"count": 20
}listUnread
Lists unread messages from your Gmail inbox.
Parameters:
count(optional, default: 10, max: 100) - Number of unread messages to retrieve
Example:
{
"count": 15
}findMessage
Searches for messages containing specific words.
Parameters:
query(required) - Search query using Gmail search syntax
Example:
{
"query": "from:example@gmail.com subject:important"
}sendMessage
Sends an email message with support for HTML formatting and multiple recipients.
Parameters:
to(required) - Recipient email addresssubject(required) - Email subjectbody(required) - Plain text message bodyhtml(optional) - HTML version of the email for rich formattingcc(optional) - Single email or array of emails for CCbcc(optional) - Single email or array of emails for BCC
Basic Example:
{
"to": "recipient@example.com",
"subject": "Hello from MCP Server",
"body": "This is a test message sent from the Email MCP Server!"
}HTML Email Example:
{
"to": "recipient@example.com",
"subject": "Welcome!",
"body": "Welcome to our service. This is the plain text version.",
"html": "<h1>Welcome!</h1><p>Welcome to our <strong>service</strong>.</p><p>This is the <em>HTML</em> version.</p>"
}Multiple Recipients Example:
{
"to": "recipient@example.com",
"subject": "Team Update",
"body": "Important team update",
"cc": ["manager@example.com", "colleague@example.com"],
"bcc": ["archive@example.com"]
}Single CC/BCC Example:
{
"to": "recipient@example.com",
"subject": "Quick Note",
"body": "Just a quick note",
"cc": "manager@example.com"
}markAsRead
Marks one or more messages (by UID) as read.
Parameters:
messageIds(required array of message UIDs returned by other tools)
Example:
{
"messageIds": ["12345", "12346"]
}deleteMessage
Deletes one or more messages (by UID) by moving them to the Trash folder.
Parameters:
messageIds(required array of message UIDs returned by other tools)
Example:
{
"messageIds": ["12345", "12346"]
}listLabels
Lists all available labels in your Gmail mailbox.
Parameters: None required
Example:
{}createLabel
Creates a new label in your Gmail mailbox. Supports hierarchical labels using forward slashes (e.g., Parent/Child).
Parameters:
labelName(required) - Name of the label to create. Use/to create nested labels.
Example:
{
"labelName": "Important/Work"
}deleteLabel
Deletes an existing label from your Gmail mailbox.
Parameters:
labelName(required) - Name of the label to delete
Example:
{
"labelName": "OldLabel"
}renameLabel
Renames an existing label in your Gmail mailbox.
Parameters:
oldLabelName(required) - Current name of the labelnewLabelName(required) - New name for the label
Example:
{
"oldLabelName": "testLabel",
"newLabelName": "productionLabel"
}moveLabel
Moves a label to nest it under a parent label, creating a hierarchical structure.
Parameters:
labelName(required) - Name of the label to movenewParentLabel(required) - Name of the parent label to nest under
Example:
{
"labelName": "ProjectA",
"newParentLabel": "Archive"
}This would move ProjectA to become Archive/ProjectA.
moveMessage
Moves a message from one folder/label to another.
Parameters:
messageId(required) - UID of the message to movefolder(required) - Destination folder/label namesourceFolder(optional, default: "INBOX") - Source folder/label name
Example:
{
"messageId": "12345",
"folder": "Archive/2024",
"sourceFolder": "INBOX"
}labelMessage
Applies one or more labels to a message.
Parameters:
messageId(required) - UID of the message to labellabels(required array) - Array of label names to apply
Example:
{
"messageId": "12345",
"labels": ["Important", "Work", "Follow-up"]
}Gmail Search Syntax
The findMessage tool supports Gmail's advanced search syntax:
Basic Search
keyword- Search for keyword in subject or bodyfrom:sender@example.com- Find emails from specific senderto:recipient@example.com- Find emails to specific recipientsubject:keyword- Find emails with keyword in subject
Folder Search (Gmail-style)
in:inbox test- Search for "test" in INBOXin:sent meeting- Search for "meeting" in Sent Mailin:trash important- Search for "important" in Trashin:spam- List messages in Spam folderin:drafts- List messages in Draftsin:starred- List starred messagesin:all- Search in All Mail
Date Filters
is:unread- Find unread emailsafter:2023/01/01- Find emails after specific datebefore:2023/12/31- Find emails before specific date
Important Note About Search Indexing
Gmail's search index may take a few seconds to a few minutes to update after sending or receiving emails. If you search for a recently sent email and don't find it immediately, this is normal behavior. The email was sent successfully, but Gmail's IMAP search index hasn't been updated yet. Try searching again after waiting 30-60 seconds.
Development
Run in development mode:
npm run devWatch for changes:
npm run watchThis server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/MokhtarLahjaily/gmail_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server