Repository files navigation

gws

One CLI for all of Google Workspace — built for humans and AI agents.
Drive, Gmail, Calendar, and every Workspace API. Zero boilerplate. Structured JSON output. 40+ agent skills included.

Note

This is not an officially supported Google product.

npm versionlicenseCI statusinstall size


npm install -g @googleworkspace/cli

gws doesn't ship a static list of commands. It reads Google's own Discovery Service at runtime and builds its entire command surface dynamically. When Google Workspace adds an API endpoint or method, gws picks it up automatically.

Important

This project is under active development. Expect breaking changes as we march toward v1.0.

Contents

Prerequisites

  • Node.js 18+ — for npm install (or download a pre-built binary from GitHub Releases)
  • A Google Cloud project — required for OAuth credentials. You can create one via the Google Cloud Console or with the gcloud CLI or with the gws auth setup command.
  • A Google account with access to Google Workspace

Installation

npm install -g @googleworkspace/cli

The npm package bundles pre-built native binaries for your OS and architecture. No Rust toolchain required.

Pre-built binaries are also available on the GitHub Releases page.

Or build from source:

cargo install --git https://github.com/googleworkspace/cli --locked

A Nix flake is also available at github:googleworkspace/cli

nix run github:googleworkspace/cli

Quick Start

gws auth setup # walks you through Google Cloud project config
gws auth login # subsequent OAuth login
gws drive files list --params '{"pageSize": 5}'

Why gws?

For humans — stop writing curl calls against REST docs. gws gives you --help on every resource, --dry-run to preview requests, and auto‑pagination.

For AI agents — every response is structured JSON. Pair it with the included agent skills and your LLM can manage Workspace without custom tooling.

# List the 10 most recent files
gws drive files list --params '{"pageSize": 10}'# Create a spreadsheet
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'# Send a Chat message
gws chat spaces messages create \
--params '{"parent": "spaces/xyz"}' \
--json '{"text": "Deploy complete."}' \
--dry-run
# Introspect any method's request/response schema
gws schema drive.files.list
# Stream paginated results as NDJSON
gws drive files list --params '{"pageSize": 100}' --page-all | jq -r '.files[].name'

Authentication

The CLI supports multiple auth workflows so it works on your laptop, in CI, and on a server.

Which setup should I use?

I have…Use
gcloud installed and authenticatedgws auth setup (fastest)
A GCP project but no gcloudManual OAuth setup
An existing OAuth access tokenGOOGLE_WORKSPACE_CLI_TOKEN
Existing CredentialsGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE

Interactive (local desktop)

Credentials are encrypted at rest (AES-256-GCM) with the key stored in your OS keyring.

gws auth setup # one-time: creates a Cloud project, enables APIs, logs you in
gws auth login # subsequent scope selection and login

gws auth setup requires the gcloud CLI. If you don't have gcloud, use the manual setup below instead.

Warning

Scope limits in testing mode: If your OAuth app is unverified (testing mode), Google limits consent to ~25 scopes. The recommended scope preset includes 85+ scopes and will fail for unverified apps (especially for @gmail.com accounts). Choose individual services instead to filter the scope picker:

gws auth login -s drive,gmail,sheets

Multiple accounts

You can authenticate with more than one Google account and switch between them:

gws auth login --account work@corp.com # login and register an account
gws auth login --account personal@gmail.com
gws auth list # list registered accounts
gws auth default work@corp.com. # set the default
gws --account personal@gmail.com drive files list # one-off overrideexport GOOGLE_WORKSPACE_CLI_ACCOUNT=personal@gmail.com # env var override

Credentials are stored per-account as credentials.<b64-email>.enc in ~/.config/gws/, with an accounts.json registry tracking defaults.

Manual OAuth setup (Google Cloud Console)

Use this when gws auth setup cannot automate project/client creation, or when you want explicit control.

  1. Open Google Cloud Console in the target project:
    • OAuth consent screen: https://console.cloud.google.com/apis/credentials/consent?project=<PROJECT_ID>
    • Credentials: https://console.cloud.google.com/apis/credentials?project=<PROJECT_ID>
  2. Configure OAuth branding/audience if prompted:
    • App type: External (testing mode is fine)
  3. Add your account under Test users
  4. Create an OAuth client:
    • Type: Desktop app
  5. Download the client JSON and save it to:
    • ~/.config/gws/client_secret.json

Important

You must add yourself as a test user. In the OAuth consent screen, click Test users → Add users and enter your Google account email. Without this, login will fail with a generic "Access blocked" error.

Then run:

gws auth login

Browser-assisted auth (human or agent)

You can complete OAuth either manually or with browser automation.

  • Human flow: run gws auth login, open the printed URL, approve scopes.
  • Agent-assisted flow: the agent opens the URL, selects account, handles consent prompts, and returns control once the localhost callback succeeds.

If consent shows "Google hasn't verified this app" (testing mode), click Continue. If scope checkboxes appear, select required scopes (or Select all) before continuing.

Headless / CI (export flow)

  1. Complete interactive auth on a machine with a browser.
  2. Export credentials:
    gws auth export --unmasked > credentials.json
  3. On the headless machine:
    export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/credentials.json
    gws drive files list # just works

Service Account (server-to-server)

Point to your key file; no login needed.

export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/service-account.json
gws drive files list

For Domain-Wide Delegation, add:

export GOOGLE_WORKSPACE_CLI_IMPERSONATED_USER=admin@example.com

Pre-obtained Access Token

Useful when another tool (e.g. gcloud) already mints tokens for your environment.

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

Precedence

PrioritySourceSet via
1Access tokenGOOGLE_WORKSPACE_CLI_TOKEN
2Credentials fileGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE
3Per-account encrypted credentialsgws auth login --account EMAIL
4Plaintext credentials~/.config/gws/credentials.json

Account resolution: --account flag > GOOGLE_WORKSPACE_CLI_ACCOUNT env var > default in accounts.json.

Environment variables can also live in a .env file.

AI Agent Skills

The repo ships 100+ Agent Skills (SKILL.md files) — one for every supported API, plus higher-level helpers for common workflows and 50 curated recipes for Gmail, Drive, Docs, Calendar, and Sheets. See the full Skills Index for the complete list.

# Install all skills at once
npx skills add https://github.com/googleworkspace/cli
# Or pick only what you need
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-drive
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-gmail
OpenClaw setup
# Symlink all skills (stays in sync with repo)
ln -s $(pwd)/skills/gws-*~/.openclaw/skills/
# Or copy specific skills
cp -r skills/gws-drive skills/gws-gmail ~/.openclaw/skills/

The gws-shared skill includes an install block so OpenClaw auto-installs the CLI via npm if gws isn't on PATH.

Gemini CLI Extension

  1. Authenticate the CLI first:

    gws auth setup
  2. Install the extension into the Gemini CLI:

    gemini extensions install https://github.com/googleworkspace/cli

Installing this extension gives your Gemini CLI agent direct access to all gws commands and Google Workspace agent skills. Because gws handles its own authentication securely, you simply need to authenticate your terminal once prior to using the agent, and the extension will automatically inherit your credentials.

MCP Server

gws mcp starts a Model Context Protocol server over stdio, exposing Google Workspace APIs as structured tools that any MCP-compatible client (Claude Desktop, Gemini CLI, VS Code, etc.) can call.

gws mcp -s drive # expose Drive tools
gws mcp -s drive,gmail,calendar # expose multiple services
gws mcp -s all # expose all services (many tools!)

Configure in your MCP client:

{
"mcpServers": {
"gws": {
"command": "gws",
"args": ["mcp", "-s", "drive,gmail,calendar"]
}
}
}

Tip

Each service adds roughly 10–80 tools. Keep the list to what you actually need to stay under your client's tool limit (typically 50–100 tools).

FlagDescription
-s, --services <list>Comma-separated services to expose, or all
-w, --workflowsAlso expose workflow tools
-e, --helpersAlso expose helper tools

Advanced Usage

Multipart Uploads

gws drive files create --json '{"name": "report.pdf"}' --upload ./report.pdf

Pagination

FlagDescriptionDefault
--page-allAuto-paginate, one JSON line per page (NDJSON)off
--page-limit <N>Max pages to fetch10
--page-delay <MS>Delay between pages100 ms

Google Sheets — Shell Escaping

Sheets ranges use ! which bash interprets as history expansion. Always wrap values in single quotes:

# Read cells A1:C10 from "Sheet1"
gws sheets spreadsheets values get \
--params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1:C10"}'# Append rows
gws sheets spreadsheets values append \
--params '{"spreadsheetId": "ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' \
--json '{"values": [["Name", "Score"], ["Alice", 95]]}'

Model Armor (Response Sanitization)

Integrate Google Cloud Model Armor to scan API responses for prompt injection before they reach your agent.

gws gmail users messages get --params '...' \
--sanitize "projects/P/locations/L/templates/T"
VariableDescription
GOOGLE_WORKSPACE_CLI_SANITIZE_TEMPLATEDefault Model Armor template
GOOGLE_WORKSPACE_CLI_SANITIZE_MODEwarn (default) or block

Architecture

gws uses a two-phase parsing strategy:

  1. Read argv[1] to identify the service (e.g. drive)
  2. Fetch the service's Discovery Document (cached 24 h)
  3. Build a clap::Command tree from the document's resources and methods
  4. Re-parse the remaining arguments
  5. Authenticate, build the HTTP request, execute

All output — success, errors, download metadata — is structured JSON.

Troubleshooting

"Access blocked" or 403 during login

Your OAuth app is in testing mode and your account is not listed as a test user.

Fix: Open the OAuth consent screen in your GCP project → Test usersAdd users → enter your Google account email. Then retry gws auth login.

"Google hasn't verified this app"

Expected when your app is in testing mode. Click AdvancedGo to <app name> (unsafe) to proceed. This is safe for personal use; verification is only required to publish the app to other users.

Too many scopes / consent screen error

Unverified (testing mode) apps are limited to ~25 OAuth scopes. The recommended scope preset includes many scopes and will exceed this limit.

Fix: Select only the scopes you need:

gws auth login --scopes drive,gmail,calendar

gcloud CLI not found

gws auth setup requires the gcloud CLI to automate project creation. You have three options:

  1. Install gcloud and use gcloud directly.
  2. Re-run gws auth setup which wraps gcloud calls.
  3. Skip gcloud entirely — set up OAuth credentials manually in the Cloud Console

redirect_uri_mismatch

The OAuth client was not created as a Desktop app type. In the Credentials page, delete the existing client, create a new one with type Desktop app, and download the new JSON.

API not enabled — accessNotConfigured

If a required Google API is not enabled for your GCP project, you will see a 403 error with reason accessNotConfigured:

{
"error": {
"code": 403,
"message": "Gmail API has not been used in project 549352339482 ...",
"reason": "accessNotConfigured",
"enable_url": "https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482"
}
}

gws also prints an actionable hint to stderr:

💡 API not enabled for your GCP project.
Enable it at: https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482
After enabling, wait a few seconds and retry your command.

Steps to fix:

  1. Click the enable_url link (or copy it from the enable_url JSON field).
  2. In the GCP Console, click Enable.
  3. Wait ~10 seconds, then retry your gws command.

Tip

You can also run gws auth setup which walks you through enabling all required APIs for your project automatically.

Development

cargo build # dev build
cargo clippy -- -D warnings # lint
cargo test# unit tests
./scripts/coverage.sh # HTML coverage report → target/llvm-cov/html/

License

Apache-2.0

Disclaimer

Caution

This is not an officially supported Google product.

About

Google Workspace CLI — one command-line tool for Drive, Gmail, Calendar, Sheets, Docs, Chat, Admin, and more. Dynamically built from Google Discovery Service. Includes AI agent skills.

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

gws

One CLI for all of Google Workspace — built for humans and AI agents.
Drive, Gmail, Calendar, and every Workspace API. Zero boilerplate. Structured JSON output. 40+ agent skills included.

Note

This is not an officially supported Google product.

npm versionlicenseCI statusinstall size


npm install -g @googleworkspace/cli

gws doesn't ship a static list of commands. It reads Google's own Discovery Service at runtime and builds its entire command surface dynamically. When Google Workspace adds an API endpoint or method, gws picks it up automatically.

Important

This project is under active development. Expect breaking changes as we march toward v1.0.

Contents

Prerequisites

  • Node.js 18+ — for npm install (or download a pre-built binary from GitHub Releases)
  • A Google Cloud project — required for OAuth credentials. You can create one via the Google Cloud Console or with the gcloud CLI or with the gws auth setup command.
  • A Google account with access to Google Workspace

Installation

npm install -g @googleworkspace/cli

The npm package bundles pre-built native binaries for your OS and architecture. No Rust toolchain required.

Pre-built binaries are also available on the GitHub Releases page.

Or build from source:

cargo install --git https://github.com/googleworkspace/cli --locked

A Nix flake is also available at github:googleworkspace/cli

nix run github:googleworkspace/cli

Quick Start

gws auth setup # walks you through Google Cloud project config
gws auth login # subsequent OAuth login
gws drive files list --params '{"pageSize": 5}'

Why gws?

For humans — stop writing curl calls against REST docs. gws gives you --help on every resource, --dry-run to preview requests, and auto‑pagination.

For AI agents — every response is structured JSON. Pair it with the included agent skills and your LLM can manage Workspace without custom tooling.

# List the 10 most recent files
gws drive files list --params '{"pageSize": 10}'# Create a spreadsheet
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'# Send a Chat message
gws chat spaces messages create \
--params '{"parent": "spaces/xyz"}' \
--json '{"text": "Deploy complete."}' \
--dry-run
# Introspect any method's request/response schema
gws schema drive.files.list
# Stream paginated results as NDJSON
gws drive files list --params '{"pageSize": 100}' --page-all | jq -r '.files[].name'

Authentication

The CLI supports multiple auth workflows so it works on your laptop, in CI, and on a server.

Which setup should I use?

I have…Use
gcloud installed and authenticatedgws auth setup (fastest)
A GCP project but no gcloudManual OAuth setup
An existing OAuth access tokenGOOGLE_WORKSPACE_CLI_TOKEN
Existing CredentialsGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE

Interactive (local desktop)

Credentials are encrypted at rest (AES-256-GCM) with the key stored in your OS keyring.

gws auth setup # one-time: creates a Cloud project, enables APIs, logs you in
gws auth login # subsequent scope selection and login

gws auth setup requires the gcloud CLI. If you don't have gcloud, use the manual setup below instead.

Warning

Scope limits in testing mode: If your OAuth app is unverified (testing mode), Google limits consent to ~25 scopes. The recommended scope preset includes 85+ scopes and will fail for unverified apps (especially for @gmail.com accounts). Choose individual services instead to filter the scope picker:

gws auth login -s drive,gmail,sheets

Multiple accounts

You can authenticate with more than one Google account and switch between them:

gws auth login --account work@corp.com # login and register an account
gws auth login --account personal@gmail.com
gws auth list # list registered accounts
gws auth default work@corp.com. # set the default
gws --account personal@gmail.com drive files list # one-off overrideexport GOOGLE_WORKSPACE_CLI_ACCOUNT=personal@gmail.com # env var override

Credentials are stored per-account as credentials.<b64-email>.enc in ~/.config/gws/, with an accounts.json registry tracking defaults.

Manual OAuth setup (Google Cloud Console)

Use this when gws auth setup cannot automate project/client creation, or when you want explicit control.

  1. Open Google Cloud Console in the target project:
    • OAuth consent screen: https://console.cloud.google.com/apis/credentials/consent?project=<PROJECT_ID>
    • Credentials: https://console.cloud.google.com/apis/credentials?project=<PROJECT_ID>
  2. Configure OAuth branding/audience if prompted:
    • App type: External (testing mode is fine)
  3. Add your account under Test users
  4. Create an OAuth client:
    • Type: Desktop app
  5. Download the client JSON and save it to:
    • ~/.config/gws/client_secret.json

Important

You must add yourself as a test user. In the OAuth consent screen, click Test users → Add users and enter your Google account email. Without this, login will fail with a generic "Access blocked" error.

Then run:

gws auth login

Browser-assisted auth (human or agent)

You can complete OAuth either manually or with browser automation.

  • Human flow: run gws auth login, open the printed URL, approve scopes.
  • Agent-assisted flow: the agent opens the URL, selects account, handles consent prompts, and returns control once the localhost callback succeeds.

If consent shows "Google hasn't verified this app" (testing mode), click Continue. If scope checkboxes appear, select required scopes (or Select all) before continuing.

Headless / CI (export flow)

  1. Complete interactive auth on a machine with a browser.
  2. Export credentials:
    gws auth export --unmasked > credentials.json
  3. On the headless machine:
    export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/credentials.json
    gws drive files list # just works

Service Account (server-to-server)

Point to your key file; no login needed.

export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/service-account.json
gws drive files list

For Domain-Wide Delegation, add:

export GOOGLE_WORKSPACE_CLI_IMPERSONATED_USER=admin@example.com

Pre-obtained Access Token

Useful when another tool (e.g. gcloud) already mints tokens for your environment.

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

Precedence

PrioritySourceSet via
1Access tokenGOOGLE_WORKSPACE_CLI_TOKEN
2Credentials fileGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE
3Per-account encrypted credentialsgws auth login --account EMAIL
4Plaintext credentials~/.config/gws/credentials.json

Account resolution: --account flag > GOOGLE_WORKSPACE_CLI_ACCOUNT env var > default in accounts.json.

Environment variables can also live in a .env file.

AI Agent Skills

The repo ships 100+ Agent Skills (SKILL.md files) — one for every supported API, plus higher-level helpers for common workflows and 50 curated recipes for Gmail, Drive, Docs, Calendar, and Sheets. See the full Skills Index for the complete list.

# Install all skills at once
npx skills add https://github.com/googleworkspace/cli
# Or pick only what you need
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-drive
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-gmail
OpenClaw setup
# Symlink all skills (stays in sync with repo)
ln -s $(pwd)/skills/gws-*~/.openclaw/skills/
# Or copy specific skills
cp -r skills/gws-drive skills/gws-gmail ~/.openclaw/skills/

The gws-shared skill includes an install block so OpenClaw auto-installs the CLI via npm if gws isn't on PATH.

Gemini CLI Extension

  1. Authenticate the CLI first:

    gws auth setup
  2. Install the extension into the Gemini CLI:

    gemini extensions install https://github.com/googleworkspace/cli

Installing this extension gives your Gemini CLI agent direct access to all gws commands and Google Workspace agent skills. Because gws handles its own authentication securely, you simply need to authenticate your terminal once prior to using the agent, and the extension will automatically inherit your credentials.

MCP Server

gws mcp starts a Model Context Protocol server over stdio, exposing Google Workspace APIs as structured tools that any MCP-compatible client (Claude Desktop, Gemini CLI, VS Code, etc.) can call.

gws mcp -s drive # expose Drive tools
gws mcp -s drive,gmail,calendar # expose multiple services
gws mcp -s all # expose all services (many tools!)

Configure in your MCP client:

{
"mcpServers": {
"gws": {
"command": "gws",
"args": ["mcp", "-s", "drive,gmail,calendar"]
}
}
}

Tip

Each service adds roughly 10–80 tools. Keep the list to what you actually need to stay under your client's tool limit (typically 50–100 tools).

FlagDescription
-s, --services <list>Comma-separated services to expose, or all
-w, --workflowsAlso expose workflow tools
-e, --helpersAlso expose helper tools

Advanced Usage

Multipart Uploads

gws drive files create --json '{"name": "report.pdf"}' --upload ./report.pdf

Pagination

FlagDescriptionDefault
--page-allAuto-paginate, one JSON line per page (NDJSON)off
--page-limit <N>Max pages to fetch10
--page-delay <MS>Delay between pages100 ms

Google Sheets — Shell Escaping

Sheets ranges use ! which bash interprets as history expansion. Always wrap values in single quotes:

# Read cells A1:C10 from "Sheet1"
gws sheets spreadsheets values get \
--params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1:C10"}'# Append rows
gws sheets spreadsheets values append \
--params '{"spreadsheetId": "ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' \
--json '{"values": [["Name", "Score"], ["Alice", 95]]}'

Model Armor (Response Sanitization)

Integrate Google Cloud Model Armor to scan API responses for prompt injection before they reach your agent.

gws gmail users messages get --params '...' \
--sanitize "projects/P/locations/L/templates/T"
VariableDescription
GOOGLE_WORKSPACE_CLI_SANITIZE_TEMPLATEDefault Model Armor template
GOOGLE_WORKSPACE_CLI_SANITIZE_MODEwarn (default) or block

Architecture

gws uses a two-phase parsing strategy:

  1. Read argv[1] to identify the service (e.g. drive)
  2. Fetch the service's Discovery Document (cached 24 h)
  3. Build a clap::Command tree from the document's resources and methods
  4. Re-parse the remaining arguments
  5. Authenticate, build the HTTP request, execute

All output — success, errors, download metadata — is structured JSON.

Troubleshooting

"Access blocked" or 403 during login

Your OAuth app is in testing mode and your account is not listed as a test user.

Fix: Open the OAuth consent screen in your GCP project → Test usersAdd users → enter your Google account email. Then retry gws auth login.

"Google hasn't verified this app"

Expected when your app is in testing mode. Click AdvancedGo to <app name> (unsafe) to proceed. This is safe for personal use; verification is only required to publish the app to other users.

Too many scopes / consent screen error

Unverified (testing mode) apps are limited to ~25 OAuth scopes. The recommended scope preset includes many scopes and will exceed this limit.

Fix: Select only the scopes you need:

gws auth login --scopes drive,gmail,calendar

gcloud CLI not found

gws auth setup requires the gcloud CLI to automate project creation. You have three options:

  1. Install gcloud and use gcloud directly.
  2. Re-run gws auth setup which wraps gcloud calls.
  3. Skip gcloud entirely — set up OAuth credentials manually in the Cloud Console

redirect_uri_mismatch

The OAuth client was not created as a Desktop app type. In the Credentials page, delete the existing client, create a new one with type Desktop app, and download the new JSON.

API not enabled — accessNotConfigured

If a required Google API is not enabled for your GCP project, you will see a 403 error with reason accessNotConfigured:

{
"error": {
"code": 403,
"message": "Gmail API has not been used in project 549352339482 ...",
"reason": "accessNotConfigured",
"enable_url": "https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482"
}
}

gws also prints an actionable hint to stderr:

💡 API not enabled for your GCP project.
Enable it at: https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482
After enabling, wait a few seconds and retry your command.

Steps to fix:

  1. Click the enable_url link (or copy it from the enable_url JSON field).
  2. In the GCP Console, click Enable.
  3. Wait ~10 seconds, then retry your gws command.

Tip

You can also run gws auth setup which walks you through enabling all required APIs for your project automatically.

Development

cargo build # dev build
cargo clippy -- -D warnings # lint
cargo test# unit tests
./scripts/coverage.sh # HTML coverage report → target/llvm-cov/html/

License

Apache-2.0

Disclaimer

Caution

This is not an officially supported Google product.

About

Google Workspace CLI — one command-line tool for Drive, Gmail, Calendar, Sheets, Docs, Chat, Admin, and more. Dynamically built from Google Discovery Service. Includes AI agent skills.

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

gws

One CLI for all of Google Workspace — built for humans and AI agents.
Drive, Gmail, Calendar, and every Workspace API. Zero boilerplate. Structured JSON output. 40+ agent skills included.

Note

This is not an officially supported Google product.

npm versionlicenseCI statusinstall size


npm install -g @googleworkspace/cli

gws doesn't ship a static list of commands. It reads Google's own Discovery Service at runtime and builds its entire command surface dynamically. When Google Workspace adds an API endpoint or method, gws picks it up automatically.

Important

This project is under active development. Expect breaking changes as we march toward v1.0.

Contents

Prerequisites

  • Node.js 18+ — for npm install (or download a pre-built binary from GitHub Releases)
  • A Google Cloud project — required for OAuth credentials. You can create one via the Google Cloud Console or with the gcloud CLI or with the gws auth setup command.
  • A Google account with access to Google Workspace

Installation

npm install -g @googleworkspace/cli

The npm package bundles pre-built native binaries for your OS and architecture. No Rust toolchain required.

Pre-built binaries are also available on the GitHub Releases page.

Or build from source:

cargo install --git https://github.com/googleworkspace/cli --locked

A Nix flake is also available at github:googleworkspace/cli

nix run github:googleworkspace/cli

Quick Start

gws auth setup # walks you through Google Cloud project config
gws auth login # subsequent OAuth login
gws drive files list --params '{"pageSize": 5}'

Why gws?

For humans — stop writing curl calls against REST docs. gws gives you --help on every resource, --dry-run to preview requests, and auto‑pagination.

For AI agents — every response is structured JSON. Pair it with the included agent skills and your LLM can manage Workspace without custom tooling.

# List the 10 most recent files
gws drive files list --params '{"pageSize": 10}'# Create a spreadsheet
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'# Send a Chat message
gws chat spaces messages create \
--params '{"parent": "spaces/xyz"}' \
--json '{"text": "Deploy complete."}' \
--dry-run
# Introspect any method's request/response schema
gws schema drive.files.list
# Stream paginated results as NDJSON
gws drive files list --params '{"pageSize": 100}' --page-all | jq -r '.files[].name'

Authentication

The CLI supports multiple auth workflows so it works on your laptop, in CI, and on a server.

Which setup should I use?

I have…Use
gcloud installed and authenticatedgws auth setup (fastest)
A GCP project but no gcloudManual OAuth setup
An existing OAuth access tokenGOOGLE_WORKSPACE_CLI_TOKEN
Existing CredentialsGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE

Interactive (local desktop)

Credentials are encrypted at rest (AES-256-GCM) with the key stored in your OS keyring.

gws auth setup # one-time: creates a Cloud project, enables APIs, logs you in
gws auth login # subsequent scope selection and login

gws auth setup requires the gcloud CLI. If you don't have gcloud, use the manual setup below instead.

Warning

Scope limits in testing mode: If your OAuth app is unverified (testing mode), Google limits consent to ~25 scopes. The recommended scope preset includes 85+ scopes and will fail for unverified apps (especially for @gmail.com accounts). Choose individual services instead to filter the scope picker:

gws auth login -s drive,gmail,sheets

Multiple accounts

You can authenticate with more than one Google account and switch between them:

gws auth login --account work@corp.com # login and register an account
gws auth login --account personal@gmail.com
gws auth list # list registered accounts
gws auth default work@corp.com. # set the default
gws --account personal@gmail.com drive files list # one-off overrideexport GOOGLE_WORKSPACE_CLI_ACCOUNT=personal@gmail.com # env var override

Credentials are stored per-account as credentials.<b64-email>.enc in ~/.config/gws/, with an accounts.json registry tracking defaults.

Manual OAuth setup (Google Cloud Console)

Use this when gws auth setup cannot automate project/client creation, or when you want explicit control.

  1. Open Google Cloud Console in the target project:
    • OAuth consent screen: https://console.cloud.google.com/apis/credentials/consent?project=<PROJECT_ID>
    • Credentials: https://console.cloud.google.com/apis/credentials?project=<PROJECT_ID>
  2. Configure OAuth branding/audience if prompted:
    • App type: External (testing mode is fine)
  3. Add your account under Test users
  4. Create an OAuth client:
    • Type: Desktop app
  5. Download the client JSON and save it to:
    • ~/.config/gws/client_secret.json

Important

You must add yourself as a test user. In the OAuth consent screen, click Test users → Add users and enter your Google account email. Without this, login will fail with a generic "Access blocked" error.

Then run:

gws auth login

Browser-assisted auth (human or agent)

You can complete OAuth either manually or with browser automation.

  • Human flow: run gws auth login, open the printed URL, approve scopes.
  • Agent-assisted flow: the agent opens the URL, selects account, handles consent prompts, and returns control once the localhost callback succeeds.

If consent shows "Google hasn't verified this app" (testing mode), click Continue. If scope checkboxes appear, select required scopes (or Select all) before continuing.

Headless / CI (export flow)

  1. Complete interactive auth on a machine with a browser.
  2. Export credentials:
    gws auth export --unmasked > credentials.json
  3. On the headless machine:
    export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/credentials.json
    gws drive files list # just works

Service Account (server-to-server)

Point to your key file; no login needed.

export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/service-account.json
gws drive files list

For Domain-Wide Delegation, add:

export GOOGLE_WORKSPACE_CLI_IMPERSONATED_USER=admin@example.com

Pre-obtained Access Token

Useful when another tool (e.g. gcloud) already mints tokens for your environment.

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

Precedence

PrioritySourceSet via
1Access tokenGOOGLE_WORKSPACE_CLI_TOKEN
2Credentials fileGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE
3Per-account encrypted credentialsgws auth login --account EMAIL
4Plaintext credentials~/.config/gws/credentials.json

Account resolution: --account flag > GOOGLE_WORKSPACE_CLI_ACCOUNT env var > default in accounts.json.

Environment variables can also live in a .env file.

AI Agent Skills

The repo ships 100+ Agent Skills (SKILL.md files) — one for every supported API, plus higher-level helpers for common workflows and 50 curated recipes for Gmail, Drive, Docs, Calendar, and Sheets. See the full Skills Index for the complete list.

# Install all skills at once
npx skills add https://github.com/googleworkspace/cli
# Or pick only what you need
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-drive
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-gmail
OpenClaw setup
# Symlink all skills (stays in sync with repo)
ln -s $(pwd)/skills/gws-*~/.openclaw/skills/
# Or copy specific skills
cp -r skills/gws-drive skills/gws-gmail ~/.openclaw/skills/

The gws-shared skill includes an install block so OpenClaw auto-installs the CLI via npm if gws isn't on PATH.

Gemini CLI Extension

  1. Authenticate the CLI first:

    gws auth setup
  2. Install the extension into the Gemini CLI:

    gemini extensions install https://github.com/googleworkspace/cli

Installing this extension gives your Gemini CLI agent direct access to all gws commands and Google Workspace agent skills. Because gws handles its own authentication securely, you simply need to authenticate your terminal once prior to using the agent, and the extension will automatically inherit your credentials.

MCP Server

gws mcp starts a Model Context Protocol server over stdio, exposing Google Workspace APIs as structured tools that any MCP-compatible client (Claude Desktop, Gemini CLI, VS Code, etc.) can call.

gws mcp -s drive # expose Drive tools
gws mcp -s drive,gmail,calendar # expose multiple services
gws mcp -s all # expose all services (many tools!)

Configure in your MCP client:

{
"mcpServers": {
"gws": {
"command": "gws",
"args": ["mcp", "-s", "drive,gmail,calendar"]
}
}
}

Tip

Each service adds roughly 10–80 tools. Keep the list to what you actually need to stay under your client's tool limit (typically 50–100 tools).

FlagDescription
-s, --services <list>Comma-separated services to expose, or all
-w, --workflowsAlso expose workflow tools
-e, --helpersAlso expose helper tools

Advanced Usage

Multipart Uploads

gws drive files create --json '{"name": "report.pdf"}' --upload ./report.pdf

Pagination

FlagDescriptionDefault
--page-allAuto-paginate, one JSON line per page (NDJSON)off
--page-limit <N>Max pages to fetch10
--page-delay <MS>Delay between pages100 ms

Google Sheets — Shell Escaping

Sheets ranges use ! which bash interprets as history expansion. Always wrap values in single quotes:

# Read cells A1:C10 from "Sheet1"
gws sheets spreadsheets values get \
--params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1:C10"}'# Append rows
gws sheets spreadsheets values append \
--params '{"spreadsheetId": "ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' \
--json '{"values": [["Name", "Score"], ["Alice", 95]]}'

Model Armor (Response Sanitization)

Integrate Google Cloud Model Armor to scan API responses for prompt injection before they reach your agent.

gws gmail users messages get --params '...' \
--sanitize "projects/P/locations/L/templates/T"
VariableDescription
GOOGLE_WORKSPACE_CLI_SANITIZE_TEMPLATEDefault Model Armor template
GOOGLE_WORKSPACE_CLI_SANITIZE_MODEwarn (default) or block

Architecture

gws uses a two-phase parsing strategy:

  1. Read argv[1] to identify the service (e.g. drive)
  2. Fetch the service's Discovery Document (cached 24 h)
  3. Build a clap::Command tree from the document's resources and methods
  4. Re-parse the remaining arguments
  5. Authenticate, build the HTTP request, execute

All output — success, errors, download metadata — is structured JSON.

Troubleshooting

"Access blocked" or 403 during login

Your OAuth app is in testing mode and your account is not listed as a test user.

Fix: Open the OAuth consent screen in your GCP project → Test usersAdd users → enter your Google account email. Then retry gws auth login.

"Google hasn't verified this app"

Expected when your app is in testing mode. Click AdvancedGo to <app name> (unsafe) to proceed. This is safe for personal use; verification is only required to publish the app to other users.

Too many scopes / consent screen error

Unverified (testing mode) apps are limited to ~25 OAuth scopes. The recommended scope preset includes many scopes and will exceed this limit.

Fix: Select only the scopes you need:

gws auth login --scopes drive,gmail,calendar

gcloud CLI not found

gws auth setup requires the gcloud CLI to automate project creation. You have three options:

  1. Install gcloud and use gcloud directly.
  2. Re-run gws auth setup which wraps gcloud calls.
  3. Skip gcloud entirely — set up OAuth credentials manually in the Cloud Console

redirect_uri_mismatch

The OAuth client was not created as a Desktop app type. In the Credentials page, delete the existing client, create a new one with type Desktop app, and download the new JSON.

API not enabled — accessNotConfigured

If a required Google API is not enabled for your GCP project, you will see a 403 error with reason accessNotConfigured:

{
"error": {
"code": 403,
"message": "Gmail API has not been used in project 549352339482 ...",
"reason": "accessNotConfigured",
"enable_url": "https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482"
}
}

gws also prints an actionable hint to stderr:

💡 API not enabled for your GCP project.
Enable it at: https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482
After enabling, wait a few seconds and retry your command.

Steps to fix:

  1. Click the enable_url link (or copy it from the enable_url JSON field).
  2. In the GCP Console, click Enable.
  3. Wait ~10 seconds, then retry your gws command.

Tip

You can also run gws auth setup which walks you through enabling all required APIs for your project automatically.

Development

cargo build # dev build
cargo clippy -- -D warnings # lint
cargo test# unit tests
./scripts/coverage.sh # HTML coverage report → target/llvm-cov/html/

License

Apache-2.0

Disclaimer

Caution

This is not an officially supported Google product.

About

Google Workspace CLI — one command-line tool for Drive, Gmail, Calendar, Sheets, Docs, Chat, Admin, and more. Dynamically built from Google Discovery Service. Includes AI agent skills.

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

gws

One CLI for all of Google Workspace — built for humans and AI agents.
Drive, Gmail, Calendar, and every Workspace API. Zero boilerplate. Structured JSON output. 40+ agent skills included.

Note

This is not an officially supported Google product.

npm versionlicenseCI statusinstall size


npm install -g @googleworkspace/cli

gws doesn't ship a static list of commands. It reads Google's own Discovery Service at runtime and builds its entire command surface dynamically. When Google Workspace adds an API endpoint or method, gws picks it up automatically.

Important

This project is under active development. Expect breaking changes as we march toward v1.0.

Contents

Prerequisites

  • Node.js 18+ — for npm install (or download a pre-built binary from GitHub Releases)
  • A Google Cloud project — required for OAuth credentials. You can create one via the Google Cloud Console or with the gcloud CLI or with the gws auth setup command.
  • A Google account with access to Google Workspace

Installation

npm install -g @googleworkspace/cli

The npm package bundles pre-built native binaries for your OS and architecture. No Rust toolchain required.

Pre-built binaries are also available on the GitHub Releases page.

Or build from source:

cargo install --git https://github.com/googleworkspace/cli --locked

A Nix flake is also available at github:googleworkspace/cli

nix run github:googleworkspace/cli

Quick Start

gws auth setup # walks you through Google Cloud project config
gws auth login # subsequent OAuth login
gws drive files list --params '{"pageSize": 5}'

Why gws?

For humans — stop writing curl calls against REST docs. gws gives you --help on every resource, --dry-run to preview requests, and auto‑pagination.

For AI agents — every response is structured JSON. Pair it with the included agent skills and your LLM can manage Workspace without custom tooling.

# List the 10 most recent files
gws drive files list --params '{"pageSize": 10}'# Create a spreadsheet
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'# Send a Chat message
gws chat spaces messages create \
--params '{"parent": "spaces/xyz"}' \
--json '{"text": "Deploy complete."}' \
--dry-run
# Introspect any method's request/response schema
gws schema drive.files.list
# Stream paginated results as NDJSON
gws drive files list --params '{"pageSize": 100}' --page-all | jq -r '.files[].name'

Authentication

The CLI supports multiple auth workflows so it works on your laptop, in CI, and on a server.

Which setup should I use?

I have…Use
gcloud installed and authenticatedgws auth setup (fastest)
A GCP project but no gcloudManual OAuth setup
An existing OAuth access tokenGOOGLE_WORKSPACE_CLI_TOKEN
Existing CredentialsGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE

Interactive (local desktop)

Credentials are encrypted at rest (AES-256-GCM) with the key stored in your OS keyring.

gws auth setup # one-time: creates a Cloud project, enables APIs, logs you in
gws auth login # subsequent scope selection and login

gws auth setup requires the gcloud CLI. If you don't have gcloud, use the manual setup below instead.

Warning

Scope limits in testing mode: If your OAuth app is unverified (testing mode), Google limits consent to ~25 scopes. The recommended scope preset includes 85+ scopes and will fail for unverified apps (especially for @gmail.com accounts). Choose individual services instead to filter the scope picker:

gws auth login -s drive,gmail,sheets

Multiple accounts

You can authenticate with more than one Google account and switch between them:

gws auth login --account work@corp.com # login and register an account
gws auth login --account personal@gmail.com
gws auth list # list registered accounts
gws auth default work@corp.com. # set the default
gws --account personal@gmail.com drive files list # one-off overrideexport GOOGLE_WORKSPACE_CLI_ACCOUNT=personal@gmail.com # env var override

Credentials are stored per-account as credentials.<b64-email>.enc in ~/.config/gws/, with an accounts.json registry tracking defaults.

Manual OAuth setup (Google Cloud Console)

Use this when gws auth setup cannot automate project/client creation, or when you want explicit control.

  1. Open Google Cloud Console in the target project:
    • OAuth consent screen: https://console.cloud.google.com/apis/credentials/consent?project=<PROJECT_ID>
    • Credentials: https://console.cloud.google.com/apis/credentials?project=<PROJECT_ID>
  2. Configure OAuth branding/audience if prompted:
    • App type: External (testing mode is fine)
  3. Add your account under Test users
  4. Create an OAuth client:
    • Type: Desktop app
  5. Download the client JSON and save it to:
    • ~/.config/gws/client_secret.json

Important

You must add yourself as a test user. In the OAuth consent screen, click Test users → Add users and enter your Google account email. Without this, login will fail with a generic "Access blocked" error.

Then run:

gws auth login

Browser-assisted auth (human or agent)

You can complete OAuth either manually or with browser automation.

  • Human flow: run gws auth login, open the printed URL, approve scopes.
  • Agent-assisted flow: the agent opens the URL, selects account, handles consent prompts, and returns control once the localhost callback succeeds.

If consent shows "Google hasn't verified this app" (testing mode), click Continue. If scope checkboxes appear, select required scopes (or Select all) before continuing.

Headless / CI (export flow)

  1. Complete interactive auth on a machine with a browser.
  2. Export credentials:
    gws auth export --unmasked > credentials.json
  3. On the headless machine:
    export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/credentials.json
    gws drive files list # just works

Service Account (server-to-server)

Point to your key file; no login needed.

export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/service-account.json
gws drive files list

For Domain-Wide Delegation, add:

export GOOGLE_WORKSPACE_CLI_IMPERSONATED_USER=admin@example.com

Pre-obtained Access Token

Useful when another tool (e.g. gcloud) already mints tokens for your environment.

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

Precedence

PrioritySourceSet via
1Access tokenGOOGLE_WORKSPACE_CLI_TOKEN
2Credentials fileGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE
3Per-account encrypted credentialsgws auth login --account EMAIL
4Plaintext credentials~/.config/gws/credentials.json

Account resolution: --account flag > GOOGLE_WORKSPACE_CLI_ACCOUNT env var > default in accounts.json.

Environment variables can also live in a .env file.

AI Agent Skills

The repo ships 100+ Agent Skills (SKILL.md files) — one for every supported API, plus higher-level helpers for common workflows and 50 curated recipes for Gmail, Drive, Docs, Calendar, and Sheets. See the full Skills Index for the complete list.

# Install all skills at once
npx skills add https://github.com/googleworkspace/cli
# Or pick only what you need
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-drive
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-gmail
OpenClaw setup
# Symlink all skills (stays in sync with repo)
ln -s $(pwd)/skills/gws-*~/.openclaw/skills/
# Or copy specific skills
cp -r skills/gws-drive skills/gws-gmail ~/.openclaw/skills/

The gws-shared skill includes an install block so OpenClaw auto-installs the CLI via npm if gws isn't on PATH.

Gemini CLI Extension

  1. Authenticate the CLI first:

    gws auth setup
  2. Install the extension into the Gemini CLI:

    gemini extensions install https://github.com/googleworkspace/cli

Installing this extension gives your Gemini CLI agent direct access to all gws commands and Google Workspace agent skills. Because gws handles its own authentication securely, you simply need to authenticate your terminal once prior to using the agent, and the extension will automatically inherit your credentials.

MCP Server

gws mcp starts a Model Context Protocol server over stdio, exposing Google Workspace APIs as structured tools that any MCP-compatible client (Claude Desktop, Gemini CLI, VS Code, etc.) can call.

gws mcp -s drive # expose Drive tools
gws mcp -s drive,gmail,calendar # expose multiple services
gws mcp -s all # expose all services (many tools!)

Configure in your MCP client:

{
"mcpServers": {
"gws": {
"command": "gws",
"args": ["mcp", "-s", "drive,gmail,calendar"]
}
}
}

Tip

Each service adds roughly 10–80 tools. Keep the list to what you actually need to stay under your client's tool limit (typically 50–100 tools).

FlagDescription
-s, --services <list>Comma-separated services to expose, or all
-w, --workflowsAlso expose workflow tools
-e, --helpersAlso expose helper tools

Advanced Usage

Multipart Uploads

gws drive files create --json '{"name": "report.pdf"}' --upload ./report.pdf

Pagination

FlagDescriptionDefault
--page-allAuto-paginate, one JSON line per page (NDJSON)off
--page-limit <N>Max pages to fetch10
--page-delay <MS>Delay between pages100 ms

Google Sheets — Shell Escaping

Sheets ranges use ! which bash interprets as history expansion. Always wrap values in single quotes:

# Read cells A1:C10 from "Sheet1"
gws sheets spreadsheets values get \
--params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1:C10"}'# Append rows
gws sheets spreadsheets values append \
--params '{"spreadsheetId": "ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' \
--json '{"values": [["Name", "Score"], ["Alice", 95]]}'

Model Armor (Response Sanitization)

Integrate Google Cloud Model Armor to scan API responses for prompt injection before they reach your agent.

gws gmail users messages get --params '...' \
--sanitize "projects/P/locations/L/templates/T"
VariableDescription
GOOGLE_WORKSPACE_CLI_SANITIZE_TEMPLATEDefault Model Armor template
GOOGLE_WORKSPACE_CLI_SANITIZE_MODEwarn (default) or block

Architecture

gws uses a two-phase parsing strategy:

  1. Read argv[1] to identify the service (e.g. drive)
  2. Fetch the service's Discovery Document (cached 24 h)
  3. Build a clap::Command tree from the document's resources and methods
  4. Re-parse the remaining arguments
  5. Authenticate, build the HTTP request, execute

All output — success, errors, download metadata — is structured JSON.

Troubleshooting

"Access blocked" or 403 during login

Your OAuth app is in testing mode and your account is not listed as a test user.

Fix: Open the OAuth consent screen in your GCP project → Test usersAdd users → enter your Google account email. Then retry gws auth login.

"Google hasn't verified this app"

Expected when your app is in testing mode. Click AdvancedGo to <app name> (unsafe) to proceed. This is safe for personal use; verification is only required to publish the app to other users.

Too many scopes / consent screen error

Unverified (testing mode) apps are limited to ~25 OAuth scopes. The recommended scope preset includes many scopes and will exceed this limit.

Fix: Select only the scopes you need:

gws auth login --scopes drive,gmail,calendar

gcloud CLI not found

gws auth setup requires the gcloud CLI to automate project creation. You have three options:

  1. Install gcloud and use gcloud directly.
  2. Re-run gws auth setup which wraps gcloud calls.
  3. Skip gcloud entirely — set up OAuth credentials manually in the Cloud Console

redirect_uri_mismatch

The OAuth client was not created as a Desktop app type. In the Credentials page, delete the existing client, create a new one with type Desktop app, and download the new JSON.

API not enabled — accessNotConfigured

If a required Google API is not enabled for your GCP project, you will see a 403 error with reason accessNotConfigured:

{
"error": {
"code": 403,
"message": "Gmail API has not been used in project 549352339482 ...",
"reason": "accessNotConfigured",
"enable_url": "https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482"
}
}

gws also prints an actionable hint to stderr:

💡 API not enabled for your GCP project.
Enable it at: https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482
After enabling, wait a few seconds and retry your command.

Steps to fix:

  1. Click the enable_url link (or copy it from the enable_url JSON field).
  2. In the GCP Console, click Enable.
  3. Wait ~10 seconds, then retry your gws command.

Tip

You can also run gws auth setup which walks you through enabling all required APIs for your project automatically.

Development

cargo build # dev build
cargo clippy -- -D warnings # lint
cargo test# unit tests
./scripts/coverage.sh # HTML coverage report → target/llvm-cov/html/

License

Apache-2.0

Disclaimer

Caution

This is not an officially supported Google product.

About

Google Workspace CLI — one command-line tool for Drive, Gmail, Calendar, Sheets, Docs, Chat, Admin, and more. Dynamically built from Google Discovery Service. Includes AI agent skills.

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

gws

One CLI for all of Google Workspace — built for humans and AI agents.
Drive, Gmail, Calendar, and every Workspace API. Zero boilerplate. Structured JSON output. 40+ agent skills included.

Note

This is not an officially supported Google product.

npm versionlicenseCI statusinstall size


npm install -g @googleworkspace/cli

gws doesn't ship a static list of commands. It reads Google's own Discovery Service at runtime and builds its entire command surface dynamically. When Google Workspace adds an API endpoint or method, gws picks it up automatically.

Important

This project is under active development. Expect breaking changes as we march toward v1.0.

Contents

Prerequisites

  • Node.js 18+ — for npm install (or download a pre-built binary from GitHub Releases)
  • A Google Cloud project — required for OAuth credentials. You can create one via the Google Cloud Console or with the gcloud CLI or with the gws auth setup command.
  • A Google account with access to Google Workspace

Installation

npm install -g @googleworkspace/cli

The npm package bundles pre-built native binaries for your OS and architecture. No Rust toolchain required.

Pre-built binaries are also available on the GitHub Releases page.

Or build from source:

cargo install --git https://github.com/googleworkspace/cli --locked

A Nix flake is also available at github:googleworkspace/cli

nix run github:googleworkspace/cli

Quick Start

gws auth setup # walks you through Google Cloud project config
gws auth login # subsequent OAuth login
gws drive files list --params '{"pageSize": 5}'

Why gws?

For humans — stop writing curl calls against REST docs. gws gives you --help on every resource, --dry-run to preview requests, and auto‑pagination.

For AI agents — every response is structured JSON. Pair it with the included agent skills and your LLM can manage Workspace without custom tooling.

# List the 10 most recent files
gws drive files list --params '{"pageSize": 10}'# Create a spreadsheet
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'# Send a Chat message
gws chat spaces messages create \
--params '{"parent": "spaces/xyz"}' \
--json '{"text": "Deploy complete."}' \
--dry-run
# Introspect any method's request/response schema
gws schema drive.files.list
# Stream paginated results as NDJSON
gws drive files list --params '{"pageSize": 100}' --page-all | jq -r '.files[].name'

Authentication

The CLI supports multiple auth workflows so it works on your laptop, in CI, and on a server.

Which setup should I use?

I have…Use
gcloud installed and authenticatedgws auth setup (fastest)
A GCP project but no gcloudManual OAuth setup
An existing OAuth access tokenGOOGLE_WORKSPACE_CLI_TOKEN
Existing CredentialsGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE

Interactive (local desktop)

Credentials are encrypted at rest (AES-256-GCM) with the key stored in your OS keyring.

gws auth setup # one-time: creates a Cloud project, enables APIs, logs you in
gws auth login # subsequent scope selection and login

gws auth setup requires the gcloud CLI. If you don't have gcloud, use the manual setup below instead.

Warning

Scope limits in testing mode: If your OAuth app is unverified (testing mode), Google limits consent to ~25 scopes. The recommended scope preset includes 85+ scopes and will fail for unverified apps (especially for @gmail.com accounts). Choose individual services instead to filter the scope picker:

gws auth login -s drive,gmail,sheets

Multiple accounts

You can authenticate with more than one Google account and switch between them:

gws auth login --account work@corp.com # login and register an account
gws auth login --account personal@gmail.com
gws auth list # list registered accounts
gws auth default work@corp.com. # set the default
gws --account personal@gmail.com drive files list # one-off overrideexport GOOGLE_WORKSPACE_CLI_ACCOUNT=personal@gmail.com # env var override

Credentials are stored per-account as credentials.<b64-email>.enc in ~/.config/gws/, with an accounts.json registry tracking defaults.

Manual OAuth setup (Google Cloud Console)

Use this when gws auth setup cannot automate project/client creation, or when you want explicit control.

  1. Open Google Cloud Console in the target project:
    • OAuth consent screen: https://console.cloud.google.com/apis/credentials/consent?project=<PROJECT_ID>
    • Credentials: https://console.cloud.google.com/apis/credentials?project=<PROJECT_ID>
  2. Configure OAuth branding/audience if prompted:
    • App type: External (testing mode is fine)
  3. Add your account under Test users
  4. Create an OAuth client:
    • Type: Desktop app
  5. Download the client JSON and save it to:
    • ~/.config/gws/client_secret.json

Important

You must add yourself as a test user. In the OAuth consent screen, click Test users → Add users and enter your Google account email. Without this, login will fail with a generic "Access blocked" error.

Then run:

gws auth login

Browser-assisted auth (human or agent)

You can complete OAuth either manually or with browser automation.

  • Human flow: run gws auth login, open the printed URL, approve scopes.
  • Agent-assisted flow: the agent opens the URL, selects account, handles consent prompts, and returns control once the localhost callback succeeds.

If consent shows "Google hasn't verified this app" (testing mode), click Continue. If scope checkboxes appear, select required scopes (or Select all) before continuing.

Headless / CI (export flow)

  1. Complete interactive auth on a machine with a browser.
  2. Export credentials:
    gws auth export --unmasked > credentials.json
  3. On the headless machine:
    export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/credentials.json
    gws drive files list # just works

Service Account (server-to-server)

Point to your key file; no login needed.

export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/service-account.json
gws drive files list

For Domain-Wide Delegation, add:

export GOOGLE_WORKSPACE_CLI_IMPERSONATED_USER=admin@example.com

Pre-obtained Access Token

Useful when another tool (e.g. gcloud) already mints tokens for your environment.

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

Precedence

PrioritySourceSet via
1Access tokenGOOGLE_WORKSPACE_CLI_TOKEN
2Credentials fileGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE
3Per-account encrypted credentialsgws auth login --account EMAIL
4Plaintext credentials~/.config/gws/credentials.json

Account resolution: --account flag > GOOGLE_WORKSPACE_CLI_ACCOUNT env var > default in accounts.json.

Environment variables can also live in a .env file.

AI Agent Skills

The repo ships 100+ Agent Skills (SKILL.md files) — one for every supported API, plus higher-level helpers for common workflows and 50 curated recipes for Gmail, Drive, Docs, Calendar, and Sheets. See the full Skills Index for the complete list.

# Install all skills at once
npx skills add https://github.com/googleworkspace/cli
# Or pick only what you need
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-drive
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-gmail
OpenClaw setup
# Symlink all skills (stays in sync with repo)
ln -s $(pwd)/skills/gws-*~/.openclaw/skills/
# Or copy specific skills
cp -r skills/gws-drive skills/gws-gmail ~/.openclaw/skills/

The gws-shared skill includes an install block so OpenClaw auto-installs the CLI via npm if gws isn't on PATH.

Gemini CLI Extension

  1. Authenticate the CLI first:

    gws auth setup
  2. Install the extension into the Gemini CLI:

    gemini extensions install https://github.com/googleworkspace/cli

Installing this extension gives your Gemini CLI agent direct access to all gws commands and Google Workspace agent skills. Because gws handles its own authentication securely, you simply need to authenticate your terminal once prior to using the agent, and the extension will automatically inherit your credentials.

MCP Server

gws mcp starts a Model Context Protocol server over stdio, exposing Google Workspace APIs as structured tools that any MCP-compatible client (Claude Desktop, Gemini CLI, VS Code, etc.) can call.

gws mcp -s drive # expose Drive tools
gws mcp -s drive,gmail,calendar # expose multiple services
gws mcp -s all # expose all services (many tools!)

Configure in your MCP client:

{
"mcpServers": {
"gws": {
"command": "gws",
"args": ["mcp", "-s", "drive,gmail,calendar"]
}
}
}

Tip

Each service adds roughly 10–80 tools. Keep the list to what you actually need to stay under your client's tool limit (typically 50–100 tools).

FlagDescription
-s, --services <list>Comma-separated services to expose, or all
-w, --workflowsAlso expose workflow tools
-e, --helpersAlso expose helper tools

Advanced Usage

Multipart Uploads

gws drive files create --json '{"name": "report.pdf"}' --upload ./report.pdf

Pagination

FlagDescriptionDefault
--page-allAuto-paginate, one JSON line per page (NDJSON)off
--page-limit <N>Max pages to fetch10
--page-delay <MS>Delay between pages100 ms

Google Sheets — Shell Escaping

Sheets ranges use ! which bash interprets as history expansion. Always wrap values in single quotes:

# Read cells A1:C10 from "Sheet1"
gws sheets spreadsheets values get \
--params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1:C10"}'# Append rows
gws sheets spreadsheets values append \
--params '{"spreadsheetId": "ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' \
--json '{"values": [["Name", "Score"], ["Alice", 95]]}'

Model Armor (Response Sanitization)

Integrate Google Cloud Model Armor to scan API responses for prompt injection before they reach your agent.

gws gmail users messages get --params '...' \
--sanitize "projects/P/locations/L/templates/T"
VariableDescription
GOOGLE_WORKSPACE_CLI_SANITIZE_TEMPLATEDefault Model Armor template
GOOGLE_WORKSPACE_CLI_SANITIZE_MODEwarn (default) or block

Architecture

gws uses a two-phase parsing strategy:

  1. Read argv[1] to identify the service (e.g. drive)
  2. Fetch the service's Discovery Document (cached 24 h)
  3. Build a clap::Command tree from the document's resources and methods
  4. Re-parse the remaining arguments
  5. Authenticate, build the HTTP request, execute

All output — success, errors, download metadata — is structured JSON.

Troubleshooting

"Access blocked" or 403 during login

Your OAuth app is in testing mode and your account is not listed as a test user.

Fix: Open the OAuth consent screen in your GCP project → Test usersAdd users → enter your Google account email. Then retry gws auth login.

"Google hasn't verified this app"

Expected when your app is in testing mode. Click AdvancedGo to <app name> (unsafe) to proceed. This is safe for personal use; verification is only required to publish the app to other users.

Too many scopes / consent screen error

Unverified (testing mode) apps are limited to ~25 OAuth scopes. The recommended scope preset includes many scopes and will exceed this limit.

Fix: Select only the scopes you need:

gws auth login --scopes drive,gmail,calendar

gcloud CLI not found

gws auth setup requires the gcloud CLI to automate project creation. You have three options:

  1. Install gcloud and use gcloud directly.
  2. Re-run gws auth setup which wraps gcloud calls.
  3. Skip gcloud entirely — set up OAuth credentials manually in the Cloud Console

redirect_uri_mismatch

The OAuth client was not created as a Desktop app type. In the Credentials page, delete the existing client, create a new one with type Desktop app, and download the new JSON.

API not enabled — accessNotConfigured

If a required Google API is not enabled for your GCP project, you will see a 403 error with reason accessNotConfigured:

{
"error": {
"code": 403,
"message": "Gmail API has not been used in project 549352339482 ...",
"reason": "accessNotConfigured",
"enable_url": "https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482"
}
}

gws also prints an actionable hint to stderr:

💡 API not enabled for your GCP project.
Enable it at: https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482
After enabling, wait a few seconds and retry your command.

Steps to fix:

  1. Click the enable_url link (or copy it from the enable_url JSON field).
  2. In the GCP Console, click Enable.
  3. Wait ~10 seconds, then retry your gws command.

Tip

You can also run gws auth setup which walks you through enabling all required APIs for your project automatically.

Development

cargo build # dev build
cargo clippy -- -D warnings # lint
cargo test# unit tests
./scripts/coverage.sh # HTML coverage report → target/llvm-cov/html/

License

Apache-2.0

Disclaimer

Caution

This is not an officially supported Google product.

About

Google Workspace CLI — one command-line tool for Drive, Gmail, Calendar, Sheets, Docs, Chat, Admin, and more. Dynamically built from Google Discovery Service. Includes AI agent skills.

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

gws

One CLI for all of Google Workspace — built for humans and AI agents.
Drive, Gmail, Calendar, and every Workspace API. Zero boilerplate. Structured JSON output. 40+ agent skills included.

Note

This is not an officially supported Google product.

npm versionlicenseCI statusinstall size


npm install -g @googleworkspace/cli

gws doesn't ship a static list of commands. It reads Google's own Discovery Service at runtime and builds its entire command surface dynamically. When Google Workspace adds an API endpoint or method, gws picks it up automatically.

Important

This project is under active development. Expect breaking changes as we march toward v1.0.

Contents

Prerequisites

  • Node.js 18+ — for npm install (or download a pre-built binary from GitHub Releases)
  • A Google Cloud project — required for OAuth credentials. You can create one via the Google Cloud Console or with the gcloud CLI or with the gws auth setup command.
  • A Google account with access to Google Workspace

Installation

npm install -g @googleworkspace/cli

The npm package bundles pre-built native binaries for your OS and architecture. No Rust toolchain required.

Pre-built binaries are also available on the GitHub Releases page.

Or build from source:

cargo install --git https://github.com/googleworkspace/cli --locked

A Nix flake is also available at github:googleworkspace/cli

nix run github:googleworkspace/cli

Quick Start

gws auth setup # walks you through Google Cloud project config
gws auth login # subsequent OAuth login
gws drive files list --params '{"pageSize": 5}'

Why gws?

For humans — stop writing curl calls against REST docs. gws gives you --help on every resource, --dry-run to preview requests, and auto‑pagination.

For AI agents — every response is structured JSON. Pair it with the included agent skills and your LLM can manage Workspace without custom tooling.

# List the 10 most recent files
gws drive files list --params '{"pageSize": 10}'# Create a spreadsheet
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'# Send a Chat message
gws chat spaces messages create \
--params '{"parent": "spaces/xyz"}' \
--json '{"text": "Deploy complete."}' \
--dry-run
# Introspect any method's request/response schema
gws schema drive.files.list
# Stream paginated results as NDJSON
gws drive files list --params '{"pageSize": 100}' --page-all | jq -r '.files[].name'

Authentication

The CLI supports multiple auth workflows so it works on your laptop, in CI, and on a server.

Which setup should I use?

I have…Use
gcloud installed and authenticatedgws auth setup (fastest)
A GCP project but no gcloudManual OAuth setup
An existing OAuth access tokenGOOGLE_WORKSPACE_CLI_TOKEN
Existing CredentialsGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE

Interactive (local desktop)

Credentials are encrypted at rest (AES-256-GCM) with the key stored in your OS keyring.

gws auth setup # one-time: creates a Cloud project, enables APIs, logs you in
gws auth login # subsequent scope selection and login

gws auth setup requires the gcloud CLI. If you don't have gcloud, use the manual setup below instead.

Warning

Scope limits in testing mode: If your OAuth app is unverified (testing mode), Google limits consent to ~25 scopes. The recommended scope preset includes 85+ scopes and will fail for unverified apps (especially for @gmail.com accounts). Choose individual services instead to filter the scope picker:

gws auth login -s drive,gmail,sheets

Multiple accounts

You can authenticate with more than one Google account and switch between them:

gws auth login --account work@corp.com # login and register an account
gws auth login --account personal@gmail.com
gws auth list # list registered accounts
gws auth default work@corp.com. # set the default
gws --account personal@gmail.com drive files list # one-off overrideexport GOOGLE_WORKSPACE_CLI_ACCOUNT=personal@gmail.com # env var override

Credentials are stored per-account as credentials.<b64-email>.enc in ~/.config/gws/, with an accounts.json registry tracking defaults.

Manual OAuth setup (Google Cloud Console)

Use this when gws auth setup cannot automate project/client creation, or when you want explicit control.

  1. Open Google Cloud Console in the target project:
    • OAuth consent screen: https://console.cloud.google.com/apis/credentials/consent?project=<PROJECT_ID>
    • Credentials: https://console.cloud.google.com/apis/credentials?project=<PROJECT_ID>
  2. Configure OAuth branding/audience if prompted:
    • App type: External (testing mode is fine)
  3. Add your account under Test users
  4. Create an OAuth client:
    • Type: Desktop app
  5. Download the client JSON and save it to:
    • ~/.config/gws/client_secret.json

Important

You must add yourself as a test user. In the OAuth consent screen, click Test users → Add users and enter your Google account email. Without this, login will fail with a generic "Access blocked" error.

Then run:

gws auth login

Browser-assisted auth (human or agent)

You can complete OAuth either manually or with browser automation.

  • Human flow: run gws auth login, open the printed URL, approve scopes.
  • Agent-assisted flow: the agent opens the URL, selects account, handles consent prompts, and returns control once the localhost callback succeeds.

If consent shows "Google hasn't verified this app" (testing mode), click Continue. If scope checkboxes appear, select required scopes (or Select all) before continuing.

Headless / CI (export flow)

  1. Complete interactive auth on a machine with a browser.
  2. Export credentials:
    gws auth export --unmasked > credentials.json
  3. On the headless machine:
    export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/credentials.json
    gws drive files list # just works

Service Account (server-to-server)

Point to your key file; no login needed.

export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/service-account.json
gws drive files list

For Domain-Wide Delegation, add:

export GOOGLE_WORKSPACE_CLI_IMPERSONATED_USER=admin@example.com

Pre-obtained Access Token

Useful when another tool (e.g. gcloud) already mints tokens for your environment.

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

Precedence

PrioritySourceSet via
1Access tokenGOOGLE_WORKSPACE_CLI_TOKEN
2Credentials fileGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE
3Per-account encrypted credentialsgws auth login --account EMAIL
4Plaintext credentials~/.config/gws/credentials.json

Account resolution: --account flag > GOOGLE_WORKSPACE_CLI_ACCOUNT env var > default in accounts.json.

Environment variables can also live in a .env file.

AI Agent Skills

The repo ships 100+ Agent Skills (SKILL.md files) — one for every supported API, plus higher-level helpers for common workflows and 50 curated recipes for Gmail, Drive, Docs, Calendar, and Sheets. See the full Skills Index for the complete list.

# Install all skills at once
npx skills add https://github.com/googleworkspace/cli
# Or pick only what you need
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-drive
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-gmail
OpenClaw setup
# Symlink all skills (stays in sync with repo)
ln -s $(pwd)/skills/gws-*~/.openclaw/skills/
# Or copy specific skills
cp -r skills/gws-drive skills/gws-gmail ~/.openclaw/skills/

The gws-shared skill includes an install block so OpenClaw auto-installs the CLI via npm if gws isn't on PATH.

Gemini CLI Extension

  1. Authenticate the CLI first:

    gws auth setup
  2. Install the extension into the Gemini CLI:

    gemini extensions install https://github.com/googleworkspace/cli

Installing this extension gives your Gemini CLI agent direct access to all gws commands and Google Workspace agent skills. Because gws handles its own authentication securely, you simply need to authenticate your terminal once prior to using the agent, and the extension will automatically inherit your credentials.

MCP Server

gws mcp starts a Model Context Protocol server over stdio, exposing Google Workspace APIs as structured tools that any MCP-compatible client (Claude Desktop, Gemini CLI, VS Code, etc.) can call.

gws mcp -s drive # expose Drive tools
gws mcp -s drive,gmail,calendar # expose multiple services
gws mcp -s all # expose all services (many tools!)

Configure in your MCP client:

{
"mcpServers": {
"gws": {
"command": "gws",
"args": ["mcp", "-s", "drive,gmail,calendar"]
}
}
}

Tip

Each service adds roughly 10–80 tools. Keep the list to what you actually need to stay under your client's tool limit (typically 50–100 tools).

FlagDescription
-s, --services <list>Comma-separated services to expose, or all
-w, --workflowsAlso expose workflow tools
-e, --helpersAlso expose helper tools

Advanced Usage

Multipart Uploads

gws drive files create --json '{"name": "report.pdf"}' --upload ./report.pdf

Pagination

FlagDescriptionDefault
--page-allAuto-paginate, one JSON line per page (NDJSON)off
--page-limit <N>Max pages to fetch10
--page-delay <MS>Delay between pages100 ms

Google Sheets — Shell Escaping

Sheets ranges use ! which bash interprets as history expansion. Always wrap values in single quotes:

# Read cells A1:C10 from "Sheet1"
gws sheets spreadsheets values get \
--params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1:C10"}'# Append rows
gws sheets spreadsheets values append \
--params '{"spreadsheetId": "ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' \
--json '{"values": [["Name", "Score"], ["Alice", 95]]}'

Model Armor (Response Sanitization)

Integrate Google Cloud Model Armor to scan API responses for prompt injection before they reach your agent.

gws gmail users messages get --params '...' \
--sanitize "projects/P/locations/L/templates/T"
VariableDescription
GOOGLE_WORKSPACE_CLI_SANITIZE_TEMPLATEDefault Model Armor template
GOOGLE_WORKSPACE_CLI_SANITIZE_MODEwarn (default) or block

Architecture

gws uses a two-phase parsing strategy:

  1. Read argv[1] to identify the service (e.g. drive)
  2. Fetch the service's Discovery Document (cached 24 h)
  3. Build a clap::Command tree from the document's resources and methods
  4. Re-parse the remaining arguments
  5. Authenticate, build the HTTP request, execute

All output — success, errors, download metadata — is structured JSON.

Troubleshooting

"Access blocked" or 403 during login

Your OAuth app is in testing mode and your account is not listed as a test user.

Fix: Open the OAuth consent screen in your GCP project → Test usersAdd users → enter your Google account email. Then retry gws auth login.

"Google hasn't verified this app"

Expected when your app is in testing mode. Click AdvancedGo to <app name> (unsafe) to proceed. This is safe for personal use; verification is only required to publish the app to other users.

Too many scopes / consent screen error

Unverified (testing mode) apps are limited to ~25 OAuth scopes. The recommended scope preset includes many scopes and will exceed this limit.

Fix: Select only the scopes you need:

gws auth login --scopes drive,gmail,calendar

gcloud CLI not found

gws auth setup requires the gcloud CLI to automate project creation. You have three options:

  1. Install gcloud and use gcloud directly.
  2. Re-run gws auth setup which wraps gcloud calls.
  3. Skip gcloud entirely — set up OAuth credentials manually in the Cloud Console

redirect_uri_mismatch

The OAuth client was not created as a Desktop app type. In the Credentials page, delete the existing client, create a new one with type Desktop app, and download the new JSON.

API not enabled — accessNotConfigured

If a required Google API is not enabled for your GCP project, you will see a 403 error with reason accessNotConfigured:

{
"error": {
"code": 403,
"message": "Gmail API has not been used in project 549352339482 ...",
"reason": "accessNotConfigured",
"enable_url": "https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482"
}
}

gws also prints an actionable hint to stderr:

💡 API not enabled for your GCP project.
Enable it at: https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482
After enabling, wait a few seconds and retry your command.

Steps to fix:

  1. Click the enable_url link (or copy it from the enable_url JSON field).
  2. In the GCP Console, click Enable.
  3. Wait ~10 seconds, then retry your gws command.

Tip

You can also run gws auth setup which walks you through enabling all required APIs for your project automatically.

Development

cargo build # dev build
cargo clippy -- -D warnings # lint
cargo test# unit tests
./scripts/coverage.sh # HTML coverage report → target/llvm-cov/html/

License

Apache-2.0

Disclaimer

Caution

This is not an officially supported Google product.

About

Google Workspace CLI — one command-line tool for Drive, Gmail, Calendar, Sheets, Docs, Chat, Admin, and more. Dynamically built from Google Discovery Service. Includes AI agent skills.

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

gws

One CLI for all of Google Workspace — built for humans and AI agents.
Drive, Gmail, Calendar, and every Workspace API. Zero boilerplate. Structured JSON output. 40+ agent skills included.

Note

This is not an officially supported Google product.

npm versionlicenseCI statusinstall size


npm install -g @googleworkspace/cli

gws doesn't ship a static list of commands. It reads Google's own Discovery Service at runtime and builds its entire command surface dynamically. When Google Workspace adds an API endpoint or method, gws picks it up automatically.

Important

This project is under active development. Expect breaking changes as we march toward v1.0.

Contents

Prerequisites

  • Node.js 18+ — for npm install (or download a pre-built binary from GitHub Releases)
  • A Google Cloud project — required for OAuth credentials. You can create one via the Google Cloud Console or with the gcloud CLI or with the gws auth setup command.
  • A Google account with access to Google Workspace

Installation

npm install -g @googleworkspace/cli

The npm package bundles pre-built native binaries for your OS and architecture. No Rust toolchain required.

Pre-built binaries are also available on the GitHub Releases page.

Or build from source:

cargo install --git https://github.com/googleworkspace/cli --locked

A Nix flake is also available at github:googleworkspace/cli

nix run github:googleworkspace/cli

Quick Start

gws auth setup # walks you through Google Cloud project config
gws auth login # subsequent OAuth login
gws drive files list --params '{"pageSize": 5}'

Why gws?

For humans — stop writing curl calls against REST docs. gws gives you --help on every resource, --dry-run to preview requests, and auto‑pagination.

For AI agents — every response is structured JSON. Pair it with the included agent skills and your LLM can manage Workspace without custom tooling.

# List the 10 most recent files
gws drive files list --params '{"pageSize": 10}'# Create a spreadsheet
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'# Send a Chat message
gws chat spaces messages create \
--params '{"parent": "spaces/xyz"}' \
--json '{"text": "Deploy complete."}' \
--dry-run
# Introspect any method's request/response schema
gws schema drive.files.list
# Stream paginated results as NDJSON
gws drive files list --params '{"pageSize": 100}' --page-all | jq -r '.files[].name'

Authentication

The CLI supports multiple auth workflows so it works on your laptop, in CI, and on a server.

Which setup should I use?

I have…Use
gcloud installed and authenticatedgws auth setup (fastest)
A GCP project but no gcloudManual OAuth setup
An existing OAuth access tokenGOOGLE_WORKSPACE_CLI_TOKEN
Existing CredentialsGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE

Interactive (local desktop)

Credentials are encrypted at rest (AES-256-GCM) with the key stored in your OS keyring.

gws auth setup # one-time: creates a Cloud project, enables APIs, logs you in
gws auth login # subsequent scope selection and login

gws auth setup requires the gcloud CLI. If you don't have gcloud, use the manual setup below instead.

Warning

Scope limits in testing mode: If your OAuth app is unverified (testing mode), Google limits consent to ~25 scopes. The recommended scope preset includes 85+ scopes and will fail for unverified apps (especially for @gmail.com accounts). Choose individual services instead to filter the scope picker:

gws auth login -s drive,gmail,sheets

Multiple accounts

You can authenticate with more than one Google account and switch between them:

gws auth login --account work@corp.com # login and register an account
gws auth login --account personal@gmail.com
gws auth list # list registered accounts
gws auth default work@corp.com. # set the default
gws --account personal@gmail.com drive files list # one-off overrideexport GOOGLE_WORKSPACE_CLI_ACCOUNT=personal@gmail.com # env var override

Credentials are stored per-account as credentials.<b64-email>.enc in ~/.config/gws/, with an accounts.json registry tracking defaults.

Manual OAuth setup (Google Cloud Console)

Use this when gws auth setup cannot automate project/client creation, or when you want explicit control.

  1. Open Google Cloud Console in the target project:
    • OAuth consent screen: https://console.cloud.google.com/apis/credentials/consent?project=<PROJECT_ID>
    • Credentials: https://console.cloud.google.com/apis/credentials?project=<PROJECT_ID>
  2. Configure OAuth branding/audience if prompted:
    • App type: External (testing mode is fine)
  3. Add your account under Test users
  4. Create an OAuth client:
    • Type: Desktop app
  5. Download the client JSON and save it to:
    • ~/.config/gws/client_secret.json

Important

You must add yourself as a test user. In the OAuth consent screen, click Test users → Add users and enter your Google account email. Without this, login will fail with a generic "Access blocked" error.

Then run:

gws auth login

Browser-assisted auth (human or agent)

You can complete OAuth either manually or with browser automation.

  • Human flow: run gws auth login, open the printed URL, approve scopes.
  • Agent-assisted flow: the agent opens the URL, selects account, handles consent prompts, and returns control once the localhost callback succeeds.

If consent shows "Google hasn't verified this app" (testing mode), click Continue. If scope checkboxes appear, select required scopes (or Select all) before continuing.

Headless / CI (export flow)

  1. Complete interactive auth on a machine with a browser.
  2. Export credentials:
    gws auth export --unmasked > credentials.json
  3. On the headless machine:
    export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/credentials.json
    gws drive files list # just works

Service Account (server-to-server)

Point to your key file; no login needed.

export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/service-account.json
gws drive files list

For Domain-Wide Delegation, add:

export GOOGLE_WORKSPACE_CLI_IMPERSONATED_USER=admin@example.com

Pre-obtained Access Token

Useful when another tool (e.g. gcloud) already mints tokens for your environment.

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

Precedence

PrioritySourceSet via
1Access tokenGOOGLE_WORKSPACE_CLI_TOKEN
2Credentials fileGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE
3Per-account encrypted credentialsgws auth login --account EMAIL
4Plaintext credentials~/.config/gws/credentials.json

Account resolution: --account flag > GOOGLE_WORKSPACE_CLI_ACCOUNT env var > default in accounts.json.

Environment variables can also live in a .env file.

AI Agent Skills

The repo ships 100+ Agent Skills (SKILL.md files) — one for every supported API, plus higher-level helpers for common workflows and 50 curated recipes for Gmail, Drive, Docs, Calendar, and Sheets. See the full Skills Index for the complete list.

# Install all skills at once
npx skills add https://github.com/googleworkspace/cli
# Or pick only what you need
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-drive
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-gmail
OpenClaw setup
# Symlink all skills (stays in sync with repo)
ln -s $(pwd)/skills/gws-*~/.openclaw/skills/
# Or copy specific skills
cp -r skills/gws-drive skills/gws-gmail ~/.openclaw/skills/

The gws-shared skill includes an install block so OpenClaw auto-installs the CLI via npm if gws isn't on PATH.

Gemini CLI Extension

  1. Authenticate the CLI first:

    gws auth setup
  2. Install the extension into the Gemini CLI:

    gemini extensions install https://github.com/googleworkspace/cli

Installing this extension gives your Gemini CLI agent direct access to all gws commands and Google Workspace agent skills. Because gws handles its own authentication securely, you simply need to authenticate your terminal once prior to using the agent, and the extension will automatically inherit your credentials.

MCP Server

gws mcp starts a Model Context Protocol server over stdio, exposing Google Workspace APIs as structured tools that any MCP-compatible client (Claude Desktop, Gemini CLI, VS Code, etc.) can call.

gws mcp -s drive # expose Drive tools
gws mcp -s drive,gmail,calendar # expose multiple services
gws mcp -s all # expose all services (many tools!)

Configure in your MCP client:

{
"mcpServers": {
"gws": {
"command": "gws",
"args": ["mcp", "-s", "drive,gmail,calendar"]
}
}
}

Tip

Each service adds roughly 10–80 tools. Keep the list to what you actually need to stay under your client's tool limit (typically 50–100 tools).

FlagDescription
-s, --services <list>Comma-separated services to expose, or all
-w, --workflowsAlso expose workflow tools
-e, --helpersAlso expose helper tools

Advanced Usage

Multipart Uploads

gws drive files create --json '{"name": "report.pdf"}' --upload ./report.pdf

Pagination

FlagDescriptionDefault
--page-allAuto-paginate, one JSON line per page (NDJSON)off
--page-limit <N>Max pages to fetch10
--page-delay <MS>Delay between pages100 ms

Google Sheets — Shell Escaping

Sheets ranges use ! which bash interprets as history expansion. Always wrap values in single quotes:

# Read cells A1:C10 from "Sheet1"
gws sheets spreadsheets values get \
--params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1:C10"}'# Append rows
gws sheets spreadsheets values append \
--params '{"spreadsheetId": "ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' \
--json '{"values": [["Name", "Score"], ["Alice", 95]]}'

Model Armor (Response Sanitization)

Integrate Google Cloud Model Armor to scan API responses for prompt injection before they reach your agent.

gws gmail users messages get --params '...' \
--sanitize "projects/P/locations/L/templates/T"
VariableDescription
GOOGLE_WORKSPACE_CLI_SANITIZE_TEMPLATEDefault Model Armor template
GOOGLE_WORKSPACE_CLI_SANITIZE_MODEwarn (default) or block

Architecture

gws uses a two-phase parsing strategy:

  1. Read argv[1] to identify the service (e.g. drive)
  2. Fetch the service's Discovery Document (cached 24 h)
  3. Build a clap::Command tree from the document's resources and methods
  4. Re-parse the remaining arguments
  5. Authenticate, build the HTTP request, execute

All output — success, errors, download metadata — is structured JSON.

Troubleshooting

"Access blocked" or 403 during login

Your OAuth app is in testing mode and your account is not listed as a test user.

Fix: Open the OAuth consent screen in your GCP project → Test usersAdd users → enter your Google account email. Then retry gws auth login.

"Google hasn't verified this app"

Expected when your app is in testing mode. Click AdvancedGo to <app name> (unsafe) to proceed. This is safe for personal use; verification is only required to publish the app to other users.

Too many scopes / consent screen error

Unverified (testing mode) apps are limited to ~25 OAuth scopes. The recommended scope preset includes many scopes and will exceed this limit.

Fix: Select only the scopes you need:

gws auth login --scopes drive,gmail,calendar

gcloud CLI not found

gws auth setup requires the gcloud CLI to automate project creation. You have three options:

  1. Install gcloud and use gcloud directly.
  2. Re-run gws auth setup which wraps gcloud calls.
  3. Skip gcloud entirely — set up OAuth credentials manually in the Cloud Console

redirect_uri_mismatch

The OAuth client was not created as a Desktop app type. In the Credentials page, delete the existing client, create a new one with type Desktop app, and download the new JSON.

API not enabled — accessNotConfigured

If a required Google API is not enabled for your GCP project, you will see a 403 error with reason accessNotConfigured:

{
"error": {
"code": 403,
"message": "Gmail API has not been used in project 549352339482 ...",
"reason": "accessNotConfigured",
"enable_url": "https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482"
}
}

gws also prints an actionable hint to stderr:

💡 API not enabled for your GCP project.
Enable it at: https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482
After enabling, wait a few seconds and retry your command.

Steps to fix:

  1. Click the enable_url link (or copy it from the enable_url JSON field).
  2. In the GCP Console, click Enable.
  3. Wait ~10 seconds, then retry your gws command.

Tip

You can also run gws auth setup which walks you through enabling all required APIs for your project automatically.

Development

cargo build # dev build
cargo clippy -- -D warnings # lint
cargo test# unit tests
./scripts/coverage.sh # HTML coverage report → target/llvm-cov/html/

License

Apache-2.0

Disclaimer

Caution

This is not an officially supported Google product.

About

Google Workspace CLI — one command-line tool for Drive, Gmail, Calendar, Sheets, Docs, Chat, Admin, and more. Dynamically built from Google Discovery Service. Includes AI agent skills.

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

gws

One CLI for all of Google Workspace — built for humans and AI agents.
Drive, Gmail, Calendar, and every Workspace API. Zero boilerplate. Structured JSON output. 40+ agent skills included.

Note

This is not an officially supported Google product.

npm versionlicenseCI statusinstall size


npm install -g @googleworkspace/cli

gws doesn't ship a static list of commands. It reads Google's own Discovery Service at runtime and builds its entire command surface dynamically. When Google Workspace adds an API endpoint or method, gws picks it up automatically.

Important

This project is under active development. Expect breaking changes as we march toward v1.0.

Contents

Prerequisites

  • Node.js 18+ — for npm install (or download a pre-built binary from GitHub Releases)
  • A Google Cloud project — required for OAuth credentials. You can create one via the Google Cloud Console or with the gcloud CLI or with the gws auth setup command.
  • A Google account with access to Google Workspace

Installation

npm install -g @googleworkspace/cli

The npm package bundles pre-built native binaries for your OS and architecture. No Rust toolchain required.

Pre-built binaries are also available on the GitHub Releases page.

Or build from source:

cargo install --git https://github.com/googleworkspace/cli --locked

A Nix flake is also available at github:googleworkspace/cli

nix run github:googleworkspace/cli

Quick Start

gws auth setup # walks you through Google Cloud project config
gws auth login # subsequent OAuth login
gws drive files list --params '{"pageSize": 5}'

Why gws?

For humans — stop writing curl calls against REST docs. gws gives you --help on every resource, --dry-run to preview requests, and auto‑pagination.

For AI agents — every response is structured JSON. Pair it with the included agent skills and your LLM can manage Workspace without custom tooling.

# List the 10 most recent files
gws drive files list --params '{"pageSize": 10}'# Create a spreadsheet
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'# Send a Chat message
gws chat spaces messages create \
--params '{"parent": "spaces/xyz"}' \
--json '{"text": "Deploy complete."}' \
--dry-run
# Introspect any method's request/response schema
gws schema drive.files.list
# Stream paginated results as NDJSON
gws drive files list --params '{"pageSize": 100}' --page-all | jq -r '.files[].name'

Authentication

The CLI supports multiple auth workflows so it works on your laptop, in CI, and on a server.

Which setup should I use?

I have…Use
gcloud installed and authenticatedgws auth setup (fastest)
A GCP project but no gcloudManual OAuth setup
An existing OAuth access tokenGOOGLE_WORKSPACE_CLI_TOKEN
Existing CredentialsGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE

Interactive (local desktop)

Credentials are encrypted at rest (AES-256-GCM) with the key stored in your OS keyring.

gws auth setup # one-time: creates a Cloud project, enables APIs, logs you in
gws auth login # subsequent scope selection and login

gws auth setup requires the gcloud CLI. If you don't have gcloud, use the manual setup below instead.

Warning

Scope limits in testing mode: If your OAuth app is unverified (testing mode), Google limits consent to ~25 scopes. The recommended scope preset includes 85+ scopes and will fail for unverified apps (especially for @gmail.com accounts). Choose individual services instead to filter the scope picker:

gws auth login -s drive,gmail,sheets

Multiple accounts

You can authenticate with more than one Google account and switch between them:

gws auth login --account work@corp.com # login and register an account
gws auth login --account personal@gmail.com
gws auth list # list registered accounts
gws auth default work@corp.com. # set the default
gws --account personal@gmail.com drive files list # one-off overrideexport GOOGLE_WORKSPACE_CLI_ACCOUNT=personal@gmail.com # env var override

Credentials are stored per-account as credentials.<b64-email>.enc in ~/.config/gws/, with an accounts.json registry tracking defaults.

Manual OAuth setup (Google Cloud Console)

Use this when gws auth setup cannot automate project/client creation, or when you want explicit control.

  1. Open Google Cloud Console in the target project:
    • OAuth consent screen: https://console.cloud.google.com/apis/credentials/consent?project=<PROJECT_ID>
    • Credentials: https://console.cloud.google.com/apis/credentials?project=<PROJECT_ID>
  2. Configure OAuth branding/audience if prompted:
    • App type: External (testing mode is fine)
  3. Add your account under Test users
  4. Create an OAuth client:
    • Type: Desktop app
  5. Download the client JSON and save it to:
    • ~/.config/gws/client_secret.json

Important

You must add yourself as a test user. In the OAuth consent screen, click Test users → Add users and enter your Google account email. Without this, login will fail with a generic "Access blocked" error.

Then run:

gws auth login

Browser-assisted auth (human or agent)

You can complete OAuth either manually or with browser automation.

  • Human flow: run gws auth login, open the printed URL, approve scopes.
  • Agent-assisted flow: the agent opens the URL, selects account, handles consent prompts, and returns control once the localhost callback succeeds.

If consent shows "Google hasn't verified this app" (testing mode), click Continue. If scope checkboxes appear, select required scopes (or Select all) before continuing.

Headless / CI (export flow)

  1. Complete interactive auth on a machine with a browser.
  2. Export credentials:
    gws auth export --unmasked > credentials.json
  3. On the headless machine:
    export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/credentials.json
    gws drive files list # just works

Service Account (server-to-server)

Point to your key file; no login needed.

export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/service-account.json
gws drive files list

For Domain-Wide Delegation, add:

export GOOGLE_WORKSPACE_CLI_IMPERSONATED_USER=admin@example.com

Pre-obtained Access Token

Useful when another tool (e.g. gcloud) already mints tokens for your environment.

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

Precedence

PrioritySourceSet via
1Access tokenGOOGLE_WORKSPACE_CLI_TOKEN
2Credentials fileGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE
3Per-account encrypted credentialsgws auth login --account EMAIL
4Plaintext credentials~/.config/gws/credentials.json

Account resolution: --account flag > GOOGLE_WORKSPACE_CLI_ACCOUNT env var > default in accounts.json.

Environment variables can also live in a .env file.

AI Agent Skills

The repo ships 100+ Agent Skills (SKILL.md files) — one for every supported API, plus higher-level helpers for common workflows and 50 curated recipes for Gmail, Drive, Docs, Calendar, and Sheets. See the full Skills Index for the complete list.

# Install all skills at once
npx skills add https://github.com/googleworkspace/cli
# Or pick only what you need
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-drive
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-gmail
OpenClaw setup
# Symlink all skills (stays in sync with repo)
ln -s $(pwd)/skills/gws-*~/.openclaw/skills/
# Or copy specific skills
cp -r skills/gws-drive skills/gws-gmail ~/.openclaw/skills/

The gws-shared skill includes an install block so OpenClaw auto-installs the CLI via npm if gws isn't on PATH.

Gemini CLI Extension

  1. Authenticate the CLI first:

    gws auth setup
  2. Install the extension into the Gemini CLI:

    gemini extensions install https://github.com/googleworkspace/cli

Installing this extension gives your Gemini CLI agent direct access to all gws commands and Google Workspace agent skills. Because gws handles its own authentication securely, you simply need to authenticate your terminal once prior to using the agent, and the extension will automatically inherit your credentials.

MCP Server

gws mcp starts a Model Context Protocol server over stdio, exposing Google Workspace APIs as structured tools that any MCP-compatible client (Claude Desktop, Gemini CLI, VS Code, etc.) can call.

gws mcp -s drive # expose Drive tools
gws mcp -s drive,gmail,calendar # expose multiple services
gws mcp -s all # expose all services (many tools!)

Configure in your MCP client:

{
"mcpServers": {
"gws": {
"command": "gws",
"args": ["mcp", "-s", "drive,gmail,calendar"]
}
}
}

Tip

Each service adds roughly 10–80 tools. Keep the list to what you actually need to stay under your client's tool limit (typically 50–100 tools).

FlagDescription
-s, --services <list>Comma-separated services to expose, or all
-w, --workflowsAlso expose workflow tools
-e, --helpersAlso expose helper tools

Advanced Usage

Multipart Uploads

gws drive files create --json '{"name": "report.pdf"}' --upload ./report.pdf

Pagination

FlagDescriptionDefault
--page-allAuto-paginate, one JSON line per page (NDJSON)off
--page-limit <N>Max pages to fetch10
--page-delay <MS>Delay between pages100 ms

Google Sheets — Shell Escaping

Sheets ranges use ! which bash interprets as history expansion. Always wrap values in single quotes:

# Read cells A1:C10 from "Sheet1"
gws sheets spreadsheets values get \
--params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1:C10"}'# Append rows
gws sheets spreadsheets values append \
--params '{"spreadsheetId": "ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' \
--json '{"values": [["Name", "Score"], ["Alice", 95]]}'

Model Armor (Response Sanitization)

Integrate Google Cloud Model Armor to scan API responses for prompt injection before they reach your agent.

gws gmail users messages get --params '...' \
--sanitize "projects/P/locations/L/templates/T"
VariableDescription
GOOGLE_WORKSPACE_CLI_SANITIZE_TEMPLATEDefault Model Armor template
GOOGLE_WORKSPACE_CLI_SANITIZE_MODEwarn (default) or block

Architecture

gws uses a two-phase parsing strategy:

  1. Read argv[1] to identify the service (e.g. drive)
  2. Fetch the service's Discovery Document (cached 24 h)
  3. Build a clap::Command tree from the document's resources and methods
  4. Re-parse the remaining arguments
  5. Authenticate, build the HTTP request, execute

All output — success, errors, download metadata — is structured JSON.

Troubleshooting

"Access blocked" or 403 during login

Your OAuth app is in testing mode and your account is not listed as a test user.

Fix: Open the OAuth consent screen in your GCP project → Test usersAdd users → enter your Google account email. Then retry gws auth login.

"Google hasn't verified this app"

Expected when your app is in testing mode. Click AdvancedGo to <app name> (unsafe) to proceed. This is safe for personal use; verification is only required to publish the app to other users.

Too many scopes / consent screen error

Unverified (testing mode) apps are limited to ~25 OAuth scopes. The recommended scope preset includes many scopes and will exceed this limit.

Fix: Select only the scopes you need:

gws auth login --scopes drive,gmail,calendar

gcloud CLI not found

gws auth setup requires the gcloud CLI to automate project creation. You have three options:

  1. Install gcloud and use gcloud directly.
  2. Re-run gws auth setup which wraps gcloud calls.
  3. Skip gcloud entirely — set up OAuth credentials manually in the Cloud Console

redirect_uri_mismatch

The OAuth client was not created as a Desktop app type. In the Credentials page, delete the existing client, create a new one with type Desktop app, and download the new JSON.

API not enabled — accessNotConfigured

If a required Google API is not enabled for your GCP project, you will see a 403 error with reason accessNotConfigured:

{
"error": {
"code": 403,
"message": "Gmail API has not been used in project 549352339482 ...",
"reason": "accessNotConfigured",
"enable_url": "https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482"
}
}

gws also prints an actionable hint to stderr:

💡 API not enabled for your GCP project.
Enable it at: https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482
After enabling, wait a few seconds and retry your command.

Steps to fix:

  1. Click the enable_url link (or copy it from the enable_url JSON field).
  2. In the GCP Console, click Enable.
  3. Wait ~10 seconds, then retry your gws command.

Tip

You can also run gws auth setup which walks you through enabling all required APIs for your project automatically.

Development

cargo build # dev build
cargo clippy -- -D warnings # lint
cargo test# unit tests
./scripts/coverage.sh # HTML coverage report → target/llvm-cov/html/

License

Apache-2.0

Disclaimer

Caution

This is not an officially supported Google product.

About

Google Workspace CLI — one command-line tool for Drive, Gmail, Calendar, Sheets, Docs, Chat, Admin, and more. Dynamically built from Google Discovery Service. Includes AI agent skills.

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages