One Command to Control Gmail, Calendar, and Drive—Google’s New CLI for Humans and AI Agents
Google has open‑sourced the Google Workspace CLI (gws), a Rust‑based command‑line tool that lets you manage Drive, Gmail, Calendar, Sheets, Docs, Chat and more with a single command, offering dynamic API discovery, extensive authentication options, built‑in Agent skills, and a Model Armor security layer, while noting current limitations and setup considerations.
What Can It Do?
Google Workspace CLI (gws) is a unified command‑line interface that covers Drive, Gmail, Calendar, Sheets, Docs, Chat, Admin and all other Workspace APIs. Example commands include:
# List the latest 10 files in Google Drive
gws drive files list --params '{"pageSize": 10}'
# Create a new Google Sheet
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'
# List all file names with automatic pagination
gws drive files list --page-all | jq -r '.files[].name'
# Show request/response schema for an API method
gws schema drive.files.listAll outputs are structured JSON, making them easy to process programmatically or by AI agents.
Technical Highlights
Rust implementation for performance – gws is built in Rust, providing fast startup, low memory usage, and native cross‑platform support.
Dynamic API discovery – Instead of hard‑coding every endpoint, gws fetches Google’s Discovery Service at runtime, caches the document for 24 hours, and generates the full command tree on the fly. This ensures the CLI never becomes outdated when new Workspace APIs are added.
The execution flow is:
Read the first argument (e.g., drive) to identify the target service.
Download the service’s Discovery Document (cached locally for 24 hours).
Generate the complete command‑line parameter structure from the document.
Parse remaining arguments and issue the HTTP request.
Because the CLI builds commands dynamically, newly released APIs can be used immediately without updating the binary.
Authentication Coverage
gws supports a full range of authentication methods:
Interactive auth : gws auth setup guides you step‑by‑step.
Manual OAuth : Configure a client ID in Google Cloud Console.
Service Account : Suitable for server‑side scenarios with domain‑wide delegation.
External Token : Pass an existing access token directly.
CI/CD support : Export credentials for headless environments.
Multi‑account switching is also supported, with credentials stored encrypted.
Why It’s Built for Agents
gws ships with over 40 pre‑defined Agent skills written in Markdown, which can be invoked by frameworks such as OpenClaw. These skills let an AI agent operate the entire Google Workspace suite without custom adapters.
It also includes native MCP Server support. A single command like gws mcp -s drive,gmail,calendar starts a server that exposes Drive, Gmail and Calendar as tools, allowing integration with Claude Desktop, Gemini CLI, or VS Code AI assistants.
For security, gws integrates Google Cloud’s Model Armor to sanitize AI responses and protect against prompt‑injection attacks.
Installation
The simplest method is a one‑line npm install: npm install -g @googleworkspace/cli You can also add it as a Skill: npx skills add github:googleworkspace/cli Other distribution options include building from source via Cargo, downloading pre‑compiled releases from GitHub, or using Nix Flakes.
Things to Watch Out For
Although gws is powerful, there are several caveats:
Pre‑v1.0 : The tool is still in active development; breaking changes may occur.
Auth setup complexity : First‑time OAuth client or Service Account configuration can be cumbersome for newcomers.
Dynamic discovery trade‑off : Requires network access on first use and may provide less polished auto‑completion compared to static CLIs.
Agent permissions : Granting an AI agent direct access to Gmail or Drive poses security risks; misuse could lead to data loss or spam.
Since 2026, the combination of CLIs and Agent skills has been gaining traction, turning command‑line tools from developer‑only utilities into general‑purpose AI interfaces.
GitHub repository: https://github.com/googleworkspace/cli
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
