Gmail MCP

Gmail MCP

Enables comprehensive Gmail management through the Gmail API, including sending/receiving emails, organizing labels and threads, managing drafts, and configuring account settings with secure OAuth2 authentication.

Category
访问服务器

README

Gmail MCP

npm version smithery badge

<p align="center"><img height="512" src=https://github.com/user-attachments/assets/b61db02e-bde4-4386-b5a9-2b1c6a989925></p>

A Model Context Protocol (MCP) implementation for the Gmail API, providing a standardized interface for email management, sending, and retrieval.

Features

  • Complete Gmail API coverage including messages, threads, labels, drafts, and settings
  • Support for sending, drafting, and managing emails
  • Label management with customizable colors and visibility settings
  • Thread operations for conversation management
  • Settings management including vacation responder, IMAP/POP, and language settings
  • History tracking for mailbox changes
  • Secure OAuth2 authentication using Google Cloud credentials

Prerequisites

To run this MCP server, you first need to set up a Google API Client for your organization, with each user running a script to retrieve their own OAuth refresh token.

Google API Client Setup (once per organization)

  1. Go to the Google Cloud Console.
  2. Create a new project or select an existing one.
  3. Enable the Gmail API for your project.
  4. Go to Credentials and create an OAuth 2.0 Client ID. Choose "Desktop app" for the client type.
  5. Download and save the OAuth keys JSON as ~/.gmail-mcp/gcp-oauth.keys.json. ⚠️ NOTE: to create ~/.gmail-mcp/ through MacOS's Finder app you need to enable hidden files first.
  6. (Optional) For remote server installation (ex. using Smithery CLI), note the CLIENT_ID and CLIENT_SECRET from this file.

Client OAuth (once per user)

  1. Have the user copy ~/.gmail-mcp/gcp-oauth.keys.json to their computer at the same path.
  2. Run npx @shinzolabs/gmail-mcp auth.
  3. A browser window will open where the user may select a profile, review the requested scopes, and approve.
  4. (Optional) For remote server installation, note the file path mentioned in the success message (~/.gmail-mcp/credentials.json by default). The user's REFRESH_TOKEN will be found here.

Client Configuration

There are several options to configure your MCP client with the server. For hosted/remote server setup, use Smithery's CLI with a Smithery API Key. For local installation, use npx or build from source. Each of these options is explained below.

Smithery Remote Server (Recommended)

To add a remote server to your MCP client config.json, run the following command from Smithery CLI:

npx -y @smithery/cli install @shinzo-labs/gmail-mcp

Enter your CLIENT_ID, CLIENT_SECRET, and REFRESH_TOKEN when prompted.

Smithery SDK

If you are developing your own agent application, you can use the boilerplate code here.

NPX Local Install

To install the server locally with npx, add the following to your MCP client config.json:

{
  "mcpServers": {
    "gmail": {
      "command": "npx",
      "args": [
        "@shinzolabs/gmail-mcp"
      ]
    }
  }
}

Build from Source

  1. Download the repo:
git clone https://github.com/shinzo-labs/gmail-mcp.git
  1. Install packages and build with pnpm (inside cloned repo):
pnpm i && pnpm build
  1. Add the following to your MCP client config.json:
{
  "mcpServers": {
    "gmail": {
      "command": "node",
      "args": [
        "/path/to/gmail-mcp/dist/index.js"
      ]
    }
  }
}

Config Variables

Variable Description Required? Default
AUTH_SERVER_PORT Port for the temporary OAuth authentication server No 3000
CLIENT_ID Google API client ID (found in GMAIL_OAUTH_PATH) Yes if remote server connection ''
CLIENT_SECRET Google API client secret (found in GMAIL_OAUTH_PATH) Yes if remote server connection ''
GMAIL_CREDENTIALS_PATH Path to the user credentials file No MCP_CONFIG_DIR/credentials.json
GMAIL_OAUTH_PATH Path to the Google API Client file No MCP_CONFIG_DIR/gcp-oauth.keys.json
MCP_CONFIG_DIR Directory for storing configuration files No ~/.gmail-mcp
REFRESH_TOKEN OAuth refresh token (found in GMAIL_CREDENTIALS_PATH) Yes if remote server connection ''
PORT Port for Streamable HTTP transport method No 3000

Supported Endpoints

User Management

  • get_profile: Get the current user's Gmail profile
  • stop_mail_watch: Stop receiving push notifications
  • watch_mailbox: Set up push notifications for mailbox changes

Message Management

Managing Messages

  • list_messages: List messages with optional filtering
  • get_message: Get a specific message
  • get_attachment: Get a message attachment
  • modify_message: Modify message labels
  • send_message: Send an email message to specified recipients
  • delete_message: Permanently delete a message
  • trash_message: Move message to trash
  • untrash_message: Remove message from trash
  • batch_modify_messages: Modify multiple messages
  • batch_delete_messages: Delete multiple messages

Label Management

  • list_labels: List all labels
  • get_label: Get a specific label
  • create_label: Create a new label
  • update_label: Update a label
  • patch_label: Partial update of a label
  • delete_label: Delete a label

Thread Management

  • list_threads: List email threads
  • get_thread: Get a specific thread
  • modify_thread: Modify thread labels
  • trash_thread: Move thread to trash
  • untrash_thread: Remove thread from trash
  • delete_thread: Delete a thread

Draft Management

  • list_drafts: List drafts in the user's mailbox
  • get_draft: Get a specific draft by ID
  • create_draft: Create a draft email in Gmail
  • update_draft: Replace a draft's content
  • delete_draft: Delete a draft
  • send_draft: Send an existing draft

Settings Management

Auto-Forwarding

  • get_auto_forwarding: Get auto-forwarding settings
  • update_auto_forwarding: Update auto-forwarding settings

IMAP Settings

  • get_imap: Get IMAP settings
  • update_imap: Update IMAP settings

POP Settings

  • get_pop: Get POP settings
  • update_pop: Update POP settings

Vacation Responder

  • get_vacation: Get vacation responder settings
  • update_vacation: Update vacation responder

Language Settings

  • get_language: Get language settings
  • update_language: Update language settings

Delegates

  • list_delegates: List account delegates
  • get_delegate: Get a specific delegate
  • add_delegate: Add a delegate
  • remove_delegate: Remove a delegate

Filters

  • list_filters: List email filters
  • get_filter: Get a specific filter
  • create_filter: Create a new filter
  • delete_filter: Delete a filter

Forwarding Addresses

  • list_forwarding_addresses: List forwarding addresses
  • get_forwarding_address: Get a specific forwarding address
  • create_forwarding_address: Create a forwarding address
  • delete_forwarding_address: Delete a forwarding address

Send-As Settings

  • list_send_as: List send-as aliases
  • get_send_as: Get a specific send-as alias
  • create_send_as: Create a send-as alias
  • update_send_as: Update a send-as alias
  • patch_send_as: Partial update of a send-as alias
  • verify_send_as: Send verification email
  • delete_send_as: Delete a send-as alias

S/MIME Settings

  • list_smime_info: List S/MIME configurations
  • get_smime_info: Get a specific S/MIME config
  • insert_smime_info: Upload a new S/MIME config
  • set_default_smime_info: Set default S/MIME config
  • delete_smime_info: Delete an S/MIME config

Contributing

Contributions are welcomed and encouraged! Please read CONTRIBUTING.md for guidelines on issues, contributions, and contact information.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选