← 返回 Skills 市场
swaylq

Google Workspace (gws CLI)

作者 Sway Liu · GitHub ↗ · v1.1.0
cross-platform ⚠ suspicious
1159
总下载
1
收藏
1
当前安装
2
版本数
在 OpenClaw 中安装
/install gws-workspace
功能描述
Manage Google Workspace via the `gws` CLI — Drive, Gmail, Calendar, Sheets, Docs, Chat, Admin, Tasks, Meet, Slides, Forms, Contacts, and every other Workspac...
使用说明 (SKILL.md)

Google Workspace Skill

Operate all Google Workspace services through the gws CLI from OpenClaw.

Prerequisites

  • Node.js 18+
  • A Google Cloud project with OAuth credentials
  • gws CLI installed: npm install -g @googleworkspace/cli

Authentication

First-time setup (machine with browser)

gws auth setup        # creates GCP project, enables APIs, logs in
gws auth login -s drive,gmail,sheets,calendar   # pick services you need

Headless server (no browser)

Complete auth on a machine with a browser, then export:

gws auth export --unmasked > credentials.json

Security notes:

  • Set file permissions: chmod 600 credentials.json
  • Do not commit credential files to git — add credentials.json to your .gitignore
  • For production environments, prefer using a service account instead of user credentials

On the headless server:

export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/credentials.json

Service account

export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/service-account.json

Pre-obtained token

export GOOGLE_WORKSPACE_CLI_TOKEN=$(gcloud auth print-access-token)

Priority: Token env > Credentials file env > gws auth login store > plaintext file.

Command Pattern

gws \x3Cservice> \x3Cresource> \x3Cmethod> [--params '{}'] [--json '{}'] [flags]

All responses are structured JSON. Use jq for extraction.

Global Flags

Flag Purpose
--dry-run Preview request without executing
--page-all Stream all pages as NDJSON
--fields 'a,b' Select response fields
--output table Table output for humans

Discover commands

gws --help              # list all services
gws drive --help        # list resources in a service
gws drive files --help  # list methods on a resource
gws schema drive.files.list  # full request/response schema

Common Operations

Drive

# List recent files
gws drive files list --params '{"pageSize": 10}'

# Search files
gws drive files list --params '{"q": "name contains '\''report'\''", "pageSize": 20}'

# Upload a file
gws drive +upload ./report.pdf

# Download a file
gws drive files get --params '{"fileId": "FILE_ID", "alt": "media"}' > output.pdf

# Create a folder
gws drive files create --json '{"name": "Project", "mimeType": "application/vnd.google-apps.folder"}'

# Share a file
gws drive permissions create \
  --params '{"fileId": "FILE_ID"}' \
  --json '{"role": "reader", "type": "user", "emailAddress": "[email protected]"}'

# List all pages
gws drive files list --params '{"pageSize": 100}' --page-all | jq -r '.files[].name'

Gmail

# List inbox messages
gws gmail users-messages list --params '{"userId": "me", "maxResults": 10}'

# Read a message
gws gmail users-messages get --params '{"userId": "me", "id": "MSG_ID"}'

# Send an email
gws gmail users-messages send \
  --params '{"userId": "me"}' \
  --json '{"raw": "BASE64_ENCODED_EMAIL"}'

# Search messages
gws gmail users-messages list --params '{"userId": "me", "q": "from:[email protected] is:unread"}'

# List labels
gws gmail users-labels list --params '{"userId": "me"}'

# Create a filter
gws gmail users-settings-filters create \
  --params '{"userId": "me"}' \
  --json '{"criteria": {"from": "[email protected]"}, "action": {"addLabelIds": ["LABEL_ID"], "removeLabelIds": ["INBOX"]}}'

Calendar

# List upcoming events
gws calendar events list --params '{"calendarId": "primary", "timeMin": "2026-01-01T00:00:00Z", "maxResults": 10, "orderBy": "startTime", "singleEvents": true}'

# Create an event
gws calendar events insert \
  --params '{"calendarId": "primary"}' \
  --json '{"summary": "Team Sync", "start": {"dateTime": "2026-03-07T10:00:00+08:00"}, "end": {"dateTime": "2026-03-07T11:00:00+08:00"}, "attendees": [{"email": "[email protected]"}]}'

# Delete an event
gws calendar events delete --params '{"calendarId": "primary", "eventId": "EVENT_ID"}'

# Find free/busy slots
gws calendar freebusy query \
  --json '{"timeMin": "2026-03-07T00:00:00Z", "timeMax": "2026-03-07T23:59:59Z", "items": [{"id": "[email protected]"}]}'

Sheets

# Create a spreadsheet
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'

# Read cell values
gws sheets spreadsheets-values get --params '{"spreadsheetId": "SHEET_ID", "range": "Sheet1!A1:D10"}'

# Write values
gws sheets spreadsheets-values update \
  --params '{"spreadsheetId": "SHEET_ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' \
  --json '{"values": [["Name", "Amount"], ["Rent", "2000"]]}'

# Append a row
gws sheets spreadsheets-values append \
  --params '{"spreadsheetId": "SHEET_ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' \
  --json '{"values": [["New Item", "500"]]}'

Docs

# Create a document
gws docs documents create --json '{"title": "Meeting Notes"}'

# Get document content
gws docs documents get --params '{"documentId": "DOC_ID"}'

# Insert text (batchUpdate)
gws docs documents batchUpdate \
  --params '{"documentId": "DOC_ID"}' \
  --json '{"requests": [{"insertText": {"location": {"index": 1}, "text": "Hello World\
"}}]}'

Chat

# List spaces
gws chat spaces list

# Send a message
gws chat spaces messages create \
  --params '{"parent": "spaces/SPACE_ID"}' \
  --json '{"text": "Deploy complete ✅"}'

Tasks

# List task lists
gws tasks tasklists list

# List tasks
gws tasks tasks list --params '{"tasklist": "TASKLIST_ID"}'

# Create a task
gws tasks tasks insert \
  --params '{"tasklist": "TASKLIST_ID"}' \
  --json '{"title": "Review PR", "due": "2026-03-10T00:00:00Z"}'

Admin (Directory)

# List users
gws admin users list --params '{"domain": "example.com"}'

# Get user details
gws admin users get --params '{"userKey": "[email protected]"}'

Workflow Patterns

Pipeline: Find → Process → Act

# Find unread emails from boss, extract subjects
gws gmail users-messages list --params '{"userId": "me", "q": "from:boss is:unread"}' \
  | jq -r '.messages[].id' \
  | while read id; do
      gws gmail users-messages get --params "{\"userId\": \"me\", \"id\": \"$id\"}" \
        | jq -r '.payload.headers[] | select(.name=="Subject") | .value'
    done

Dry-run first

Always use --dry-run before destructive operations:

gws drive files delete --params '{"fileId": "FILE_ID"}' --dry-run

Tips

  • Use gws schema \x3Cmethod> to discover exact parameter names and types.
  • All commands accept --params for URL/query parameters and --json for request body.
  • Pipe through jq for field extraction in agent pipelines.
  • Use --page-all for full result sets with automatic pagination.
  • Credentials are encrypted at rest (AES-256-GCM) with OS keyring.

Recipes

For 50+ ready-made workflow recipes (label & archive emails, organize Drive folders, schedule meetings, etc.), see the official recipe library.

Disclaimer

The gws CLI is not an officially supported Google product. It is a community/experimental tool. Use at your own discretion, and refer to the upstream repository for license and support details.

Troubleshooting

Issue Fix
gws: command not found npm install -g @googleworkspace/cli
Auth fails / scope error gws auth login -s drive,gmail (pick specific services)
"Access blocked" on login Add yourself as test user in GCP OAuth consent screen
Headless server Export creds from a desktop, set GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE
Rate limited Add delays between calls, reduce pageSize
安全使用建议
This skill wraps the third-party `gws` CLI and is generally coherent with its purpose, but: (1) verify the npm package and upstream repository before installing (confirm publisher, checksum, and repository code), (2) never commit exported credentials.json to source control and prefer a service account with least-privilege scopes, (3) only set GOOGLE_WORKSPACE_CLI_TOKEN or credential file env vars on machines you fully trust, (4) be cautious with batch/delete examples — test on non-production data first, and (5) avoid enabling `gws mcp` (MCP server) unless you understand who can connect to it because it exposes all Workspace operations to remote clients. If you want a safer setup: run the CLI inside an isolated environment, use service accounts with scoped permissions, and review the npm package source code before trusting it with org data.
功能分析
Type: OpenClaw Skill Name: gws-workspace Version: 1.1.0 The skill bundle is a comprehensive wrapper for the 'gws' CLI (@googleworkspace/cli), enabling an AI agent to manage Google Workspace services like Drive, Gmail, and Calendar. It provides structured instructions for authentication, API discovery, and common operations, including security best practices such as using service accounts and setting file permissions for credentials. No evidence of malicious intent, data exfiltration to unauthorized endpoints, or prompt injection was found; the broad permissions requested are consistent with the stated purpose of managing Workspace APIs.
能力评估
Purpose & Capability
Name and description map directly to the `gws` CLI and the install produces the `gws` binary; requested binary is exactly what the skill says it wraps. The claimed capabilities (Drive, Gmail, Calendar, Sheets, etc.) align with what the CLI exposes.
Instruction Scope
SKILL.md instructs the agent to read/write credential files, set environment variables, export unmasked credentials, and run destructive batch commands (e.g., delete files via xargs). It also documents running `gws mcp`, which exposes Workspace operations over an MCP server — increasing the attack surface. The instructions reference environment variables and filesystem paths that are not declared in the registry metadata.
Install Mechanism
The install spec installs an npm package (@googleworkspace/cli) which is a reasonable distribution method for this CLI but is higher risk than an instruction-only skill because arbitrary code will be written to disk and a global binary will be created. The README links to an upstream GitHub repo and explicitly states the CLI is not an officially supported Google product; you should verify the npm package and upstream source before installing.
Credentials
Registry metadata declares no required env vars, but the SKILL.md and references mention and require GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE, GOOGLE_WORKSPACE_CLI_TOKEN and other env variables (and .env file usage). The skill will operate with broad Workspace OAuth scopes if you grant them; ensure you only grant minimal scopes and use service accounts or domain-limited credentials where appropriate.
Persistence & Privilege
always:false and no explicit persistent modifications to other skills or system configs, which is good. However, the documented `gws mcp` server can expose Workspace operations to other agents/tools — this is effectively a network-exposed tool surface and should be enabled only when you understand and trust every client that can reach it.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install gws-workspace
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /gws-workspace 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.0
Fix chat command format, add security notes, add disclaimer, add .gitignore
v1.0.0
Initial release: Full Google Workspace CLI integration for OpenClaw agents. Covers Drive, Gmail, Calendar, Sheets, Docs, Chat, Tasks, Admin, Meet, Slides, Forms, Contacts, and all other Workspace APIs via the gws CLI. Includes auth setup guides, common operations, workflow patterns, and troubleshooting.
元数据
Slug gws-workspace
版本 1.1.0
许可证
累计安装 2
当前安装数 1
历史版本数 2
常见问题

Google Workspace (gws CLI) 是什么?

Manage Google Workspace via the `gws` CLI — Drive, Gmail, Calendar, Sheets, Docs, Chat, Admin, Tasks, Meet, Slides, Forms, Contacts, and every other Workspac... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 1159 次。

如何安装 Google Workspace (gws CLI)?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install gws-workspace」即可一键安装,无需额外配置。

Google Workspace (gws CLI) 是免费的吗?

是的,Google Workspace (gws CLI) 完全免费(开源免费),可自由下载、安装和使用。

Google Workspace (gws CLI) 支持哪些平台?

Google Workspace (gws CLI) 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Google Workspace (gws CLI)?

由 Sway Liu(@swaylq)开发并维护,当前版本 v1.1.0。

💬 留言讨论