用于模型上下文协议 (MCP) 的 Gmail 服务器
该 MCP 服务器与 Gmail 集成,可实现发送、删除、阅读、起草和回复电子邮件。
注意:此服务器允许 MCP 客户端阅读、删除和发送电子邮件。但是,客户端会在执行这些操作之前提示用户。
https://github.com/user-attachments/assets/5794cd16-00d2-45a2-884a-8ba0c3a90c90
成分
工具
- 发送电子邮件
- 发送电子邮件至电子邮件地址收件人
- 输入:
recipient_id
(字符串):收件人的电子邮件地址subject
(字符串):电子邮件主题message
(字符串):电子邮件内容
- 返回状态和消息 ID
- 垃圾邮件
- 将电子邮件移至垃圾箱
- 输入:
email_id
(字符串):自动生成的电子邮件 ID
- 返回成功消息
- 将电子邮件标记为已读
- 将电子邮件标记为已读
- 输入:
email_id
(字符串):自动生成的电子邮件 ID
- 返回成功消息
- 获取未读邮件
- 检索未读电子邮件
- 返回包含电子邮件 ID 的电子邮件列表
- 阅读电子邮件
- 检索给定的电子邮件内容
- 输入:
email_id
(字符串):自动生成的电子邮件 ID
- 返回电子邮件元数据字典并将电子邮件标记为已读
- 打开电子邮件
- 在浏览器中打开电子邮件
- 输入:
email_id
(字符串):自动生成的电子邮件 ID
- 返回成功消息并在默认浏览器中打开给定的电子邮件
设置
Gmail API 设置
- 创建新的 Google Cloud 项目
- 启用 Gmail API
- 配置 OAuth 同意屏幕
- 选择“外部”。但是,我们不会发布该应用。
- 将您的个人电子邮件地址添加为“测试用户”。
- 添加 OAuth 范围
https://www.googleapis.com/auth/gmail/modify
- 为应用程序类型“桌面应用程序”创建 OAuth 客户端 ID
- 下载客户端 OAuth 密钥的 JSON 文件
- 重命名密钥文件并将其保存到本地计算机的安全位置。记下该位置。
- 服务器启动时,该文件的绝对路径将作为参数
--creds-file-path
传递。
- 服务器启动时,该文件的绝对路径将作为参数
验证
服务器启动后,您的系统浏览器中将启动身份验证流程。令牌凭证随后将保存(并稍后检索)到传递给参数--token-path
绝对文件路径中。
例如,您可以在主文件夹中使用点目录,替换[your-home-folder]
。:
范围 | 例子 |
---|---|
--creds-file-path | /[your-home-folder]/.google/client_creds.json |
--token-path | /[your-home-folder]/.google/app_tokens.json |
与桌面应用程序一起使用
建议使用紫外线。
要将此服务器与 Claude Desktop 集成为 MCP 客户端,请将以下内容添加到应用的服务器配置中。默认情况下,此配置存储在~/Library/Application\ Support/Claude/claude_desktop_config.json
中。
必须设置以下参数
范围 | 例子 |
---|---|
--directory | 包含服务器的gmail 目录的绝对路径 |
--creds-file-path | 在 Gmail API 设置中创建的凭据文件的绝对路径。 |
--token-path | 存储和检索应用程序的访问和刷新令牌的绝对路径。 |
使用 MCP Inspector 进行故障排除
要测试服务器,请使用MCP Inspector 。从 git 仓库运行以下命令,并相应地更改参数。
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
与 Gmail 集成,实现通过模型上下文协议 (MCP) 发送、阅读、起草和管理电子邮件,允许用户通过自动客户端提示与电子邮件任务进行交互。
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityModel Context Protocol server for Gmail integration. This allows Claude Desktop (or any MCP client) to interact with your Gmail account through Google Apps Script.Last updated -2312MIT License
- -securityAlicense-qualityEnables interaction with Gmail and Google Calendar using the MCP protocol, supporting multiple Google accounts, email management, and calendar operations through natural language.Last updated -13MIT License
- -securityAlicense-qualityProvides comprehensive Gmail integration with LLM processing capabilities, allowing users to read, search, filter emails and handle attachments through the Model Context Protocol.Last updated -81MIT License
- -securityAlicense-qualityMCP server that integrates with Gmail to enable sending, reading, and managing emails through tools like send-email, trash-email, get-unread-emails, and read-email.Last updated -59GPL 3.0