Integrating Google Workspace APIs—corresponding to Drive, Gmail, Calendar, and Sheets—into purposes and knowledge pipelines sometimes requires writing boilerplate code to deal with REST endpoints, pagination, and OAuth 2.0 flows. Google AI staff simply launched a CLI Instrument (gws) for Google Workspace. The open-source googleworkspace/cli (invoked by way of the gws command) offers a unified, dynamic command-line interface to handle these companies.
Designed for each human builders and AI brokers, gws eliminates the necessity for customized wrapper scripts by offering structured JSON outputs, native Mannequin Context Protocol (MCP) assist, and automatic authentication workflows.
Dynamic API Discovery Structure
Not like conventional CLI instruments that compile a static checklist of instructions, gws builds its command floor dynamically at runtime.
When executed, gws makes use of a two-phase parsing technique:
- It reads the primary argument to determine the goal service (e.g.,
drive). - It fetches that service’s Google Discovery Doc (cached for twenty-four hours).
- It builds a command tree from the doc’s assets and strategies.
- It parses the remaining arguments, authenticates, and executes the HTTP request.
Due to this structure, gws routinely helps new Google Workspace API endpoints the second they’re added to the Discovery Service.
Core Options for Software program Engineers and Information Scientists
The CLI will be put in by way of npm (npm set up -g @googleworkspace/cli) or constructed from supply (cargo set up --path .). As soon as put in, it affords a number of built-in utilities for knowledge extraction and automation:
- Introspection and Preview: Each useful resource consists of
--helpdocumentation generated from the Discovery API. You may view the schema of any methodology (e.g.,gws schema drive.information.checklist) or use the--dry-runflag to preview the precise HTTP request earlier than execution. - Structured Information Extraction: By default, each response—together with errors and metadata—is returned as structured JSON.
- Auto-Pagination: For devs pulling giant datasets, the
--page-allflag routinely handles API cursors. It streams paginated outcomes as NDJSON (Newline Delimited JSON), which will be piped straight into command-line JSON processors:Bashgws drive information checklist --params '{"pageSize": 100}' --page-all | jq -r '.information[].title'
Integration with AI Brokers and MCP
A major use case for gws is serving as a tool-calling backend for Giant Language Fashions (LLMs).
- Mannequin Context Protocol (MCP) Server: By working
gws mcp -s drive,gmail,calendar, the CLI begins an MCP server overstdio. This exposes Workspace APIs as structured instruments that any MCP-compatible shopper (like Claude Desktop or VS Code) can natively name. - Pre-built Agent Expertise: The repository consists of over 100 Agent Expertise overlaying all supported APIs and customary workflows. AI Engineers can set up these straight into agent environments utilizing
npx abilities add github:googleworkspace/cli. - Gemini CLI Extension: Builders utilizing the Gemini CLI can set up the
gwsextension (gemini extensions set up https://github.com/googleworkspace/cli), permitting the native Gemini agent to inheritgwscredentials and handle Workspace assets natively. - Mannequin Armor (Response Sanitization): To mitigate immediate injection dangers when feeding API knowledge to an LLM,
gwshelps Google Cloud Mannequin Armor. Passing the--sanitizeflag scans API responses for malicious payloads earlier than the info reaches your agent.
Authentication Workflows
The CLI handles authentication securely throughout totally different environments, changing the necessity for guide token administration in customized scripts. Priority is given to specific tokens, adopted by credentials information, and eventually native keyring storage.
- Native Desktop: Working
gws auth setupinitiates an interactive stream to configure a Google Cloud mission, allow essential APIs, and deal with OAuth login. Credentials are encrypted at relaxation utilizing AES-256-GCM and saved within the OS keyring. - Headless / CI/CD: For server environments, builders can full the interactive auth domestically and export the plaintext credentials:Bash
gws auth export --unmasked > credentials.jsonOn the headless machine, level the CLI to this file utilizing an surroundings variable:export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/credentials.json. - Service Accounts:
gwsnatively helps server-to-server Service Account key information and Area-Large Delegation by way of theGOOGLE_WORKSPACE_CLI_IMPERSONATED_USERvariable.
Take a look at the Repo right here. Additionally, be happy to comply with us on Twitter and don’t overlook to hitch our 120k+ ML SubReddit and Subscribe to our E-newsletter. Wait! are you on telegram? now you’ll be able to be part of us on telegram as effectively.