Google Command Line Tool for OpenClaw: 7 Mistakes to Avoid
The Google command line tool that OpenClaw users talk about is gws, the Google Workspace CLI from the googleworkspace/cli repository on GitHub. It covers Drive, Gmail, Calendar, Sheets, Docs, Chat and more, and it ships agent skills that OpenClaw can load. The README says plainly that it is "not an officially supported Google product" and that breaking changes are expected before v1.0. An earlier version of this post described a tool called gworkspace installed with pip. That tool does not exist, so the post has been rewritten around the real one.
I installed the Google command line tool, gws v0.22.5 (the latest release, published 31 March 2026) in a clean Debian 13 container and ran everything that works without a Google account: help, schema lookup, dry runs and the error paths. I did not log in to a real Workspace account, so nothing below shows real Drive or Gmail data.

Contents
Install the Google command line tool the right way
The README recommends the pre-built binary from GitHub Releases; npm install -g @googleworkspace/cli downloads the same binary, and there are also Cargo, Nix and Homebrew options. For Linux x86_64 the release has a gnu and a musl tarball, each with a .sha256 file. Check it before you put anything on your PATH:
$ cat google-workspace-cli-x86_64-unknown-linux-gnu.tar.gz.sha256; sha256sum google-workspace-cli-x86_64-unknown-linux-gnu.tar.gz
de78ecdbd2f1a84cca0063a7ecbc440240fc14b6ebccbb17f4646b792a8c5c1f google-workspace-cli-x86_64-unknown-linux-gnu.tar.gz
de78ecdbd2f1a84cca0063a7ecbc440240fc14b6ebccbb17f4646b792a8c5c1f google-workspace-cli-x86_64-unknown-linux-gnu.tar.gz
$ tar -tzf google-workspace-cli-x86_64-unknown-linux-gnu.tar.gz
./
./CHANGELOG.md
./LICENSE
./gws
./README.md
$ gws --version
gws 0.22.5
This is not an officially supported Google product.
The Google command line tool archive holds one binary plus docs, and the container needed only curl and ca-certificates to fetch it. There is no Python requirement at all.
Do not pip install the old name
The old article told readers to run pip install google-workspace-cli openclaw-connector. Today openclaw-connector returns 404 on PyPI, and google-workspace-cli does exist, but it is a different project: version 0.1.1, uploaded on 16 June 2026, "Google Workspace CLI for Claude Code", with its homepage at github.com/JFK/gw-cli (checked on the PyPI page on 17 November 2026). I did not install it. A package that asks for OAuth access to your mail and files should come from a source you chose on purpose, not from a name copied out of a blog post.
What gws can do before you log in
The Google command line tool does not carry a fixed command list. The README explains that it reads Google's Discovery Service at runtime and builds the commands from it, with the Discovery document cached for 24 hours. The lab shows the effect: gws drive --help listed resources such as files, permissions, revisions and drives, plus one hand-written helper, +upload. Gmail had seven helpers, among them +send, +triage, +reply and +watch.
The schema command is the most useful thing for an AI agent, because the agent can read the real parameters instead of guessing them. gws schema drive.files.list printed the method's JSON description, including the note that it "returns *all* files by default, including trashed files", and that corpus is "Deprecated: The source of files to list. Use `corpora` instead."
Then the dry run. The Google command line tool builds the request and stops, which makes it a good habit for any command an agent proposes:
$ gws chat spaces messages create --params '{"parent": "spaces/xyz"}' --json '{"text": "Deploy complete."}' --dry-run
{
"body": {
"text": "Deploy complete."
},
"dry_run": true,
"is_multipart_upload": false,
"method": "POST",
"query_params": [],
"url": "https://chat.googleapis.com/v1/spaces/xyz/messages"
}
For Sheets, the dry run showed how the range Sheet1!A1:C10 ends up in the URL as Sheet1%21A1%3AC10. The README warns that ! triggers bash history expansion, so keep the whole --params value in single quotes.
Exporting Docs text: the real commands
With the Google command line tool, exports go through Drive. The old post's gworkspace docs export --query ... --format txt has no equivalent. In gws, gws docs export --format txt fails with "error[validation]: error: unrecognized subcommand 'export'" and exit code 3. Exporting a Google Doc as text is a Drive API call: find the files, then call files export with a MIME type. Here is the search, written to a file to avoid quoting trouble:
$ cat /tmp/q.json
{"q": "mimeType = 'application/vnd.google-apps.document' and name contains 'architecture' and modifiedTime > '2026-11-10T00:00:00' and trashed = false", "fields": "files(id,name,modifiedTime)"}
$ gws drive files list --params "$(cat /tmp/q.json)" --dry-run
{
"body": null,
"dry_run": true,
"is_multipart_upload": false,
"method": "GET",
"query_params": [
[
"fields",
"files(id,name,modifiedTime)"
],
[
"q",
"mimeType = 'application/vnd.google-apps.document' and name contains 'architecture' and modifiedTime > '2026-11-10T00:00:00' and trashed = false"
]
],
"url": "https://www.googleapis.com/drive/v3/files"
}
The query syntax is Drive's own, described in Search for files and folders. Add trashed = false, because the schema says trashed files are included otherwise. Broken JSON is caught before any request: --params '{pageSize: 5}' failed with "Invalid --params JSON: key must be a string at line 1 column 2" and exit 3.
For each file ID, the export is gws drive files export --params '{"fileId": "DOC_ID", "mimeType": "text/plain"}' --output architecture.txt. Its schema lists fileId and mimeType as the parameter order, and the MIME type is required; the allowed values are on Google's export MIME types page.
Authentication and exit codes for scripts
Without credentials, a real call from the Google command line tool fails cleanly with JSON on stdout and a short line on stderr:
$ gws drive files list --params '{"pageSize": 5}'
{
"error": {
"code": 401,
"message": "Access denied. No credentials provided. Run `gws auth login` or set GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE to an OAuth credentials JSON file.",
"reason": "authError"
}
}
error[auth]: Access denied. No credentials provided. Run `gws auth login` or set GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE to an OAuth credentials JSON file.
That ended with exit code 2. An unknown service or bad JSON gave exit 3. With a fake token in GOOGLE_WORKSPACE_CLI_TOKEN, Google answered 401, gws printed error[api] and the exit code was 1, so an invalid token counts as an API error, not an auth error. If your nightly job retries on 1 and alerts on 2, test that path with a revoked token before you trust it.
gws auth login on a fresh machine stopped with "No OAuth client configured" and listed three ways out: gws auth setup (which needs gcloud), a client_secret.json in ~/.config/gws/, or the GOOGLE_WORKSPACE_CLI_CLIENT_ID and GOOGLE_WORKSPACE_CLI_CLIENT_SECRET variables. According to the README, the OAuth client must be a Desktop app, you must add yourself as a test user while the app is in testing mode, and unverified apps are limited to about 25 scopes. So log in with only the services you need, for example gws auth login -s drive,gmail,sheets.
To run the Google command line tool on a server, use the export flow the README describes: gws auth export --unmasked on a desktop machine and GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE on the headless one. That exported file opens your mailbox to whoever can read it, so give it mode 600 and keep it out of git.
Connecting the Google command line tool to OpenClaw
OpenClaw does not need a connector package for the Google command line tool. The repository has a skills/ folder (95 entries in my clone, 44 of them named gws-*), and the README's OpenClaw setup is a symlink:
ln -s $(pwd)/skills/gws-* ~/.openclaw/skills/
Each skill is a SKILL.md with front matter that OpenClaw reads. In the cloned copy, gws-drive declares requires: bins: - gws and cliHelp: "gws drive --help", and tells the agent to read ../gws-shared/SKILL.md first for auth and security rules. The README says gws-shared has an install block so OpenClaw can install the CLI through npm; the front matter in my clone listed only the binary requirement, so install gws yourself and pin the version.
Copy only the skills the agent needs (cp -r skills/gws-drive skills/gws-gmail ~/.openclaw/skills/ is the README's example) and log in with matching scopes. Every skill you link is a set of instructions your agent will follow with your Google credentials. Recent OpenClaw problems such as the attacks that expose agent secrets are a good reason to keep that list short. If you route the agent through a gateway, see the OpenClaw gateway features post.
Google command line tool checklist
- Install the Google command line tool from GitHub Releases or npm, check the sha256, and record the version (v0.22.5 here).
- Use
gws schemaand--dry-runbefore any write, and let the agent do the same. - Log in with a short service list; the full recommended preset fails on unverified apps.
- Branch scripts on exit codes 1, 2 and 3, and test the expired-token case.
- Docs text comes from
gws drive files export, not from a docs export command. - Link only the
gws-*skills you need into~/.openclaw/skills/.
One last check on any tutorial about this Google command line tool, this one included: run gws <service> --help on your own version. The command surface comes from Google's Discovery documents, so it can change without a new gws release.
Comments
Post a Comment