Skip to main content
Glama
Steph-ux

gmail-mcp

by Steph-ux

gmail-mcp v1.0.0

用于 Gmail 的统一多账户 Google OAuth2 MCP 服务器。 跨多个 Google 账户无缝搜索、读取、撰写、发送、创建草稿和整理邮件。

功能(4 个统一工具)

  • gmail_search:使用官方 Gmail 搜索语法检索邮件(is:unreadfrom:boss@corp.comsubject:invoicenewer_than:2dhas:attachment

  • gmail_read:读取完整的邮件内容和元数据(主题、发件、正文文本、HTML、抄送、密送、标签、附件列表)

  • gmail_send:发送邮件或创建草稿(支持 HTML、抄送、密送、线程回复和文件附件)

  • gmail_manage:标签管理、归档、垃圾邮件处理、已读/未读切换、永久删除以及多账户清单

Related MCP server: Moist

多账户架构

单个 Google Cloud OAuth 客户端(credentials.json)即可认证多个 Gmail 账户。 令牌按账户存储在 ~/.secrets/gmail/tokens/<account_name>.json 中。

1. 设置 Google OAuth 凭据(一次性)

  1. Google Cloud Console 中创建项目。

  2. 启用 Gmail API

  3. 创建 OAuth 2.0 客户端 ID(桌面应用)。

  4. 下载客户端密钥 JSON 文件,并将其保存为 ~/.secrets/gmail/credentials.json(或设置 GMAIL_CREDENTIALS_JSON)。

2. 认证账户

为每个账户运行交互式授权 CLI:

gmail-auth default    # Authenticates primary account
gmail-auth work       # Authenticates secondary work account
gmail-auth client_x   # Authenticates any additional account

列出所有已认证的账户:

gmail-auth --list

在 MCP 客户端中安装(Claude Desktop、OpenCode、Cursor、Windsurf)

选项 1:通过 uvx 即时安装(推荐)

{
  "mcpServers": {
    "gmail": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/Steph-ux/gmail-mcp.git", "gmail-mcp"]
    }
  }
}

选项 2:通过 pip install 安装

pip install git+https://github.com/Steph-ux/gmail-mcp.git

然后在你的 MCP 配置中:

{
  "mcpServers": {
    "gmail": {
      "command": "gmail-mcp"
    }
  }
}

选项 3:本地克隆(开发)

{
  "mcpServers": {
    "gmail": {
      "command": "python",
      "args": ["D:\\Steph\\script\\gmail-mcp\\server.py"]
    }
  }
}

使用示例

1. 搜索邮件

# Search in default account:
gmail_search(query='is:unread from:github')

# Search in work account:
gmail_search(account='work', query='subject:invoice newer_than:7d')

2. 读取邮件

gmail_read(account='work', message_id='18f2a9b4c10d')

3. 发送邮件或创建草稿

# Send direct email:
gmail_send(
    account='default',
    to='colleague@example.com',
    subject='Project Update',
    body_text='Here is the latest status...',
    body_html='<h1>Project Update</h1><p>Here is the latest status...</p>'
)

# Create a draft:
gmail_send(
    account='work',
    to='client@example.com',
    subject='Proposal draft',
    body_text='Please review the proposal.',
    draft=True
)

4. 整理与管理

# Archive email:
gmail_manage(account='work', action='archive', message_id='18f2a9b4c10d')

# Mark as unread:
gmail_manage(account='default', action='mark_unread', message_id='18f2a9b4c10d')

# Move to trash:
gmail_manage(account='default', action='trash', message_id='18f2a9b4c10d')

# List active accounts:
gmail_manage(action='list_accounts')

测试

pytest tests

许可证

MIT

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables interaction with Gmail through the MCP protocol, supporting sending, reading, searching, replying, forwarding, managing drafts and labels, and saving attachments.
    12
    3
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables Gmail operations such as reading, sending, searching, and managing emails, threads, labels, and drafts via MCP tools.
    1
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables reading, searching, sending, and drafting Gmail emails via MCP tools, with support for multiple accounts and background notifications.

View all related MCP servers

Related MCP Connectors

  • Read, search, send, organize, draft and schedule email across your inboxes from any MCP client.

  • Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflow…

  • Manage Gmail messages, threads, labels, drafts, and settings from your workflows. Send and organiz…

View all MCP Connectors

Latest Blog Posts

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/Steph-ux/gmail-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server