Google Workspace CLI
$ gws 官方出品 高风险Google Workspace CLI(gws)通过 Google Discovery Service 动态将 Drive、Gmail、Calendar、Sheets、Docs 与 Chat 封装为统一命令行工具。专为 AI Agent 场景打造,提供 --dry-run、结构化 JSON、Schema 自省以及官方 SKILL.md。
npm install -g @googleworkspace/cli gws 通过 Discovery 覆盖全套 Workspace 服务,支持 --params / fields 掩码并自带官方 SKILL.md 与可选 MCP 模式,比多套独立 MCP 显著省上下文。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
专为 AI Agent 设计:全 JSON 输入输出、--params 字段裁剪、gws schema 运行时自省、--dry-run 与官方 SKILL.md 一应俱全。
- Ships official
SKILL.mdfiles ingoogleworkspace/cli - Includes
gws schema,--dry-run, and JSON payload I/O
支持 --dry-run、Model Armor 净化选项与细粒度 OAuth/服务账号,但 Gmail 与 Drive 本身涉及高敏感个人与企业数据。
- Supports
--dry-runvalidation and scoped OAuth tokens - External email sending and Drive deletions carry high real-world impact
支持 npm/Rust 跨平台安装,但个人账号首次配置需要在 GCP 中启用对应 API 并完成 OAuth 授权。
- Distributed via
@googleworkspace/cliand Rust releases; requires GCP OAuth setup
单二进制通过 Discovery 动态覆盖 Gmail、Drive、Calendar、Sheets、Docs 与 Chat。
- Dynamic Discovery Service covers the entire Workspace API surface
Google Workspace 官方组织(googleworkspace/cli)以 Apache-2.0 积极维护。
- Hosted under official
googleworkspaceGitHub org
仓库内直接提供完整 README、Schema 自检与现成 Agent Skills。
- Repository includes agent skills and command examples
安全边界、鉴权与放权指南
使用本地加密凭据存储 / 系统钥匙串(gws auth login),或通过 GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE 传入服务账号 JSON。
CLI 以 Apache-2.0 开源免费;需配合 Google 账号 / GCP OAuth 客户端并受 Workspace API 配额限制。
# Google Workspace CLI (gws) Agent Rules - Always inspect unfamiliar methods with `gws schema <method>` first. - Pass `fields` in `--params` on list/get calls to minimize returned payload size. - Require `--dry-run` preview and explicit user approval before sending emails (`gmail`) or deleting Drive files.
Agent 高频安全命令配方
只读查询(安全推荐)
gws drive files list --params '{"pageSize": 10, "fields": "files(id,name,mimeType)"}' 通过 API fields 参数仅返回关键字段,防止冗余元数据撑爆上下文。
gws schema drive.files.list
直接从 Google Discovery 打印准确的请求与响应结构。
受控写入与预演
--dry-run 预演云盘创建请求 gws drive files create --json '{"name":"report.md"}' --dry-run 在本地校验 JSON 请求载荷而不真正执行远端写入。
核心优势
- + 原生随仓附带面向编码 Agent 的
SKILL.md与gws schema自省能力。 - + 一套工具统一操作 Drive、Gmail、Calendar、Sheets、Docs 与 Chat。
- +
--dry-run可在触达线上 API 前先验证写入载荷。
注意事项与踩坑点
- ! 首次登录需在 Google Cloud 项目中配置 OAuth 与启用相关 Workspace API。
- ! 切勿向全自动无人值守循环授予无约束的 Gmail 发信或 Drive 删除权限。