关于 google-workspace-mcp
google-workspace-mcp 是面向 Google Workspace 管理员的 MCP 服务,可通过对话管理用户、群组、别名和组织单位。它使用 Admin SDK 与域范围委派,删除操作需明确确认,且服务端不存储数据。
主要功能
- 01搜索、查看和创建用户
- 02暂停用户并重置密码
- 03添加、移除和列出邮件别名
- 04管理群组及成员
- 05列出组织单位并移动用户
适用场景
- 01处理新员工账号创建和离职停用
- 02为用户重置密码或调整别名
- 03维护邮件群组成员
- 04将用户分配到不同组织单位
MCP 相关
该 MCP 服务向兼容客户端暴露 Google Workspace 管理工具,可管理用户、群组、别名和组织单位。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
uvx google-workspace-admin-mcpGOOGLE_SERVICE_ACCOUNT_FILE密钥Path to Service Account JSON credentialsGOOGLE_ADMIN_EMAILSuper admin email with domain-wide delegationGOOGLE_CUSTOMER_IDDomain customer ID (default: my_customer)本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
🔧 Google Workspace MCP Server
🇮🇹 意大利语 | 🇬🇧 英语
意大利语
用于通过 Claude AI 和其他兼容助手管理 Google Workspace 的 MCP(Model Context Protocol)服务。可以通过自然对话管理用户、群组、别名和组织单位。
✨ 功能
| 工具 | 描述 |
|---|---|
gw_list_users | 列出用户,支持搜索和筛选 |
gw_get_user | 获取用户的完整详情 |
gw_create_user | 创建新用户并自动生成密码 |
gw_delete_user | 删除用户(必须确认) |
gw_suspend_user | 暂停或重新激活用户 |
gw_reset_password | 重置密码并自动生成新密码 |
gw_manage_alias | 添加、移除和列出电子邮件别名 |
gw_list_groups | 列出域中的群组或用户所属的群组 |
gw_manage_group_member | 在群组中添加或移除成员 |
gw_list_org_units | 列出组织单位 |
gw_move_user_org | 在组织单位之间移动用户 |
📋 前置条件
- Python 3.10+
- 具有管理员访问权限的 Google Workspace 账号
- 已启用 Admin SDK API 的 Google Cloud 项目
- Claude Desktop 或其他 MCP 客户端
🚀 安装
pip install google-workspace-mcp
或从源代码安装:
git clone https://github.com/aringad/google-workspace-mcp.git
cd google-workspace-mcp
pip install -r requirements.txt
🔑 Google Cloud 配置
1. 创建项目并启用 API
- 前往 console.cloud.google.com
- 创建新项目(或使用现有项目)
- 前往 API 和服务 → 库
- 搜索并启用:Admin SDK API
2. 创建 Service Account
- 前往 API 和服务 → 凭据
- 创建凭据 → 服务账号
- 为其命名(例如
mcp-workspace-admin) - 前往 Service Account → 密钥 → 添加密钥 → JSON
- 下载 JSON 文件(这就是你的凭据)
- 记下 Client ID(Service Account 详情中的长数字)
⚠️ 无需为 Service Account 分配 IAM 角色。权限来自全域委派。
3. 全域委派
- 前往 admin.google.com
- 安全性 → 访问和数据控制 → API 控制 → 管理全域委派
- 点击 添加新项
- 输入 Service Account 的 Client ID
- 在 OAuth 范围中输入:
https://www.googleapis.com/auth/admin.directory.user,https://www.googleapis.com/auth/admin.directory.group,https://www.googleapis.com/auth/admin.directory.orgunit,https://www.googleapis.com/auth/admin.directory.user.alias
- 授权
⚙️ 环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
GOOGLE_SERVICE_ACCOUNT_FILE | 凭据 JSON 文件的路径 | ./credentials.json |
GOOGLE_ADMIN_EMAIL | 已启用委派的超级管理员电子邮件 | (必填) |
GOOGLE_CUSTOMER_ID | 域的 Customer ID | my_customer |
🔌 Claude Desktop 配置
将以下内容添加到配置文件:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"google_workspace": {
"command": "/percorso/completo/google-workspace-mcp/venv/bin/python",
"args": ["/percorso/completo/google-workspace-mcp/server.py"],
"env": {
"GOOGLE_SERVICE_ACCOUNT_FILE": "/percorso/completo/credentials.json",
"GOOGLE_ADMIN_EMAIL": "[email protected]"
}
}
}
}
完全退出 Claude Desktop(Mac 上按 Cmd+Q)后重新打开。
🏢 多客户端配置
添加独立实例即可管理多个域:
{
"mcpServers": {
"gw_cliente_alfa": {
"command": "/percorso/venv/bin/python",
"args": ["server.py"],
"env": {
"GOOGLE_SERVICE_ACCOUNT_FILE": "/percorso/credentials-alfa.json",
"GOOGLE_ADMIN_EMAIL": "[email protected]"
}
},
"gw_cliente_beta": {
"command": "/percorso/venv/bin/python",
"args": ["server.py"],
"env": {
"GOOGLE_SERVICE_ACCOUNT_FILE": "/percorso/credentials-beta.json",
"GOOGLE_ADMIN_EMAIL": "[email protected]"
}
}
}
}
💬 使用示例
完成配置后,你可以对 Claude 说:
- “显示域中的所有用户”
- “创建新用户 [email protected],姓名为 Mario Rossi”
- “暂停用户 [email protected]”
- “重置 [email protected] 的密码”
- “为用户 [email protected] 添加别名 [email protected]”
- “将 [email protected] 添加到群组 [email protected]”
- “这个域划分为哪些组织单位?”
你也可以直接复制客户的电子邮件并附上请求,Claude 会自动判断要执行的操作。
🔒 安全
- 绝不要将 Service Account 凭据提交到仓库
- 生成的临时密码为 16 个字符,包含字母、数字和符号
- 破坏性操作(删除)需要明确确认
- Service Account 仅使用严格必需的权限
- MCP 服务不会存储任何数据
🧪 测试
# Verifica che il server parta
python server.py --help
# Test con MCP Inspector
npx @modelcontextprotocol/inspector python server.py
English
用于将 Google Workspace Admin 与 Claude AI 及其他兼容助手集成的 MCP(Model Context Protocol)服务。通过自然对话管理用户、群组、别名和组织单位。
✨ 功能
| 工具 | 描述 |
|---|---|
gw_list_users | 列出用户,支持搜索和筛选 |
gw_get_user | 完整的用户详情 |
gw_create_user | 创建用户并自动生成密码 |
gw_delete_user | 删除用户(需要明确确认) |
gw_suspend_user | 暂停或重新激活用户 |
gw_reset_password | 重置密码并自动生成新密码 |
gw_manage_alias | 添加、移除、列出电子邮件别名 |
gw_list_groups | 列出域或用户群组 |
gw_manage_group_member | 添加/移除群组成员 |
gw_list_org_units | 列出组织单位 |
gw_move_user_org | 在组织单位之间移动用户 |
📋 前提条件
- Python 3.10+
- 具有管理员访问权限的 Google Workspace 账号
- 已启用 Admin SDK API 的 Google Cloud 项目
- Claude Desktop 或其他 MCP 客户端
🚀 安装
pip install google-workspace-mcp
也可以从源码安装:
git clone https://github.com/aringad/google-workspace-mcp.git
cd google-workspace-mcp
pip install -r requirements.txt
🔑 Google Cloud 设置
1. 创建项目并启用 API
- 前往 console.cloud.google.com
- 创建一个新项目(或使用现有项目)
- 前往 APIs & Services → Library
- 搜索并启用:Admin SDK API
2. 创建 Service Account
- 前往 APIs & Services → Credentials
- 选择 Create Credentials → Service Account
- 为其命名(例如,
mcp-workspace-admin) - 前往 Service Account → Keys → Add Key → JSON
- 下载 JSON 文件(这是你的凭据)
- 记下 Client ID(Service Account 详情中的长数字)
⚠️ Service Account 无需 IAM 角色。权限通过全网域委派授予。
3. 全网域委派
- 前往 admin.google.com
- 选择 Security → Access and data control → API controls → Manage Domain Wide Delegation
- 点击 Add new
- 输入 Service Account 的 Client ID
- 在 OAuth scopes 中输入:
https://www.googleapis.com/auth/admin.directory.user,https://www.googleapis.com/auth/admin.directory.group,https://www.googleapis.com/auth/admin.directory.orgunit,https://www.googleapis.com/auth/admin.directory.user.alias
- 点击 Authorize
⚙️ 环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
GOOGLE_SERVICE_ACCOUNT_FILE | 凭据 JSON 文件的路径 | ./credentials.json |
GOOGLE_ADMIN_EMAIL | 启用了委派的超级管理员电子邮件地址 | (必填) |
GOOGLE_CUSTOMER_ID | 网域客户 ID | my_customer |
🔌 Claude Desktop 配置
将以下内容添加到配置文件:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"google_workspace": {
"command": "/full/path/to/google-workspace-mcp/venv/bin/python",
"args": ["/full/path/to/google-workspace-mcp/server.py"],
"env": {
"GOOGLE_SERVICE_ACCOUNT_FILE": "/full/path/to/credentials.json",
"GOOGLE_ADMIN_EMAIL": "[email protected]"
}
}
}
}
完全退出 Claude Desktop(Mac 上按 Cmd+Q)并重新打开。
💬 使用示例
配置完成后,你可以告诉 Claude:
- “显示网域中的所有用户”
- “创建新用户 [email protected],姓名为 John Doe”
- “暂停用户 [email protected]”
- “重置 [email protected] 的密码”
- “为用户 [email protected] 添加别名 [email protected]”
- “将 [email protected] 添加到 [email protected] 群组”
- “网域中有哪些组织单位?”
你也可以直接粘贴客户的请求邮件,Claude 会自动解析需要执行的操作。
🔒 安全
- 服务账号凭据绝不能提交到代码仓库
- 临时密码为 16 位,包含字母、数字和符号
- 破坏性操作(删除)需要明确确认
- 服务账号遵循最小必要权限原则
- MCP 服务不会存储任何数据
🧪 测试
# Verify server starts
python server.py --help
# Test with MCP Inspector
npx @modelcontextprotocol/inspector python server.py
📄 许可证
MIT 许可证 — 详情请参阅 LICENSE。
👨💻 作者
由 Mediaform s.c.r.l. 开发 — 意大利热那亚
基于 MCP 和 Google Admin SDK 构建
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。