MCP Gmail

MCP Gmail

site icon
2024.12.27 9
JavaScriptGmail集成邮件自动化交流协作
MCP Gmail 是一个基于 Model Context Protocol 的服务,用于实现 Gmail 的集成。它允许 Claude Desktop(或任何 MCP 客户端)通过 Google Apps Script 与用户的 Gmail 账户进行交互。该服务提供了搜索邮件、获取邮件内容和下载附件等功能,适用于需要自动化处理 Gmail 邮件的场景。
View on GitHub

Overview

基本能力

产品定位

MCP Gmail 是一个用于 Gmail 集成的服务,通过 Google Apps Script 实现与 Gmail 账户的交互。

核心功能

  • 搜索邮件:使用 Gmail 搜索查询语法搜索邮件(如 "subject:Meeting newer_than:1d")。
  • 获取邮件内容:获取特定邮件的完整内容和详细信息。
  • 下载附件:从特定邮件中下载附件。

适用场景

  • 自动化处理 Gmail 邮件。
  • 集成 Gmail 功能到其他应用程序中。
  • 开发需要访问 Gmail 数据的工具或服务。

工具列表

  • gmail_search_messages:使用 Gmail 搜索查询语法搜索邮件。
  • gmail_get_message:获取特定邮件的完整内容和详细信息。
  • gmail_download_attachment:从特定邮件中下载附件。

常见问题解答

  • 确保在部署 Google Apps Script 时正确授权 Gmail 访问权限。
  • 始终保密 VALID_API_KEY,不要将其提交到版本控制中。

使用教程

使用依赖

  • Node.js 18+(通过 brew install node 安装)。
  • Gmail 账户。
  • Google Apps Script 部署。
  • Claude Desktop(从 https://claude.ai/desktop 安装)。

安装教程

  1. 部署 Google Apps Script:
  2. 访问 Google Apps Script 并创建新项目。
  3. 复制 code.gs 的全部内容并粘贴到脚本编辑器中。
  4. 点击 "Deploy" > "New deployment"。
  5. 选择 "Web app" 作为部署类型。
  6. 配置以下设置:
    • Execute as: Me
    • Who has access: Anyone
    • 点击 "Deploy"。
  7. 复制部署 URL 并生成随机 API 密钥以确保安全。

  8. 修改 Claude Desktop 配置文件:

  9. 打开 ~/Library/Application Support/Claude/claude_desktop_config.json
  10. 添加以下内容: json { "tools": { "gmail": { "command": "npx", "args": ["-y", "@kazuph/mcp-gmail-gas"], "env": { "GAS_ENDPOINT": "YOUR_DEPLOYMENT_URL", "VALID_API_KEY": "YOUR_API_KEY" } } } }

调试方式

  • 确保 Claude Desktop 已安装并运行。
  • 安装 tsx 全局工具: bash npm install -g tsx # or pnpm add -g tsx
  • 修改 Claude Desktop 配置文件以使用本地开发版本。

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。