Integrations
Allows reading, sending, and managing emails from multiple Gmail accounts, including searching emails, downloading attachments, and handling email conversations and threads.
Requires a Google Cloud Project with Gmail API enabled and OAuth 2.0 credentials for authentication and authorization.
Gmail MCP 服务器
一个强大而灵活的 Gmail 集成服务器,基于 MCP(消息控制协议)框架构建。该服务器提供强大的接口,可与 Gmail API 交互,并提供以编程方式阅读、发送和管理电子邮件的功能。
特征
- 阅读来自多个 Gmail 帐户的电子邮件
- 发送带附件的电子邮件
- 使用高级查询选项搜索电子邮件
- 下载电子邮件附件
- 处理电子邮件对话和主题
- 实时电子邮件监控
- 支持多个 Gmail 帐户
先决条件
在运行 Gmail MCP 服务器之前,请确保您具备以下条件:
- Python 3.12 或更高版本
- 已启用 Gmail API 的 Google Cloud 项目
- OAuth 2.0 客户端 ID 凭证
- 所需的 Python 包(在 pyproject.toml 中指定)
安装
通过 Smithery 安装
要通过Smithery自动为 Claude Desktop 安装 Gmail 集成服务器:
- 克隆存储库:
- 创建并激活虚拟环境:
- 安装依赖项:
设置 Google Cloud 项目
- 前往Google Cloud Console
- 创建新项目或选择现有项目
- 为您的项目启用 Gmail API
- 创建 OAuth 2.0 凭据:
- 前往“API 和服务”>“凭证”
- 点击“创建凭证”>“OAuth 客户端 ID”
- 选择“桌面应用”作为应用程序类型
- 下载客户端配置文件
- 将下载的文件重命名为
client_secret.json
并放置在项目根目录下
配置
- 在
gmail_token_creator.py
中设置电子邮件标识符:
- 运行令牌创建器来验证您的 Gmail 帐户:
- 对要集成的每个 Gmail 帐户重复此过程
服务器结构
gmail_server.py
:主要 MCP 服务器实现gmail_api.py
:Gmail API 交互函数google_apis.py
API 身份验证实用程序- 支持文件:
read_emails.py
:电子邮件阅读功能search_emails.py
:电子邮件搜索功能send_emails.py
:电子邮件发送功能
用法
启动服务器
可用工具
- 发送电子邮件:
- 搜索电子邮件:
- 阅读最新电子邮件:
- 下载附件:
安全注意事项
- 安全地存储
client_secret.json
并且永远不要将其提交到版本控制 - 确保令牌文件的安全并将其添加到
.gitignore
- 使用环境变量来获取敏感信息
- 定期轮换 OAuth 凭证
- 监控 API 使用情况并设置适当的配额
错误处理
该服务器包括全面的错误处理和日志记录:
- 日志写入
gmail_mcp.log
- 文件和控制台日志记录均已启用
- 用于调试的详细错误消息
贡献
- 分叉存储库
- 创建功能分支
- 提交你的更改
- 推送到分支
- 创建拉取请求
执照
Apache许可证2.0
支持
对于问题和功能请求,请使用 GitHub 问题跟踪器。
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
通过 Gmail API 与 Gmail 交互,阅读、发送和管理电子邮件。支持多个 Gmail 帐户,并提供实时监控以及电子邮件搜索和附件处理的高级功能。
Related Resources
Related MCP Servers
- -securityFlicense-qualityEnables users to manage Gmail accounts using AI agent-assisted operations via an MCP protocol, supporting email search, reading, deletion, and sending with a voice-powered interface.Last updated -25TypeScript
- -securityAlicense-qualityIntegrates with Gmail to enable sending, reading, drafting, and managing emails via the Model Context Protocol (MCP), allowing users to interact with email tasks through automated client prompts.Last updated -PythonGPL 3.0
- -securityAlicense-qualityAn MCP server that enables Gmail integration, allowing users to manage emails (send, receive, read, trash, mark as read) directly through MCP clients like Claude Desktop.Last updated -PythonMIT License
- -securityFlicense-qualityEnables AI assistants to interact with Gmail accounts via IMAP, allowing them to list, search, read, and send emails, manage labels and folders, and access attachments through the Model Context Protocol.Last updated -Python