A Model Context Protocol (MCP) server that enables Claude Desktop App (or any other app that supports MCP) to interact with Gmail, providing capabilities for reading, searching, and sending emails through a standardized interface.
Create a Google Cloud Project and enable the Gmail API:
gcp-oauth.keys.json
Clone and Install:
git clone https://github.com/cristip73/MCP-email-server.git
cd MCP-email-server
npm install
Build the Server:
npm run build
Authenticate with Gmail:
npm run auth
This will open a browser window to authenticate with your Google account.
Make Package available to Claude:
npm link
Add the MCP server to Claude Desktop:
Go into Claude Desktop settings then go into Developer Mode then choose Edit Config and edit the JSON file
If you have multiple MCPs be careful with you syntax. You should add them under "mcpServers" not copy the whole section below. Ask AI for help if you are unsure.
{
"mcpServers": {
"email-server": {
"command": "node",
"args": ["/path/to/email-server/build/index.js"],
"env": {
"TIME_ZONE": "GMT+2",
"DEFAULT_ATTACHMENTS_FOLDER": "/Users/username/CLAUDE/Attachments"
}
}
}
}
IMPORTANT: Set the DEFAULT_ATTACHMENTS_FOLDER to a valid path on your system.
IMPORTANT: Set the TIME_ZONE to your local timezone in GMT format. Eg: GMT+2, GMT-5, etc. Otherwise the date and time of the emails will be off, it is set to GMT+0 by default by Gmail.
The server will work also without any TIME_ZONE or DEFAULT_ATTACHMENTS_FOLDER, but your timezone will be off and you will not be able to save attachments.
For Claude Code Editor, you can add the server by running the following command:
claude mcp add email-server -- /path/to/email-server/build/index.js
This server bridges Claude AI with Gmail API, allowing Claude to:
By implementing the Model Context Protocol, it gives Claude the ability to perform authenticated Gmail operations while maintaining security and privacy.
src/
├── index.ts # Entry point and server initialization
├── server.ts # MCP server implementation
├── client-wrapper.ts # Gmail API client wrapper with multi-account support
├── tool-handler.ts # Tool registration and request routing
├── prompt-handler.ts # Prompt management and template system
├── version.ts # Version information
├── utils.ts # Shared utilities for dates, emails, etc.
├── timezone-utils.ts # Timezone handling and configuration
└── tools/ # Tool implementations by domain
├── email-read-tools.ts # Tools for reading emails
├── email-send-tools.ts # Tools for sending, replying and forwarding emails
├── email-search-tools.ts # Tools for searching and filtering emails
├── email-label-tools.ts # Tools for managing labels and message states
├── email-attachment-tools.ts # Tools for listing and saving attachments
├── email-draft-tools.ts # Tools for managing email drafts
└── timezone-tool.ts # Tool for verifying timezone configuration
The server supports the following configuration:
TIME_ZONE
: Timezone configuration in format like 'GMT+2' or 'GMT-5' (default: 'GMT+0')DEFAULT_ATTACHMENTS_FOLDER
: Path to the directory where email attachments can be saved (e.g., '/Users/username/CLAUDE/attachments')pageToken
supportsend_email
Send a new email message.
Parameters:
to
: Array of recipient email addresses (required)subject
: Email subject (required)body
: Email body content (required)cc
: Array of CC recipientsbcc
: Array of BCC recipientsinReplyTo
: Message ID to reply tothreadId
: Thread ID to add the message toreply_all_email
Reply to an email and include all original recipients (TO and CC).
Parameters:
messageId
: ID of the message to reply to (required)body
: Email body content (required)additionalRecipients
: Additional recipients to include in the replyexcludeRecipients
: Recipients to exclude from the replyfrom
: Specific send-as email address to use as sender (optional)The tool automatically handles:
forward_email
Forward an email to other recipients.
Parameters:
messageId
: ID of the message to forward (required)to
: List of recipients to forward the email to (required)additionalContent
: Additional content to add before the forwarded messagecc
: List of CC recipientsfrom
: Specific send-as email address to use as sender (optional)The tool automatically handles:
list_send_as_accounts
List all accounts and email addresses that can be used for sending emails.
Parameters: None
Returns:
get_recent_emails
Get recent emails with support for time filters, categories, and read status.
Parameters:
hours
: Number of hours to look backmaxResults
: Maximum number of results to return (default: 25)query
: Additional Gmail search querypageToken
: Token for the next page of resultscategory
: Filter by Gmail category (primary, social, promotions, updates, forums)timeFilter
: Predefined time filter (today, yesterday, last24h)autoFetchAll
: Automatically fetch all results (up to 100) without requiring paginationread_email
Read a specific email by ID and extract its content.
Parameters:
messageId
: ID of the email message to retrieve (required)search_emails
Search for emails using Gmail query syntax with support for categories and time filters.
Parameters:
query
: Gmail search query (required)maxResults
: Maximum number of results to return (default: 25)pageToken
: Token for the next page of resultscategory
: Filter by Gmail category (primary, social, promotions, updates, forums)timeFilter
: Predefined time filter (today, yesterday, last24h)autoFetchAll
: Automatically fetch all results (up to 100) without requiring paginationlist_labels
List all labels in the user's mailbox.
Parameters: None
get_label
Get details about a specific label.
Parameters:
labelId
: ID of the label to retrieve (required)create_label
Create a new label in the user's mailbox.
Parameters:
name
: Name of the label to create (required)messageListVisibility
: Controls the label's visibility in the message list (show
or hide
)labelListVisibility
: Controls the label's visibility in the label list (labelShow
, labelShowIfUnread
, or labelHide
)textColor
: Text color in hex format (e.g., #000000)backgroundColor
: Background color in hex format (e.g., #ffffff)update_label
Update an existing label.
Parameters:
labelId
: ID of the label to update (required)name
: New name for the labelmessageListVisibility
: Controls the label's visibility in the message list (show
or hide
)labelListVisibility
: Controls the label's visibility in the label list (labelShow
, labelShowIfUnread
, or labelHide
)textColor
: Text color in hex format (e.g., #000000)backgroundColor
: Background color in hex format (e.g., #ffffff)delete_label
Delete a label from the user's mailbox.
Parameters:
labelId
: ID of the label to delete (required)modify_labels
Add or remove labels from a message.
Parameters:
messageId
: ID of the message to modify (required)addLabelIds
: Array of label IDs to add to the messageremoveLabelIds
: Array of label IDs to remove from the messagemark_as_read
Mark a message as read.
Parameters:
messageId
: ID of the message to mark as read (required)mark_as_unread
Mark a message as unread.
Parameters:
messageId
: ID of the message to mark as unread (required)archive_message
Archive a message (remove from inbox).
Parameters:
messageId
: ID of the message to archive (required)unarchive_message
Move a message back to inbox.
Parameters:
messageId
: ID of the message to move to inbox (required)trash_message
Move a message to trash.
Parameters:
messageId
: ID of the message to move to trash (required)create_draft
Create a new draft email without sending it.
Parameters:
to
: Array of recipient email addresses (required)subject
: Email subject (required)body
: Email body content (required)cc
: Array of CC recipientsbcc
: Array of BCC recipientsfrom
: Specific send-as email address to use as senderget_draft
Retrieve the contents of a specific draft.
Parameters:
draftId
: ID of the draft to retrieve (required)list_drafts
List all drafts in the email account.
Parameters:
maxResults
: Maximum number of drafts to return (default: 20)pageToken
: Token for the next page of resultsquery
: Search filter for draftsupdate_draft
Update the content of an existing draft.
Parameters:
draftId
: ID of the draft to update (required)to
: New list of recipient email addresses (required)subject
: New email subject (required)body
: New email body content (required)cc
: New list of CC recipientsbcc
: New list of BCC recipientsfrom
: New specific send-as email address to use as senderdelete_draft
Permanently delete a draft.
Parameters:
draftId
: ID of the draft to delete (required)send_draft
Send an existing draft.
Parameters:
draftId
: ID of the draft to send (required)get_timezone_info
Display information about the configured timezone in the system.
Parameters: None
Returns:
list_attachments
List all attachments in an email.
Parameters:
messageId
: ID of the message for which to list attachments (required)Returns:
save_attachment
Save an attachment from an email to the configured DEFAULT_ATTACHMENTS_FOLDER.
Parameters:
messageId
: ID of the message containing the attachment (required)attachmentId
: ID of the attachment (optional if the message has only one attachment)targetPath
: Filename or relative path where the attachment will be saved (will be saved inside the DEFAULT_ATTACHMENTS_FOLDER)The tool automatically:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Seamless access to top MCP servers powering the future of AI integration.