| name | google-cli |
| description | Google Workspace CLI (gws) for Drive, Gmail, Calendar, Sheets, Docs, Chat, and Admin APIs.
Use when the user wants to interact with Google Workspace: list/upload/download Drive files,
send/read Gmail, manage Calendar events, read/write Sheets, create Docs, send Chat messages,
or administer Google Workspace. Triggers: "google drive", "gmail", "google calendar",
"google sheets", "google docs", "google chat", "gws", "workspace", or any Google Workspace action.
|
| allowed-tools | Bash(gws:*) |
Google Workspace CLI (gws)
Unified CLI for Google Workspace APIs — one command surface for Drive, Gmail, Calendar, Sheets, Docs, Chat, and Admin. Dynamically built from Google's Discovery Service, so it supports new API endpoints automatically.
Installation
npm install -g @googleworkspace/cli
Authentication
Credentials are encrypted at rest (AES-256-GCM) with keys stored in OS keyring.
gws auth setup
gws auth login
gws auth list
Multiple Accounts
gws auth login --account work@corp.com
gws auth login --account personal@gmail.com
gws auth default work@corp.com
gws --account personal@gmail.com drive files list
Environment Variables
| Variable | Purpose |
|---|
GOOGLE_WORKSPACE_CLI_TOKEN | Pre-obtained OAuth access token |
GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE | Path to credentials JSON |
GOOGLE_WORKSPACE_CLI_ACCOUNT | Default account email |
GOOGLE_WORKSPACE_CLI_IMPERSONATED_USER | Email for domain-wide delegation |
Global Flags
--dry-run — Preview the HTTP request without executing
--page-all — Auto-paginate (NDJSON, one JSON line per page)
--page-limit <N> — Max pages to fetch (default: 10)
--page-delay <MS> — Delay between pages (default: 100ms)
--account <EMAIL> — Target a specific account
--upload <PATH> — Attach file for multipart upload
Schema Introspection
Discover available methods and their parameters before calling:
gws schema drive.files.list
gws schema gmail.users.messages.send
gws schema sheets.spreadsheets.values.get
Drive
gws drive files list --params '{"pageSize": 10}'
gws drive files list --params '{"q": "mimeType=\"application/pdf\"", "pageSize": 5}'
gws drive files get --params '{"fileId": "FILE_ID"}'
gws drive files create --json '{"name": "report.pdf"}' --upload ./report.pdf
gws drive files export --params '{"fileId": "FILE_ID", "mimeType": "application/pdf"}'
gws drive files create --json '{"name": "Projects", "mimeType": "application/vnd.google-apps.folder"}'
gws drive files update --params '{"fileId": "FILE_ID", "addParents": "FOLDER_ID", "removeParents": "OLD_PARENT_ID"}'
gws drive files delete --params '{"fileId": "FILE_ID"}'
gws drive files list --params '{"q": "fullText contains \"quarterly report\"", "pageSize": 100}' --page-all
Gmail
gws gmail users messages list --params '{"userId": "me", "maxResults": 10}'
gws gmail users messages list --params '{"userId": "me", "q": "from:boss@company.com is:unread"}'
gws gmail users messages get --params '{"userId": "me", "id": "MSG_ID"}'
gws gmail users messages send --params '{"userId": "me"}' --json '{"raw": "BASE64_ENCODED_MESSAGE"}'
gws gmail users labels list --params '{"userId": "me"}'
gws gmail users messages modify --params '{"userId": "me", "id": "MSG_ID"}' --json '{"removeLabelIds": ["INBOX"]}'
gws gmail users messages trash --params '{"userId": "me", "id": "MSG_ID"}'
Calendar
gws calendar calendarList list
gws calendar events list --params '{"calendarId": "primary", "maxResults": 10, "timeMin": "2026-03-01T00:00:00Z"}'
gws calendar events get --params '{"calendarId": "primary", "eventId": "EVENT_ID"}'
gws calendar events insert --params '{"calendarId": "primary"}' --json '{
"summary": "Team standup",
"start": {"dateTime": "2026-03-06T09:00:00-06:00"},
"end": {"dateTime": "2026-03-06T09:30:00-06:00"},
"attendees": [{"email": "colleague@company.com"}]
}'
gws calendar events patch --params '{"calendarId": "primary", "eventId": "EVENT_ID"}' --json '{"summary": "Updated title"}'
gws calendar events delete --params '{"calendarId": "primary", "eventId": "EVENT_ID"}'
Sheets
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'
gws sheets spreadsheets values get --params '{"spreadsheetId": "SHEET_ID", "range": "Sheet1!A1:C10"}'
gws sheets spreadsheets values update \
--params '{"spreadsheetId": "SHEET_ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' \
--json '{"values": [["Name", "Score"], ["Alice", 95]]}'
gws sheets spreadsheets values append \
--params '{"spreadsheetId": "SHEET_ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' \
--json '{"values": [["Bob", 88]]}'
gws sheets spreadsheets values clear --params '{"spreadsheetId": "SHEET_ID", "range": "Sheet1!A1:C10"}'
gws sheets spreadsheets get --params '{"spreadsheetId": "SHEET_ID"}'
Docs
gws docs documents create --json '{"title": "Meeting Notes"}'
gws docs documents get --params '{"documentId": "DOC_ID"}'
gws docs documents batchUpdate --params '{"documentId": "DOC_ID"}' --json '{
"requests": [{"insertText": {"location": {"index": 1}, "text": "Hello World\n"}}]
}'
Chat
gws chat spaces list
gws chat spaces messages create \
--params '{"parent": "spaces/SPACE_ID"}' \
--json '{"text": "Deploy complete."}'
gws chat spaces messages list --params '{"parent": "spaces/SPACE_ID"}'
Admin (Directory API)
gws admin directory users list --params '{"domain": "company.com", "maxResults": 10}'
gws admin directory users get --params '{"userKey": "user@company.com"}'
gws admin directory groups list --params '{"domain": "company.com"}'
Common Workflows
Find and download a file
FILE_ID=$(gws drive files list --params '{"q": "name=\"report.pdf\"", "pageSize": 1}' | jq -r '.files[0].id')
gws drive files get --params "{\"fileId\": \"$FILE_ID\", \"alt\": \"media\"}"
Search Gmail and read results
MSGS=$(gws gmail users messages list --params '{"userId": "me", "q": "subject:invoice after:2026/01/01", "maxResults": 5}')
MSG_ID=$(echo "$MSGS" | jq -r '.messages[0].id')
gws gmail users messages get --params "{\"userId\": \"me\", \"id\": \"$MSG_ID\"}"
Check today's calendar
gws calendar events list --params "{\"calendarId\": \"primary\", \"timeMin\": \"$(date -u +%Y-%m-%dT00:00:00Z)\", \"timeMax\": \"$(date -u -v+1d +%Y-%m-%dT00:00:00Z)\", \"singleEvents\": true, \"orderBy\": \"startTime\"}"
Tips
- All output is structured JSON — pipe to
jq for extraction
- Use
--dry-run to preview requests before executing
- Use
gws schema <method> to discover parameters for any API method
- Use
--page-all for large result sets (auto-pagination as NDJSON)
- The CLI dynamically discovers API surface — if Google adds a new endpoint,
gws supports it automatically
- Append
--help to any subcommand for usage info