关于 Google Workspace MCP Server
通过 MCP 操作 Gmail、Google Calendar 和 Google Chat 的服务器,支持管理邮件与日历活动,以及处理 Chat 消息、空间和成员关系。
主要功能
- 01搜索、列出、发送和修改邮件
- 02列出并管理日历活动
- 03发送和检索 Chat 消息
- 04浏览空间与成员关系
- 05用自然语言筛选消息
适用场景
- 01查找并整理收件箱邮件
- 02安排或更新日历活动
- 03发送消息并查看 Google Chat 空间
MCP 相关
向 MCP 客户端提供 Gmail、Google Calendar 和 Google Chat API 工具,涵盖邮件与活动操作、消息处理,以及空间和成员关系查询。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
Google Workspace MCP 服务
一个模型上下文协议(MCP)服务,提供与 Gmail 和 Calendar API 交互的工具。此服务可让你通过 MCP 接口以编程方式管理电子邮件和日历活动。
功能
Gmail 工具
list_emails:列出收件箱中的近期电子邮件,并支持可选筛选search_emails:使用 Gmail 查询语法进行高级电子邮件搜索send_email:发送新电子邮件,并支持抄送和密送modify_email:修改电子邮件标签(归档、移至回收站、标记为已读/未读)
Calendar 工具
list_events:列出即将举行的日历活动,并支持按日期范围筛选create_event:创建包含参与者的新日历活动update_event:更新现有日历活动delete_event:删除日历活动
前置条件
- Node.js:安装 14 或更高版本的 Node.js
- Google Cloud Console 设置:
- 前往 Google Cloud Console
- 创建新项目或选择现有项目
- 启用 Gmail API 和 Google Calendar API:
- 前往“APIs & Services” > “Library”
- 搜索并启用“Gmail API”
- 搜索并启用“Google Calendar API”
- 设置 OAuth 2.0 凭据:
- 前往“APIs & Services” > “Credentials”
- 点击“Create Credentials” > “OAuth client ID”
- 选择“Web application”
- 将
http://localhost:3000/auth/callback添加到“Authorized redirect URIs” - 记下客户端 ID 和客户端密钥
通过 Smithery 安装
使用 Smithery 的 CLI 安装服务:
npx spinai-mcp install @KaranThink41/gsuite-mcp-server --provider smithery --config '{"googleClientId":"your_google_client_id","googleClientSecret":"your_google_client_secret","googleRefreshToken":"your_google_refresh_token"}'
或者,可以使用以下配置:
// smithery.config.js
export default {
KaranThink41_google_chat_mcp_server: {
command: 'npx',
args: [
'-y',
'@smithery/cli@latest',
'run',
'@KaranThink41/google_chat_mcp_server'
]
},
};
本地开发(可选)
如果你希望在本地运行服务:
- 克隆仓库:
git clone https://github.com/KaranThink41/Google_workspace_mcp_server.git
cd Google_workspace_mcp_server
- 安装依赖项:
npm install
- 构建项目:
npm run build
- 运行服务:
node build/index.js
使用示例
Gmail 操作
-
列出近期电子邮件:
{ "maxResults": 5, "query": "is:unread" } -
搜索电子邮件:
{ "query": "from:[email protected] has:attachment", "maxResults": 10 } -
发送电子邮件:
{ "to": "[email protected]", "subject": "Hello", "body": "Message content", "cc": "[email protected]", "bcc": "[email protected]" } -
修改电子邮件:
{ "id": "message_id", "addLabels": ["UNREAD"], "removeLabels": ["INBOX"] }
Calendar 操作
-
列出活动:
{ "maxResults": 10, "timeMin": "2024-01-01T00:00:00Z", "timeMax": "2024-12-31T23:59:59Z" } -
创建活动:
{ "summary": "Team Meeting", "location": "Conference Room", "description": "Weekly sync-up", "start": "2024-01-24T10:00:00Z", "end": "2024-01-24T11:00:00Z", "attendees": ["[email protected]"] } -
更新活动:
{ "eventId": "event_id", "summary": "Updated Meeting Title", "location": "Virtual", "start": "2024-01-24T11:00:00Z", "end": "2024-01-24T12:00:00Z" } -
删除活动:
{ "eventId": "event_id" }
故障排除
-
身份验证问题:
- 确保已授予所有必需的 OAuth 作用域
- 确认客户端 ID 和密钥正确无误
- 检查刷新令牌是否有效
-
API 错误:
- 在 Google Cloud Console 中检查 API 配额和限制
- 确保已为项目启用 API
- 确认请求参数符合所需格式
许可证
本项目采用 MIT 许可证。
Google Chat MCP 服务
一个用于与 Google Chat API 交互的模型上下文协议(MCP)服务实现。此服务提供用于管理 Google Chat 中消息、空间和成员资格的工具。
功能
- 向 Google Chat 空间发送文本消息
- 获取空间详情并列出空间
- 管理成员资格(列出成员、获取成员详情)
- 列出和获取消息,并支持筛选
- 支持自然语言筛选
设置说明
1. 设置 Google Cloud 项目
- 前往 Google Cloud Console
- 创建新项目或选择现有项目
- 启用 Google Chat API
- 创建 OAuth 2.0 凭据:
- 前往 API & Services > Credentials
- 点击“Create Credentials” > “OAuth client ID”
- 选择“Web application”
- 将
http://localhost:3000/auth/callback添加到“Authorized redirect URIs” - 记下客户端 ID 和客户端密钥
2. 获取刷新令牌
- 创建临时凭据文件:
cp temp-credentials.json.example temp-credentials.json
-
使用你的客户端 ID 和客户端密钥更新
temp-credentials.json -
运行刷新令牌脚本:
node get-refresh-token.js
- 按照浏览器身份验证流程获取刷新令牌
3. 通过 Smithery 安装
使用 Smithery 的 CLI 安装服务:
npx spinai-mcp install @KaranThink41/google_chat_mcp_server --provider smithery --config '{"spaceId":"your_space_id","googleClientId":"your_google_client_id","googleClientSecret":"your_google_client_secret","googleRefreshToken":"your_google_refresh_token"}'
或者,你可以使用以下配置:
export default {
KaranThink41_google_chat_mcp_server: {
command: 'npx',
args: [
'-y',
'@smithery/cli@latest',
'run',
'@KaranThink41/google_chat_mcp_server'
]
},
};
4. 本地开发(可选)
如果你更愿意在本地运行服务:
- 克隆仓库:
git clone https://github.com/KaranThink41/Google_chat_mcp_server.git
cd Google_chat_mcp_server
- 安装依赖:
npm install
- 构建项目:
npm run build
- 运行服务:
node build/index.js
可用工具
消息管理
-
post_text_message:向 Google Chat 空间发送文本消息{ "method": "tools/call", "params": { "name": "post_text_message", "arguments": { "spaceId": "AAAAfkdUqxE", "text": "Hello, this is a test message!" } } } -
fetch_message_details:获取特定消息的详细信息{ "method": "tools/call", "params": { "name": "fetch_message_details", "arguments": { "spaceId": "AAAAfkdUqxE", "messageId": "cpwLU-2f_z8.cpwLU-2f_z8" } } } -
list_space_messages:列出空间中的消息,并支持可选筛选{ "method": "tools/call", "params": { "name": "list_space_messages", "arguments": { "spaceId": "AAAAfkdUqxE", "pageSize": 10, "orderBy": "createTime" } } }
空间管理
-
fetch_space_details:获取空间的全面详细信息{ "method": "tools/call", "params": { "name": "fetch_space_details", "arguments": { "spaceId": "AAAAfkdUqxE" } } } -
list_joined_spaces:列出调用者加入的所有空间{ "method": "tools/call", "params": { "name": "list_joined_spaces", "arguments": { "pageSize": 10 } } }
成员管理
-
list_space_memberships:列出空间中的所有成员关系{ "method": "tools/call", "params": { "name": "list_space_memberships", "arguments": { "spaceId": "AAAAfkdUqxE", "pageSize": 10 } } } -
fetch_member_details:获取特定成员的详细信息{ "method": "tools/call", "params": { "name": "fetch_member_details", "arguments": { "spaceId": "AAAAfkdUqxE", "memberId": "user_123" } } }
自然语言筛选
apply_natural_language_filter:将自然语言查询转换为 API 筛选字符串{ "method": "tools/call", "params": { "name": "apply_natural_language_filter", "arguments": { "filterText": "messages from Monday" } } }
错误处理
服务实现了完善的错误处理,并提供描述性错误消息。常见错误包括:
- 身份验证失败
- 无效的空间 ID
- 速率限制
- 超出 API 配额
安全性
- 所有敏感凭据都存储在环境变量中
- OAuth 刷新令牌受到安全管理
- API 密钥绝不会暴露在代码中
贡献
- Fork 仓库
- 创建功能分支(
git checkout -b feature/amazing-feature) - 提交更改(
git commit -m 'Add some amazing feature') - 推送到分支(
git push origin feature/amazing-feature) - 发起 Pull Request
许可证
本项目采用 MIT License 许可,详情请参阅 LICENSE 文件。
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。