SuperAPI AI Directory

gws - Command-line tool open-sourced by the Google Workspace team

Author: AI小集 · Original source: AI工具集

What is gws

gws (Google Workspace CLI) is a command-line tool open-sourced by the Google Workspace team, written in Rust and distributed via npm. Its biggest highlight is that it dynamically builds commands at runtime without relying on a static command list, reading the Google Discovery Service in real time to automatically support all Workspace APIs (Drive, Gmail, Calendar, Sheets, etc.); when Google adds new endpoints, they can be used without any update. gws is designed for the AI Agent era, with a built-in MCP server, support for structured JSON output, automatic pagination, Model Armor security scanning, and a Git-like Pull/Push workflow, enabling AI to directly edit local files and then sync them back to Workspace.

gws

Main features of gws

  • Dynamic API discovery: Builds the command tree in real time from the Google Discovery Service at runtime, automatically supporting all Workspace APIs and newly added endpoints without waiting for tool updates.
  • Unified command interface: A single CLI covers all Google Workspace services including Drive, Gmail, Calendar, Sheets, Docs, Chat, etc., eliminating switching between multiple tools.
  • Structured JSON output: All responses (including errors) are in JSON format, making it easy for scripts to parse and for downstream automation processing.
  • MCP server support: Built-in Model Context Protocol server; AI Agents such as Claude and Gemini can directly call Workspace APIs as tools.
  • Intelligent authentication management: Supports multiple authentication methods such as interactive OAuth, service accounts, and CI/CD headless environments, and automatically handles token refresh.
  • Automatic pagination handling:--page-all The flag automatically handles API pagination and streams NDJSON output, making it easy to extract large amounts of data.
  • Model Armor integration: Scans API responses for security risks such as prompt injection, protecting AI Agents from malicious content attacks.
  • Agent Skills library: Built-in 100+ preset Skills covering common workflows, which can be directly integrated with Agent frameworks such as OpenClaw.
  • Pull/Push workflow: Git-like operations that pull Google documents as local structured files (TSV/JSON), and push them back to Workspace after AI editing.
  • Gemini CLI extension: A dedicated extension that gives the Gemini CLI Agent native access to all gws commands and Skills capabilities.

Technical principles of gws

  • Rust core architecture: The underlying layer is written in Rust, ensuring high performance and memory safety; prebuilt binaries are distributed via npm and support cross-platform operation.
  • Dynamic parsing of the Discovery Service: At startup, it pulls Google Discovery Documents (API specifications in JSON format) in real time and dynamically builds the command tree and parameter structure, rather than hardcoding static commands.
  • Runtime generation of the command tree: Based on the resource and method definitions in the Discovery Documents, it automatically generates the corresponding CLI subcommands, parameter mappings, and request body structures.
  • REST API wrapper layer: All operations are ultimately converted into standard HTTP calls to Google REST APIs, with unified handling of URL construction, request serialization, and response parsing.
  • OAuth 2.0 authentication pipeline: Built-in complete OAuth flow support, including a local callback server, token caching, automatic refresh, and JWT signature authentication for service accounts.
  • JSON Schema Validation: Uses the parameter definitions in Discovery Documents to perform type checking and format validation of request parameters locally.
  • Streaming Pagination Engine:--page-all mode, automatically identifies pagination tokens in responses (pageToken/nextPageToken), recursively fetches and streams results in NDJSON format.
  • MCP Protocol Adapter: Implements the Model Context Protocol standard interface, exposing gws commands as MCP Tools for AI clients to discover and invoke.
  • Model Armor Security Gateway: Calls the Google Cloud Model Armor API to perform real-time security scanning of API response content, intercepting attack vectors such as prompt injection.
  • Pull/Push Data Transformation Layer: Built-in format conversion engine that bidirectionally converts between Google documents (Sheets/Docs) and local structured files (TSV/JSON/Markdown), supporting diff detection and incremental sync.

gws project address

  • Github repository:https://github.com/googleworkspace/cli

gws application scenarios

  • AI Agent Development: Through the MCP protocol, LLMs can directly control Google Workspace, enabling Agent capabilities such as intelligent document processing, automatic email replies, and smart scheduling.
  • Batch Data Migration: Using --page-all automatic pagination to batch export Drive file lists, Gmail messages, Sheets data, etc., supporting enterprise data backup and migration.
  • CI/CD Automation: Runs in headless server environments, automating DevOps workflows such as document generation, report pushing, and permission management, with service account authentication support.
  • Content Management Automation: The Pull/Push workflow implements document version control, converting Google Docs to local Markdown for AI editing and then syncing back to the cloud.
  • Enterprise Data Pipeline: Builds real-time sync pipelines between Sheets ↔ data warehouses, automates report generation and distribution, replacing part of the capabilities of traditional ETL tools.
  • Security and Compliance Auditing: Integrates Model Armor to scan API responses, preventing prompt injection and data leakage risks in enterprise-grade Agent applications.