SG

sallytion/gmail-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

14 stars 9 forks 质量 55 趋势 20

Docker 基于 MCP 连接您的 Gmail 并读取电子邮件, 总结电子邮件, 并写邮件 .

概览

一个用于Gmail操作的模型上下文协议(MCP)服务器,使用IMAP/SMTP进行应用密码认证. - :列出最后10个信件(或更多,如果指定) - :搜索包含特定单词或短语的信件 - :发送带有指定收件人和信件正文的电子邮件 在你的Gmail账户2。 前往 —— 3. 生成一个"Mail" 4. 复制16个字符的应用程序密码 -IMAP:imap.gmail.com:993 (SSL) - SMTP: smtp.gmail.com:587 (TLS) -: App密码(不是正密码) 更新您 env 文件的 IMAP/ SMTP 设置! QQ- 简单应用程序密码认证 - 与任何电子邮件提供者一起工作 - 无 OAuth2 复杂度 - 没有 Google Cloud Console 设置 - 即时设置 (2分钟) QQ- 复杂的 OAuth2 流量 - Google Cloud Console 配置 - Token 管理和刷新 - 只有 Gmail ( vendor 锁定) 添加 MCP 服务器配置到您的 Claude 桌面配置文件 : - :% APPDATA\\ Claude desktop config .

概述(AI 翻译)

一个用于Gmail操作的模型上下文协议(MCP)服务器,使用IMAP/SMTP进行应用密码认证.

□ 特性

  • ** 列表地址**:列出最后10个信件(如果指定,则列出更多信件)
  • ** findMessage**:搜索包含特定单词或短语的信息
  • 发送信**: 发送带有指定收件人和信件正文的邮件

□ 简单设置( 不需要 OAuth !)

  1. Gmail App密码设置

  2. ** 在您的 Gmail 账户上可允许的 2- Factor 认证**

  3. 转到** Google 账户设置** ** ** 安全** ** ** App 密码**

  4. 为"邮件"生成一个App密码

  5. 复制16个特征的应用程序密码

  6. 地方发展

  7. 安装依赖性:

  8. 创建 [[T0] 文件 :

  9. 建设和启动:

  10. 插头的使用

  11. 创建您的 [[T1] 文件( 如上)

  12. 建设和运行:

□ MCP 客户端集成

QQ 简单嵌入器配置

将此添加到您的 MCP 客户端设置 :

使用 Docker 编曲

□ 支持的电子邮件提供者

QQ Gmail (默认)

  • IMAP:[[T2] (SSL)
  • SMTP:[[T3] (TLS)
  • ** 要求**: App密码(不是普通密码)
  • 展望/电子邮件 更新.env:

其他供应商

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Gmail MCP

A Model Context Protocol (MCP) server for Gmail operations using IMAP/SMTP with app password authentication.

Features

  • listMessages: List the last 10 messages (or more if specified)
  • findMessage: Search for messages containing specific words or phrases
  • sendMessage: Send emails with specified recipient and message body

Simple Setup (No OAuth Required!)

1. Gmail App Password Setup

  1. Enable 2-Factor Authentication on your Gmail account
  2. Go to Google Account Settings → Security → App passwords
  3. Generate an App password for “Mail”
  4. Copy the 16-character app password

2. Local Development

  1. Install dependencies:

    npm install
    
  2. Create a .env file:

    [email protected]
    EMAIL_PASSWORD=your_16_char_app_password
    IMAP_HOST=imap.gmail.com
    IMAP_PORT=993
    SMTP_HOST=smtp.gmail.com
    SMTP_PORT=587
    
  3. Build and start:

    npm run build
    npm start
    

3. Docker Usage

  1. Create your .env file (as above)

  2. Build and run:

    npm run docker:build
    docker run --rm -i --env-file .env email-mcp-server
    

MCP Client Integration

Simple Docker Configuration

Add this to your MCP client settings:

{
  "mcpServers": {
    "email": {
      "command": "docker",
      "args": [
        "run", "--rm", "-i",
        "--env-file", ".env",
        "email-mcp-server"
      ]
    }
  }
}

Using with Docker Compose

{
  "mcpServers": {
    "email": {
      "command": "docker-compose",
      "args": ["run", "--rm", "email-mcp-server"]
    }
  }
}

Supported Email Providers

Gmail (Default)

  • IMAP: imap.gmail.com:993 (SSL)
  • SMTP: smtp.gmail.com:587 (TLS)
  • Requires: App password (not regular password)

Outlook/Hotmail

Update .env:

IMAP_HOST=outlook.office365.com
SMTP_HOST=smtp-mail.outlook.com

Other Providers

Just update the IMAP/SMTP settings in your .env file!

Usage Examples

List Recent Messages

{
  "count": 20
}

Search Messages

{
  "query": "important meeting"
}

Send Email

{
  "to": "[email protected]",
  "subject": "Hello from MCP!",
  "body": "This email was sent via the Email MCP Server"
}

Why IMAP/SMTP vs Gmail API?

✅ IMAP/SMTP Advantages:

  • Simple app password authentication
  • Works with any email provider
  • No OAuth2 complexity
  • No Google Cloud Console setup
  • Immediate setup (2 minutes)

❌ Gmail API Disadvantages:

  • Complex OAuth2 flow
  • Google Cloud Console configuration
  • Token management and refresh
  • Gmail-only (vendor lock-in)

Usage with Claude Desktop

Configuration

  1. Add the MCP server configuration to your Claude Desktop config file:
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
在 GitHub 查看完整 README

安装

docker run --rm -i --env-file .env email-mcp-server
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "email": { "command": "docker", "args": [ "run", "--rm", "-i", "--env-file", ".env", "email-mcp-server" ] } } }