内容
# Google Workspace 别名 MCP
用于 Google Workspace 集成,支持 **发送别名** 功能、电子邮件模板和定时发送的模型上下文协议(MCP)服务器。该服务器使 AI 助手能够通过自然语言交互管理 Gmail 和 Google 日历。
### 为什么选择 `google-workspace-alias-mcp`?
- **独特**: 唯一支持发送别名功能的 MCP 服务器
- **统一**: 一个包内同时支持 Gmail 和日历
- **功能齐全**: 包含 28 个工具,覆盖完整的 API
## ✨ 为什么选择此 MCP?
| 功能 | 此 MCP | Gmail MCP(原版) |
|---------|----------|---------------------|
| **发送别名支持** | ✅ 动态发现 | ❌ 不支持 |
| **电子邮件模板** | ✅ 支持变量 | ❌ 不支持 |
| **定时发送** | ✅ 内置支持 | ❌ 不支持 |
| **Gmail + 日历** | ✅ 统一支持 | ❌ 仅支持 Gmail |
| **多账户支持** | ✅ 计划中 | ❌ 不支持 |
| **忙/闲检查** | ✅ 内置支持 | ❌ 不支持 |
## 🚀 功能
### Gmail
- ✅ **发送电子邮件** - 支持主题、正文、附件和收件人
- ✅ **发送别名支持** - 动态发现所有已配置的别名
- ✅ **电子邮件模板** - 保存和重用带有变量的模板
- ✅ **定时发送** - 预定电子邮件的发送时间
- ✅ **草稿邮件** - 创建草稿邮件而非直接发送
- ✅ **阅读电子邮件** - 获取完整的电子邮件内容并显示附件
- ✅ **列出电子邮件** - 查看收件箱、已发送邮件或自定义标签
- ✅ **搜索电子邮件** - 使用 Gmail 搜索语法
- ✅ **修改电子邮件** - 标记为已读/未读、移动到标签/文件夹
- ✅ **删除电子邮件** - 永久删除
- ✅ **下载附件** - 保存附件到本地文件系统
- ✅ **标签管理** - 创建、更新、删除标签
- ✅ **批量操作** - 高效处理多封电子邮件
- ✅ **完整附件支持** - 发送和接收文件附件
- ✅ **HTML 电子邮件** - 支持 HTML 和纯文本的多部分消息
- ✅ **国际字符** - 在主题和正文中完全支持
### Google 日历
- ✅ **创建事件** - 支持标题、时间、描述、地点和与会者
- ✅ **获取事件** - 通过 ID 检索事件详情
- ✅ **列出事件** - 查看指定时间范围内的事件
- ✅ **更新事件** - 修改现有事件
- ✅ **删除事件** - 删除事件
- ✅ **搜索事件** - 按查询条件查找事件
- ✅ **忙/闲检查** - 跨日历检查可用性
- ✅ **多日历支持** - 支持多个日历
- ✅ **重复事件** - 支持重复事件
## 📦 安装
### 使用 npm(推荐)
```bash
npm install -g google-workspace-alias-mcp
```
### 手动安装
```bash
git clone https://github.com/johndelapena168/google-workspace-alias-mcp.git
cd google-workspace-mcp
npm install
```
## ⚙️ 设置
### 1. 创建 Google Cloud 项目
1. 访问 [Google Cloud 控制台](https://console.cloud.google.com/)
2. 创建新项目或选择现有项目
3. 启用以下 API:
- Gmail API
- Google 日历 API
### 2. 创建 OAuth 2.0 凭证
1. 访问 "APIs & Services" > "Credentials"
2. 点击 "Create Credentials" > "OAuth client ID"
3. 选择 "Desktop app" 作为应用程序类型
4. 为其命名(例如 "Google Workspace MCP")
5. 点击 "Create"
6. 下载 JSON 文件
7. 将其重命名为 `gcp-oauth.keys.json`
### 3. 身份验证
将您的 `gcp-oauth.keys.json` 文件放在以下位置之一:
- `~/.google-workspace-mcp/`(推荐)
- 当前目录
然后运行:
```bash
npx google-workspace-alias-mcp auth
```
这将:
1. 打开您的浏览器进行 Google 身份验证
2. 请求访问 Gmail 和日历的权限
3. 为未来使用保存本地凭证
## 🔧 配置
### Claude Desktop
将以下内容添加到您的 Claude Desktop 配置文件(`claude_desktop_config.json`):
```json
{
"mcpServers": {
"google-workspace": {
"command": "npx",
"args": ["google-workspace-alias-mcp"]
}
}
}
```
### Cursor
将以下内容添加到您的 Cursor 设置:
```json
{
"mcpServers": {
"google-workspace": {
"command": "npx",
"args": ["google-workspace-alias-mcp"]
}
}
}
```
### Qoder
全局安装后,MCP 服务器将被自动检测。
## 📖 使用示例
### 使用别名发送电子邮件
```json
{
"tool": "send_email",
"arguments": {
"to": ["client@example.com"],
"subject": "项目更新",
"body": "您好,\n\n这是项目的最新更新。\n\n谨致问候",
"from": "hello@nexteraofai.com"
}
}
```
### 列出可用别名
```json
{
"tool": "list_aliases",
"arguments": {}
}
```
### 列出电子邮件模板
```json
{
"tool": "list_templates",
"arguments": {}
}
```
### 使用模板发送电子邮件
```json
{
"tool": "send_template_email",
"arguments": {
"template": "meeting-followup",
"to": ["client@example.com"],
"variables": {
"name": "John",
"meeting_name": "项目评审",
"summary": "讨论了项目时间表和里程碑",
"next_steps": "1. 完善需求\n2. 开始开发",
"sender_name": "John Dela Pena"
},
"from": "hello@nexteraofai.com"
}
}
```
### 创建自定义模板
```json
{
"tool": "create_template",
"arguments": {
"name": "weekly-report",
"displayName": "周报",
"subject": "周报:{{week_date}}",
"body": "您好 {{name}},\n\n以下是 {{week_date}} 的周报:\n\n{{report_content}}\n\n谨致问候,\n{{sender_name}}"
}
}
```
### 预定电子邮件发送
```json
{
"tool": "send_scheduled_email",
"arguments": {
"to": ["team@example.com"],
"subject": "周更新",
"body": "以下是项目的周更新...",
"scheduledTime": "2026-07-15T09:00:00",
"from": "hello@nexteraofai.com"
}
}
```
### 创建日历事件
```json
{
"tool": "create_event",
"arguments": {
"summary": "项目启动会议",
"description": "讨论项目范围和时间表的初始会议",
"location": "Zoom 会议",
"start": "2026-07-15T14:00:00",
"end": "2026-07-15T15:00:00",
"attendees": ["john@example.com", "jane@example.com"],
"reminders": [
{ "method": "email", "minutes": 60 },
{ "method": "popup", "minutes": 10 }
]
}
}
```
### 搜索事件
```json
{
"tool": "search_events",
"arguments": {
"query": "会议",
"timeMin": "2026-07-01T00:00:00Z",
"timeMax": "2026-07-31T23:59:59Z",
"maxResults": 20
}
}
```
### 检查忙/闲状态
```json
{
"tool": "get_freebusy",
"arguments": {
"timeMin": "2026-07-15T09:00:00Z",
"timeMax": "2026-07-15T17:00:00Z",
"calendars": ["primary", "work@example.com"]
}
}
```
### 按 ID 获取事件
```json
{
"tool": "get_event",
"arguments": {
"calendarId": "primary",
"eventId": "abc123def456"
}
}
```
### 列出收件箱中的电子邮件
```json
{
"tool": "list_emails",
"arguments": {
"labelIds": ["INBOX"],
"maxResults": 10
}
}
```
### 标记电子邮件为已读
```json
{
"tool": "modify_email",
"arguments": {
"messageId": "18a1b2c3d4e5f6789",
"removeLabelIds": ["UNREAD"]
}
}
```
### 将电子邮件移动到标签
```json
{
"tool": "modify_email",
"arguments": {
"messageId": "18a1b2c3d4e5f6789",
"addLabelIds": ["Label_123"],
"removeLabelIds": ["INBOX"]
}
}
```
### 下载附件
```json
{
"tool": "download_attachment",
"arguments": {
"messageId": "18a1b2c3d4e5f6789",
"attachmentId": "ANGjdJ8z7_OQ",
"savePath": "C:/Users/Downloads"
}
}
```
### 创建新标签
```json
{
"tool": "create_label",
"arguments": {
"name": "客户项目",
"messageListVisibility": "show",
"labelListVisibility": "labelShow"
}
}
```
### 批量删除电子邮件
```json
{
"tool": "batch_delete_emails",
"arguments": {
"messageIds": ["msg1", "msg2", "msg3"]
}
}
```
## 🎯 独特的销售卖点
### 1. 动态别名支持
没有其他 MCP 服务器支持 Gmail 发送别名。此 MCP 服务器自动发现所有已配置的别名,并允许您从任何别名发送邮件。
### 2. 电子邮件模板
保存常用的电子邮件模板,并使用变量:
```
"使用 {{name}} 的 meeting-followup 模板"
```
### 3. 预定发送
预定电子邮件在稍后发送:
```json
{
"scheduledTime": "2026-07-15T09:00:00"
}
```
### 4. 统一工作区
一个 MCP 服务器同时支持 Gmail 和日历。无需安装单独的服务器。
## 🔐 安全
- OAuth 凭证存储在本地 `~/.google-workspace-mcp/`
- 令牌在过期时自动刷新
- 不向第三方服务器发送数据
- 对权限完全控制
## 🤝 贡献
欢迎贡献!请随时提交拉取请求。
### 开发设置
```bash
git clone https://github.com/johndelapena168/google-workspace-alias-mcp.git
cd google-workspace-mcp
npm install
npm start
```
## 📝 许可证
MIT 许可证 - 请参阅 [LICENSE](LICENSE) 文件
## 🙏 致谢
- 灵感来自 [Gmail-MCP-Server](https://github.com/GongRzhe/Gmail-MCP-Server) by GongRzhe
- 使用 [Model Context Protocol SDK](https://github.com/modelcontextprotocol/typescript-sdk)
- 使用 [Google APIs](https://github.com/googleapis/google-api-nodejs-client)
## 📧 联系方式
- GitHub: [@johndelapena168](https://github.com/johndelapena168)
- 电子邮件: hello@nexteraofai.com
## ⭐ 支持
如果您觉得这个 MCP 服务器有用,请在 GitHub 上给它一个星级!