CRM & Automation10 min read

Google Workspace CLI Agent: Automate Docs and Sheets

Automate Google Docs, Sheets, and Slides with the Workspace CLI agent and MCP server. Setup, personas, recipe templates, and workflow automation guide.

Digital Applied Team
March 21, 2026
10 min read
50+

Workspace API Operations

10

Pre-Built Persona Profiles

40+

Built-In Recipe Templates

3

Auth Methods Supported

Key Takeaways

One CLI accesses Docs, Sheets, Slides, Drive, and Calendar: The Google Workspace CLI (gws) exposes 50+ API operations across every major Workspace application through a single command interface. Creating a Doc from a template, pulling Sheets data, and updating a Slides deck are all single-command operations that return structured JSON for pipeline integration.
The built-in MCP server connects Workspace to any AI agent: Running gws mcp -s docs,sheets,slides,drive starts a Model Context Protocol server that exposes selected Workspace APIs as tools for AI agents. Claude, Gemini CLI, and VS Code extensions can then create documents, update spreadsheets, and generate presentations through natural language without custom integration code.
Personas store named credential profiles for multi-account environments: The gws persona system allows storing and switching between multiple Google account configurations. Teams managing multiple client Workspace environments can define a persona per client and switch contexts with a single flag, eliminating the need to re-authenticate or maintain separate environment variables per account.
Recipes bundle multi-step operations into reusable templates: The recipe system chains multiple CLI commands into executable workflow templates. A Sheets-to-Docs report recipe might pull data from a spreadsheet, format it, and insert it into a document template — all executed from a single recipe command, with inputs parameterized for reuse across different data sources.

Automating Google Workspace has historically required choosing between two unsatisfying options: Google Apps Script, which is powerful but limited to JavaScript and locked inside Google's cloud, or the Workspace REST APIs directly, which require managing OAuth flows, client libraries, and boilerplate code for each separate application. The Google Workspace CLI (gws) collapses both paths into a single command-line interface that covers Docs, Sheets, Slides, Drive, and the rest of the Workspace suite.

This guide focuses specifically on practical automation for the three most commonly automated Workspace applications — Docs, Sheets, and Slides — and on connecting gws to AI agents through its built-in MCP server. The patterns here apply to agencies managing client reports, operations teams building internal dashboards, and developers integrating Workspace into broader automation pipelines. For the architectural overview of how gws works across all 50+ Workspace APIs, see our companion guide on Google Workspace CLI and AI agent automation. For context on how these automation patterns fit into broader CRM and automation workflows, the CLI approach integrates cleanly with existing marketing and sales automation stacks.

Workspace CLI for Docs, Sheets, and Slides

The gws CLI treats every Workspace application as a namespace of commands. The pattern is consistent across all applications:gws [application] [resource] [operation] [flags]. This predictable structure means that once you understand how to list Drive files, you already understand how to list Docs documents, Sheets spreadsheets, or Calendar events — the pattern transfers across the entire CLI.

Google Docs

Create documents from templates, read full document structure as JSON, insert and update content blocks, set named styles, and manage document sharing permissions. Ideal for report generation and template-based document production.

Google Sheets

Read and write cell ranges, batch update values, manage named ranges, add or remove sheets, configure data validation, and pull or push entire spreadsheets as local TSV files. Core tool for data pipeline automation.

Google Slides

Create presentations, update text and image placeholders, add new slides from layouts, set speaker notes, manage slide order, and export as PDF or PNG. Enables batch presentation generation from data sources.

Every command returns structured JSON by default. This is deliberate — it makes gws composable with existing Unix toolchains. Pipe output to jq for filtering, feed it into Python for transformation, or pass it to shell scripts for further processing. The composability is what distinguishes gws from the Apps Script approach: every operation is a building block for larger pipelines rather than an isolated in-cloud function.

Installation and Credential Configuration

Installation requires a single npm command. The CLI is distributed as a pre-compiled binary wrapped in an npm package, so no Rust toolchain or compilation step is needed. After installation, you create a Google Cloud project, enable the required Workspace APIs, and configure OAuth credentials. The CLI handles the OAuth flow and stores credentials encrypted in your OS keyring.

Installation and Setup Commands

Install globally via npm

npm install -g @googleworkspace/cli

Authenticate with interactive OAuth

gws auth login

Create a named persona profile

gws persona create --name client-reports

Verify authentication and list personas

gws auth status && gws persona list

Service account auth (CI/CD)

gws auth login --service-account ./service-key.json

Automating Google Docs with the CLI

Google Docs automation with gws covers three primary use cases: generating new documents from templates, reading document content for data extraction, and updating existing documents with new content. The template generation pattern is the most common for agency and operations workflows: maintain a master Docs template with named placeholders, then use the CLI to copy the template and replace placeholders with dynamic data on each execution.

Core Docs Automation Commands

Copy template to create new document

gws drive files copy --file-id {TEMPLATE_ID} --name "Client Report March 2026"

Replace named placeholder in document

gws docs documents batchUpdate --document-id {DOC_ID} --body '{"requests":[{"replaceAllText":{"containsText":{"text":"{{CLIENT_NAME}}"},"replaceText":"Acme Corp"}}]}'

Insert formatted text at end of document

gws docs documents batchUpdate --document-id {DOC_ID} --body @insert-block.json

Read full document content as JSON

gws docs documents get --document-id {DOC_ID} | jq '.body.content'

For report generation workflows, the recommended pattern is to manage heavy formatting in the template itself and use the CLI only to insert dynamic content. Attempting to apply complex formatting through batchUpdate requests is verbose and error-prone. Templates handle the structure; the CLI handles the data. This separation of concerns also makes templates easier to update independently of automation scripts.

Sheets Data Pipelines via the CLI

Sheets is the most data-dense application in Workspace automation, and the gws CLI treats it accordingly. Beyond simple read and write operations, gws supports the git-like pull and push workflow that makes Sheets data a first-class participant in development pipelines: pull a spreadsheet as a local TSV file, transform it with any tool, and push changes back. This pattern enables version control, CI/CD integration, and bulk transformation workflows that are impossible with browser-based Sheets editing.

Range Read / Write

Read specific cell ranges as JSON arrays and write updated values back in batch. Efficient for targeted updates to specific reporting sections without downloading the full spreadsheet.

gws sheets values get --spreadsheet-id {ID} --range "Summary!A1:F20"
Pull / Push Workflow

Pull the full spreadsheet as TSV plus formula.json, edit locally with any script or editor, push changes back. Enables version control and CI/CD pipeline integration for spreadsheet data.

gws sheets pull --spreadsheet-id {ID} --output ./data/
Batch Value Updates

Update multiple non-contiguous ranges in a single API call using batchUpdate. Critical for efficiency when populating dashboard sheets with data from multiple sources simultaneously.

gws sheets values batchUpdate --spreadsheet-id {ID} --body @updates.json
Append Rows

Append new rows to the first empty row after a data range. Common for logging workflows, daily data accumulation pipelines, and audit trail sheets that receive new entries on each automation run.

gws sheets values append --spreadsheet-id {ID} --range "Log!A:F" --body @new-row.json

Slides Generation and Batch Automation

Batch presentation generation is one of the most time-consuming manual tasks in agency workflows — creating variations of a standard template for different clients, campaigns, or time periods. The gws slides commands make this scriptable: define a master template with named placeholders for text and images, maintain a Sheets spreadsheet with the variable data for each presentation, and run a script that iterates through the spreadsheet rows, copying the template and populating placeholders for each row.

Batch Slides Generation Pattern
1

Pull data: Read the Sheets spreadsheet containing presentation variables — client names, metrics, dates, and image URLs — as a JSON array using the range read command.

2

Copy template: Use gws drive files copy to duplicate the master template presentation for each row in the data source.

3

Replace placeholders: Run batchUpdate on each new presentation to replace text placeholders with row-specific values and update image URLs for client logos or charts.

4

Organize and share: Move each presentation to the appropriate client folder in Drive and set sharing permissions using gws drive permissions commands.

MCP Server for AI Agent Orchestration

The most significant capability addition in gws is the built-in Model Context Protocol server that transforms the CLI into an AI agent toolkit. Instead of writing a script that calls specific gws commands in a predetermined sequence, you connect an AI agent to the MCP server and describe the desired outcome in natural language. The agent determines which gws tools to call, in what order, and with what parameters — adapting its approach based on the results of each step.

Starting the MCP Server

The -s flag controls which Workspace services are exposed to connected agents. Expose only the services required for the workflow to minimize unnecessary scope.

gws mcp -s docs,sheets,slides,drive
Claude Desktop Config

Add gws as an MCP server in Claude Desktop configuration. Claude can then create, edit, and organize Docs, Sheets, and Slides through conversation without additional setup.

{"mcpServers":{"gws":{"command":"gws","args":["mcp","-s","docs,sheets"]}}}

The practical workflow difference is significant. A scripted gws automation executes the same steps in the same order every time. An AI agent connected through MCP can adapt — if a template file is not found, it can search Drive for the latest version; if a spreadsheet row has missing data, it can skip or flag rather than error. This adaptability makes the MCP approach better for workflows with variable inputs, while scripted approaches remain better for high-volume, identical-operation automation where predictability is more important than flexibility.

Personas and Recipe Templates

Two gws features that significantly improve automation workflow ergonomics are personas and recipes. Personas address the multi-account problem. Recipes address the workflow reuse problem. Together, they transform a set of individual CLI commands into a structured automation library that scales across projects, clients, and team members.

Personas: Multi-Account Profiles

Create a named persona for each Google account context. Agencies can define a persona per client. Teams with separate staging and production Workspace environments can define one per environment. Switch context with a single flag on any command.

gws persona create --name client-agws sheets values get --persona client-a ...
Recipes: Reusable Workflow Templates

Define multi-step command sequences as named recipes with parameterized inputs. A "monthly-report" recipe accepts a spreadsheet ID and client name, executes the full pull, transform, and insert workflow, and can be run by any team member with a single command.

gws recipe run monthly-report --spreadsheet-id {ID}

The 40+ built-in recipes that ship with gws cover common business workflows including weekly team updates, client onboarding document generation, project status report compilation, and meeting recap distribution. Each built-in recipe can be inspected with gws recipe show [name] to understand its structure and use it as a template for custom recipes. The recipe format is declarative JSON, making it straightforward to version-control alongside your automation scripts.

Building Multi-Step Workflow Automations

The most valuable gws automations chain multiple Workspace applications together in workflows that would require significant API integration effort to build from scratch. The client monthly report workflow is a representative example: pull performance data from a Sheets dashboard, insert a formatted summary into a Docs report template, update a Slides executive summary deck with the headline numbers, and share both documents with the client via Drive. Each step is a gws command; the workflow is a shell script or recipe that sequences them.

Monthly Client Reporting

Pull metrics from Sheets dashboard, populate Docs report template, update Slides deck with headline KPIs, share via Drive with client permissions. Replaces 45 minutes of manual copy-paste with a single recipe command.

Client Onboarding Package

Create shared Drive folder structure, copy onboarding Docs templates with client-specific data, generate Slides kickoff deck from project brief, schedule kickoff meeting via Calendar, send welcome email via Gmail.

Project Status Updates

Read task data from a project tracking spreadsheet, update a shared status Docs document with this week's completions and blockers, append a log row to the master tracking sheet, and send a summary email to stakeholders via Gmail.

Data Consolidation Pipelines

Pull data from multiple Sheets sources, transform and merge using Python or jq, push consolidated results to a master dashboard spreadsheet. Runs on schedule via cron or triggered by CI/CD events.

Conclusion

The Google Workspace CLI brings scriptable, composable automation to Docs, Sheets, Slides, and the rest of the Workspace suite in a way that neither Apps Script nor direct API integration has matched for practical usability. The CLI-first architecture means workflows integrate naturally with existing shell pipelines, Python scripts, and CI/CD systems. The MCP server adds AI agent orchestration without custom integration code. Personas and recipes provide the workflow management layer for teams operating at scale.

The pre-v1 caveat remains relevant: production-critical workflows should be tested carefully with each version update, and the tool should be treated as a developer sample rather than a supported product until v1.0 arrives. For teams willing to work within those constraints, gws is currently the most capable and accessible path to automating Workspace at the CLI and agent level. The investment in learning the tool now produces directly transferable skills for the stable release.

Ready to Automate Your Workspace Workflows?

Workspace automation is one component of a broader CRM and automation strategy. Our team helps businesses design and implement workflow automation that scales across operations, client reporting, and team productivity.

Free consultation
Expert guidance
Tailored solutions

Related Articles

Continue exploring with these related guides