Google Workspace CLI (gws): AI Agent Automation Guide
Google Workspace CLI (gws) unifies 50+ APIs into one command with built-in MCP server for AI agents. Setup, personas, recipes, and automation workflows.
Google APIs Unified
GitHub Stars in 3 Days
Pre-Built Personas
Automated Recipes
Key Takeaways
Managing Google Workspace programmatically has historically meant juggling separate client libraries, OAuth configurations, and REST endpoints for each service. Drive has one API, Gmail has another, Calendar a third, and Sheets yet another. Google Workspace CLI changes this by collapsing all of those into a single gws command that dynamically discovers and exposes every Workspace API at runtime.
Released in early March 2026, the tool hit #1 on Hacker News with 571 points and gained 4,900 GitHub stars in three days. The traction reflects a real pain point: developers and businesses want a simpler, scriptable way to automate Workspace without writing boilerplate integration code. This guide covers everything from installation to building AI agent workflows with the built-in MCP server, including the practical limitations you need to understand before relying on a pre-v1 tool. For broader context on how AI and digital transformation tools like gws fit into modern business workflows, the pattern is clear: unified interfaces beat fragmented toolchains.
What Is Google Workspace CLI
Google Workspace CLI is an open-source command-line tool written in Rust and distributed as an npm package. It provides a single interface for interacting with more than 50 Google Workspace APIs including Drive, Gmail, Calendar, Sheets, Docs, Chat, Admin SDK, Vault, Groups, and many more. Instead of importing a different client library for each service, you install one tool and access everything through structured commands that return JSON output.
The project lives in the googleworkspace/cli GitHub repository under the Apache 2.0 license. It was created by engineers within the Google Workspace developer ecosystem, though the README prominently notes that it is not an officially supported Google product. This is a developer sample with expected breaking changes before reaching v1.0.
Written in Rust for performance and memory safety, distributed via npm for easy installation across macOS, Linux, and Windows without compiling from source.
Dynamically discovers all Workspace APIs at runtime using Google's Discovery Service. No manual updates when Google adds new API endpoints or features.
Ships with a Model Context Protocol server that exposes selected APIs as tools for AI agents like Claude Desktop, Gemini CLI, and VS Code extensions.
The Hacker News debut produced 571 points and hundreds of comments, with particular interest in the MCP server capability and the git-like spreadsheet workflow. Guillermo Rauch, CEO of Vercel, commented that “2026 is the year of Skills and CLIs,” pointing to gws as evidence that the command line is becoming the primary interface for both human operators and AI agents interacting with cloud services.
Installation and Authentication Setup
Installation is a single npm command. The Rust binary is pre-compiled for major platforms and distributed through the npm registry, so you do not need a Rust toolchain installed. For teams managing web development workflows, the npm distribution makes gws trivial to add to existing Node.js toolchains.
Install globally
npm install -g @googleworkspace/cliInteractive OAuth login
gws auth loginService account (CI/CD)
gws auth login --service-account ./key.jsonHeadless mode (no browser)
gws auth login --headlessThe interactive OAuth flow opens your default browser for Google consent. Once authorized, credentials are encrypted and stored in your operating system's keyring (macOS Keychain, Windows Credential Manager, or Linux Secret Service). For CI/CD pipelines and server environments, service account authentication bypasses the browser flow entirely. The headless mode provides a URL and verification code for environments where no browser is available.
Security note: OAuth tokens are scoped to the specific APIs you authorize. Unverified Google Cloud projects are limited to approximately 25 OAuth scopes. For production deployments requiring broader access, you will need a verified Google Cloud project with the appropriate API scopes approved.
Dynamic Discovery Across 50+ APIs
The core architectural decision that makes gws fundamentally different from previous Google Workspace tools is dynamic API discovery. Rather than hardcoding API endpoints and method signatures into the CLI binary, gws queries Google's Discovery Service at runtime to learn what APIs are available, what methods they expose, and what parameters each method accepts.
This means the tool automatically supports new API endpoints the moment Google publishes them to the Discovery Service, without requiring a CLI update. When Google adds a new method to the Gmail API or extends the Sheets API with new capabilities, gws picks them up on the next invocation.
List Drive files (JSON output)
gws drive files list --page-size 10Search Gmail messages
gws gmail messages list --query "from:client is:unread"List upcoming calendar events
gws calendar events list --calendar-id primary --time-min nowRead spreadsheet range
gws sheets values get --spreadsheet-id {ID} --range "Sheet1!A1:D10"Every command returns structured JSON by default, making it straightforward to pipe output into jq, feed it into scripts, or pass it to other tools in a pipeline. This is a deliberate design choice that makes gws composable with existing Unix workflows and automation systems. For teams already using automation platforms, see our comparison of Zapier vs Make vs n8n to understand where a CLI-based approach fits alongside visual automation builders.
MCP Server for AI Agent Integration
The feature that generated the most discussion on Hacker News is the built-in Model Context Protocol server. Running gws mcp starts a local MCP server that exposes selected Workspace APIs as tools that AI agents can discover and call. This turns your entire Google Workspace into an agent-accessible toolkit without writing any integration code.
Add the gws MCP server to your Claude Desktop configuration. Claude can then search Drive, read emails, create calendar events, and update spreadsheets through natural language.
gws mcp -s drive,gmail,calendarConnect gws to the Gemini CLI for a fully Google-native agent workflow. Gemini reasons about your request, then calls gws tools to execute Workspace operations.
gws mcp -s sheets,docs,chatThe -s flag controls which services are exposed to the agent. This is important for security: you can give an agent access to Calendar and Sheets without exposing Gmail or Admin operations. The MCP server also supports tool count limits (typically 50 to 100 tools per client) to stay within the context window constraints of different AI models. For a deeper look at MCP architecture and how it connects to Google Cloud services, see our guide on Google Cloud MCP servers for AI agents.
The practical implication is significant. An AI agent connected to the gws MCP server can execute multi-step workflows like “check my calendar for free slots this week, draft an email to the client proposing three meeting times, and create a shared Google Doc with the agenda” as a single conversation turn. Each step maps to a gws tool call that the agent orchestrates autonomously. For related patterns in building Claude skills with MCP for marketing automation, the same MCP architecture applies.
Personas, Recipes, and Agent Skills
Beyond raw API access, gws ships with a layer of pre-built abstractions designed for business users and AI agents. These come in three tiers: personas (role-based bundles), recipes (multi-step workflows), and skills (individual agent capabilities). Together they provide a structured path from “I have API access” to “I have working automation.”
Calendar management, email triage, meeting prep docs, travel coordination, and daily briefing generation. Bundles Gmail, Calendar, Docs, and Drive skills.
Timeline tracking via Sheets, task assignment, status reports, meeting scheduling, and stakeholder updates. Bundles Sheets, Calendar, Gmail, and Chat skills.
User provisioning, group management, security audit reports, license tracking, and domain settings. Bundles Admin SDK, Groups, and Directory skills.
Lead tracking in Sheets, follow-up email sequences, proposal document generation, meeting scheduling with prospects, and pipeline reporting. Bundles Sheets, Gmail, Docs, and Calendar skills.
The remaining personas cover content creators, customer support, event coordinators, team leads, researchers, and HR managers. Each persona is essentially a configuration file that specifies which API scopes to request, which skills to activate, and which recipes are available. You can customize existing personas or create new ones for your specific workflow needs. For organizations already using agent-based workflows, see our guide on Notion custom agents for autonomous workflows to compare approaches.
Recipes are the most immediately useful layer. A recipe is a multi-step workflow that chains several skills together. For example, the “weekly team update” recipe pulls calendar events for the past week, summarizes email threads from key stakeholders, compiles data from a tracking spreadsheet, and generates a formatted Google Doc report. The 40+ built-in recipes cover common business operations; the skill catalog of 100+ individual capabilities lets you compose custom recipes for anything the built-in ones do not cover.
Git-Like Pull and Push for Spreadsheets
One of the most distinctive features in gws is the ability to pull a Google Spreadsheet to your local filesystem, edit it with any tool, and push the changes back. This transforms spreadsheets from browser-only documents into files that participate in standard development workflows including version control, code review, and CI/CD pipelines.
Pull spreadsheet to local .tsv + formula.json
gws sheets pull --spreadsheet-id {ID} --output ./data/Edit locally (any editor, script, or pipeline)
# data/Sheet1.tsv — tab-separated values
# data/Sheet1.formula.json — preserved formulasPush changes back to Google Sheets
gws sheets push --spreadsheet-id {ID} --input ./data/The pull command exports each sheet tab as a .tsv file (tab-separated values) with an accompanying formula.json file that preserves cell formulas. This separation means you can process the raw data with standard Unix tools like awk, sed, or Python scripts while keeping formulas intact for the push back.
For agencies managing client reporting spreadsheets, this enables a powerful pattern: pull the reporting template, populate it programmatically from analytics APIs, commit the changes to Git for audit history, and push the finished report back to the shared Google Sheet. The entire workflow can run in a CI/CD pipeline on a schedule without any manual spreadsheet editing.
Security, Model Armor, and Dry-Run Mode
Exposing Workspace APIs to AI agents introduces legitimate security concerns. An agent with Gmail access could theoretically send emails on your behalf. An agent with Drive access could delete files. gws addresses this with several layers of protection designed for the specific risks of AI agent integration.
The --sanitize flag activates Google Model Armor to detect and block prompt injection attempts in data flowing through the MCP server.
The -s flag on the MCP server limits which services are exposed. Only grant agents access to the specific APIs they need for their task.
The --dry-run flag previews what a command would do without executing it. Essential for testing agent workflows before granting write access.
The Model Armor integration is particularly relevant for enterprise deployments. Prompt injection attacks, where malicious content in emails or documents attempts to manipulate the AI agent into unauthorized actions, are a real threat when agents have write access to production systems. The --sanitize flag routes data through Google's Model Armor service for injection detection before it reaches the agent's context window.
Recommended practice: Start every new agent workflow with --dry-run to verify the agent's behavior before enabling write operations. Use the most restrictive -s scope that still accomplishes the task, and enable --sanitize whenever agents process external data.
Agency and Business Automation Workflows
For digital agencies and businesses running on Google Workspace, gws enables automation patterns that previously required custom Apps Script code or third-party integration platforms. The combination of CLI scripting, MCP-powered agent workflows, and the git-like spreadsheet feature creates a flexible automation stack. Teams managing CRM and automation workflows benefit most from these patterns.
Pull reporting templates from Sheets, populate with analytics data via scripts, push back to shared client spreadsheets. Schedule weekly via cron or CI/CD. Eliminates manual copy-paste from dashboards.
Agent reads campaign briefs from Drive, drafts email sequences via Gmail, schedules send times against Calendar availability, and logs results to a tracking spreadsheet. One conversation turn handles the full workflow.
Create shared Drive folders, set up Calendar holds for kickoff meetings, generate onboarding docs from templates, and send welcome emails. The Project Manager persona handles this as a single recipe.
Search across Gmail, Drive, and Chat simultaneously for a client name or project keyword. Consolidate results into a single report. Essential for audits and knowledge retrieval across fragmented Workspace data.
The key advantage over visual automation platforms like Zapier or Make is composability. Each gws command is a building block that can be chained in shell scripts, called from Python, or invoked by an AI agent. There is no workflow builder UI to learn, no per-operation pricing to manage, and no platform lock-in. For teams already using HubSpot MCP server integrations, gws adds the Google Workspace side of the equation to create a complete agent-driven business automation stack.
Limitations and Pre-v1 Considerations
The enthusiasm around gws is justified by its technical ambition, but the tool comes with important caveats that affect whether and how you should use it in production workflows.
Not officially supported: Google does not provide SLA guarantees, formal support, or backward compatibility promises. The README is explicit: this is a developer sample, not a production product.
Breaking changes expected: Pre-v1 status means command syntax, flags, and output formats may change between releases. Pin your version in automation scripts and test after every update.
OAuth scope limits: Unverified Google Cloud projects are limited to approximately 25 OAuth scopes. If your workflow requires accessing many different APIs, you will hit this ceiling and need to go through Google's verification process.
Rate limits apply: All API calls go through Google's standard rate limiting. Heavy automation workflows, especially those pulling large spreadsheets or listing thousands of Drive files, need to handle rate limit errors and implement backoff logic.
Compared to Google Apps Script, gws fills a different niche. Apps Script is mature, officially supported, deeply integrated with Google services, and runs in Google's cloud. It is the right choice for simple in-document automations and triggers. gws is the right choice for complex multi-service workflows, AI agent integration, local scripting, and scenarios where you need to combine Workspace operations with non-Google tools. The two approaches are complementary rather than competitive.
The pragmatic recommendation is to experiment with gws now for internal tooling and development workflows where breaking changes are manageable. Reserve production client-facing automations for after the tool reaches v1.0 or until your team has enough experience to handle version upgrades confidently. The concepts and patterns you learn now, especially around MCP integration and persona configuration, will transfer directly to the stable release.
Conclusion
Google Workspace CLI represents a meaningful shift in how developers and businesses interact with Workspace. Unifying 50+ APIs behind a single command, adding AI agent support through MCP, and enabling git-like workflows for spreadsheets addresses three persistent friction points in Workspace automation. The tool is not production-ready in the traditional sense, but the architecture and patterns it introduces are worth learning now.
For agencies and businesses already building AI agent workflows, gws adds the missing Google Workspace layer. For teams still automating Workspace through Apps Script or visual platforms, it offers a preview of what CLI-first, agent-native Workspace integration will look like as the tool matures. The 4,900 stars in three days suggest the developer community agrees: this is the direction Workspace automation is heading.
Ready to Automate Google Workspace?
AI-powered Workspace automation is one component of a broader digital transformation strategy. Our team helps businesses design and implement agentic workflows that deliver measurable ROI.
Related Articles
Continue exploring with these related guides