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 !)
-
Gmail App密码设置
-
** 在您的 Gmail 账户上可允许的 2- Factor 认证**
-
转到** Google 账户设置** ** ** 安全** ** ** App 密码**
-
为"邮件"生成一个App密码
-
复制16个特征的应用程序密码
-
地方发展
-
安装依赖性:
-
创建 [[T0] 文件 :
-
建设和启动:
-
插头的使用
-
创建您的 [[T1] 文件( 如上)
-
建设和运行:
□ 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
- Enable 2-Factor Authentication on your Gmail account
- Go to Google Account Settings → Security → App passwords
- Generate an App password for “Mail”
- Copy the 16-character app password
2. Local Development
-
Install dependencies:
npm install -
Create a
.envfile:[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 -
Build and start:
npm run build npm start
3. Docker Usage
-
Create your
.envfile (as above) -
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
- 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
- Windows:
安装
docker run --rm -i --env-file .env email-mcp-server配置
{
"mcpServers": {
"email": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"--env-file", ".env",
"email-mcp-server"
]
}
}
}