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.
This server bridges Claude AI with Gmail API, allowing Claude to:
- Send emails and replies
- Search and retrieve emails with advanced filters
- Read email content and attachments
- Work with Gmail categories and labels
By implementing the Model Context Protocol, it gives Claude the ability to perform authenticated Gmail operations while maintaining security and privacy.
gcp-oauth.keys.json
shell
git clone https://github.com/cristip73/MCP-email-server.git
cd MCP-email-server
npm install
shell
npm run build
shell
npm run auth
shell
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.
{
"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.
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
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
supportDEFAULT_ATTACHMENTS_FOLDER
send_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 recipients
- bcc
: Array of BCC recipients
- inReplyTo
: Message ID to reply to
- threadId
: Thread ID to add the message to
reply_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 reply
- excludeRecipients
: Recipients to exclude from the reply
- from
: Specific send-as email address to use as sender (optional)
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 message
- cc
: List of CC recipients
- from
: Specific send-as email address to use as sender (optional)
list_send_as_accounts
List all accounts and email addresses that can be used for sending emails.
Parameters: None
get_recent_emails
Get recent emails with support for time filters, categories, and read status.
Parameters:
- hours
: Number of hours to look back
- maxResults
: Maximum number of results to return (default: 25)
- query
: Additional Gmail search query
- pageToken
: Token for the next page of results
- category
: 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 pagination
read_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 results
- category
: 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 pagination
list_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 label
- 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)
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 message
- removeLabelIds
: Array of label IDs to remove from the message
mark_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 recipients
- bcc
: Array of BCC recipients
- from
: Specific send-as email address to use as sender
get_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 results
- query
: Search filter for drafts
update_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 recipients
- bcc
: New list of BCC recipients
- from
: New specific send-as email address to use as sender
delete_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:
- Configured timezone (from the TIME_ZONE
variable)
- Calculated offset in hours
- Current date and time adjusted to the timezone
- Current date and time in UTC for comparison
list_attachments
List all attachments in an email.
Parameters:
- messageId
: ID of the message for which to list attachments (required)
Returns:
- List of all attachments with their details (name, type, size)
- Count of attachments in the email
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
)
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.