Google Docs CLI for AI Agents

Framework Integration Gradient
Google Docs Logo
CLI Logo
divider

Introduction

CLIs are eating MCPs. The industry is converging on the very same idea. MCPs for all their merit can be token hungry, slow, and unreliable for complex tool chaining. However, coding agents have become incredibly good at working with CLIs, and in fact they are far more comfortable working with CLI tools than MCP.

With Composio's Universal CLI, your coding agents can talk to over 850+ SaaS applications. With Google Docs, agents can create a new meeting notes document, copy last week's project summary template, add bullet points to the action items section, and more — all without worrying about authentication.

This guide walks you through Composio Universal CLI and explains how you can connect it with coding agents like Claude Code, Codex, OpenCode, etc, for end-to-end Google Docs automation.

Also integrate Google Docs with

What is Universal CLI and why use it?

The idea behind building the universal CLI is to give agents a single command interface to interact with all your external applications. Here's what you'll get with it:

  • Agent-friendly: Coding agents like Claude Code, Codex, and OpenCode can use CLI tools natively — no MCP setup required.
  • Authentication handled: Connect once via OAuth or API Key, and all CLI commands work with your credentials automatically.
  • Tool discovery: Search, inspect, and execute 20,000+ tools across 850+ apps from one interface.
  • Trigger support: Use triggers to listen for events across your apps, powered by real-time webhooks or polling under the hood.
  • Type generation: Generate typed schemas for autocomplete and type safety in your projects.

Prerequisites

Install the Composio CLI, authenticate, and initialize your project:

bash
# Install the Composio CLI
curl -fsSL https://composio.dev/install | bash

# Authenticate with Composio
composio login

During login you'll be redirected to sign in page, finish the complete flow and you're all set.

Composio CLI authentication flow

Connecting Google Docs to Coding Agents via Universal CLI

Once it is installed, it's essentially done. Claude Code, Codex, OpenCode, OpenClaw, or any other agent will be able to access the CLI. A few steps to give agents access to your apps.

  1. Launch your Coding Agent — Claude Code, Codex, OpenCode, anything you prefer.
  2. Prompt it to "Authenticate with Google Docs"
  3. Complete the authentication and authorization flow and your Google Docs integration is all set.
  4. Start asking anything you want.

Supported Tools & Triggers

Tools
Triggers
Copy Google DocumentTool to create a copy of an existing google document.
Create a documentCreates a new google docs document using the provided title as filename and inserts the initial text at the beginning if non-empty, returning the document's id and metadata (excluding body content).
Create Document MarkdownCreates a new google docs document, optionally initializing it with a title and content provided as markdown text.
Create FooterTool to create a new footer in a google document.
Create FootnoteTool to create a new footnote in a google document.
Create HeaderTool to create a new header in a google document.
Create Named RangeTool to create a new named range in a google document.
Create Paragraph BulletsTool to add bullets to paragraphs within a specified range in a google document.
Delete Content Range in DocumentTool to delete a range of content from a google document.
Delete FooterTool to delete a footer from a google document.
Delete HeaderDeletes the header from the specified section or the default header if no section is specified.
Delete Named RangeTool to delete a named range from a google document.
Delete Paragraph BulletsTool to remove bullets from paragraphs within a specified range in a google document.
Delete TableTool to delete an entire table from a google document.
Delete Table ColumnTool to delete a column from a table in a google document.
Delete Table RowTool to delete a row from a table in a google document.
Get Charts from SpreadsheetTool to retrieve a list of all charts from a specified google sheets spreadsheet.
Get document by idRetrieves an existing google document by its id; will error if the document is not found.
Insert Inline ImageTool to insert an image from a given uri at a specified location in a google document as an inline image.
Insert Page BreakTool to insert a page break into a google document.
Insert Table in Google DocTool to insert a table into a google document.
Insert Table ColumnTool to insert a new column into a table in a google document.
Insert Text into DocumentTool to insert a string of text at a specified location within a google document.
List Charts from SpreadsheetTool to retrieve a list of charts with their ids and metadata from a google sheets spreadsheet.
Replace All Text in DocumentTool to replace all occurrences of a specified text string with another text string throughout a google document.
Replace Image in DocumentTool to replace a specific image in a document with a new image from a uri.
Search DocumentsSearch for google documents using various filters including name, content, date ranges, and more.
Unmerge Table CellsTool to unmerge previously merged cells in a table.
Update Document MarkdownReplaces the entire content of an existing google docs document with new markdown text; requires edit permissions for the document.
Update Document StyleTool to update the overall document style, such as page size, margins, and default text direction.
Update existing documentApplies programmatic edits, such as text insertion, deletion, or formatting, to a specified google doc using the `batchupdate` api method.
Update Table Row StyleTool to update the style of a table row in a google document.

Universal CLI Commands for Google Docs

You can also manually execute CLI commands to interact with your Google Docs.

Connect your Google Docs account

Link your Google Docs account and verify the connection:

bash
# Connect your Google Docs account (opens OAuth flow)
composio connected-accounts link googledocs

# Verify the connection
composio connected-accounts list --toolkits googledocs

Discover Google Docs tools

Search and inspect available Google Docs tools:

bash
# List all available Google Docs tools
composio tools list --toolkit googledocs

# Search for Google Docs tools by action
composio tools search "google docs"

# Inspect a tool's input schema
composio tools info GOOGLEDOCS_COPY_DOCUMENT

Common Google Docs Actions

Copy Google DocumentTool to create a copy of an existing google document

bash
composio tools execute GOOGLEDOCS_COPY_DOCUMENT \
  --document_id "1a2b3c-example-document-id"

Create a documentCreates a new google docs document using the provided title as filename and inserts the initial text at the beginning if non-empty, returning the document's id and metadata (excluding body content)

bash
composio tools execute GOOGLEDOCS_CREATE_DOCUMENT \
  --text "This document outlines the key findings..." \
  --title "Quarterly Business Review"

Create Document MarkdownCreates a new google docs document, optionally initializing it with a title and content provided as markdown text

bash
composio tools execute GOOGLEDOCS_CREATE_DOCUMENT_MARKDOWN \
  --title "Meeting Notes Q3" \
  --markdown_text "<string>"

Create FooterTool to create a new footer in a google document

bash
composio tools execute GOOGLEDOCS_CREATE_FOOTER \
  --type "DEFAULT" \
  --document_id "12345abcdef"

Set up Google Docs Triggers

Listen for events in real time using triggers:

New Document CreatedTriggers when a new Google Doc is created

bash
# Find your connected account ID
composio connected-accounts list --toolkits googledocs

# Create a trigger
composio triggers create GOOGLEDOCS_DOCUMENT_CREATED_TRIGGER \
  --connected-account-id <your-connected-account-id> \
  --trigger-config '{
  "query": "name contains 'report'",
  "interval": 2,
  "max_results": 100
}'

# Listen for trigger events in real time
composio triggers listen --toolkits googledocs --table

Document DeletedTriggers when an existing Google Doc is deleted (moved to trash)

bash
# Find your connected account ID
composio connected-accounts list --toolkits googledocs

# Create a trigger
composio triggers create GOOGLEDOCS_DOCUMENT_DELETED_TRIGGER \
  --connected-account-id <your-connected-account-id> \
  --trigger-config '{
  "query": "name contains 'report'",
  "interval": 2,
  "max_results": 10
}'

# Listen for trigger events in real time
composio triggers listen --toolkits googledocs --table

Document Placeholder FilledTriggers when a Google Doc's plain text changes such that a configured placeholder token/pattern is no longer present (i

bash
# Find your connected account ID
composio connected-accounts list --toolkits googledocs

# Create a trigger
composio triggers create GOOGLEDOCS_DOCUMENT_PLACEHOLDER_FILLED_TRIGGER \
  --connected-account-id <your-connected-account-id> \
  --trigger-config '{
  "document_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
  "case_sensitive": true,
  "include_footers": "<boolean>"
}'

# Listen for trigger events in real time
composio triggers listen --toolkits googledocs --table

Generate Type Definitions

Generate typed schemas for Google Docs tools to get autocomplete and type safety in your project:

bash
# Auto-detect language
composio generate --toolkits googledocs

# TypeScript
composio ts generate --toolkits googledocs

# Python
composio py generate --toolkits googledocs

Tips & Tricks

  • Always inspect a tool's input schema before executing: composio tools info <TOOL_NAME>
  • Pipe output with jq for better readability: composio tools execute TOOL_NAME -d '{}' | jq
  • Set COMPOSIO_API_KEY as an environment variable for CI/CD pipelines
  • Use composio dev logs tools to inspect execution logs and debug issues

Next Steps

  • Try asking your coding agent to perform various Google Docs operations
  • Explore cross-app workflows by connecting more toolkits
  • Set up triggers for real-time automation
  • Use composio generate for typed schemas in your projects

How to build Google Docs MCP Agent with another framework

FAQ

What is the Composio Universal CLI?

The Composio Universal CLI is a single command-line interface that lets coding agents and developers interact with 850+ SaaS applications. It handles authentication, tool discovery, action execution, and trigger setup — all from the terminal, without needing to configure MCP servers.

Which coding agents work with the Composio CLI?

Any coding agent that can run shell commands works with the Composio CLI — including Claude Code, Codex, OpenCode, OpenClaw, and others. Once the CLI is installed, agents automatically discover and use the composio commands to interact with Google Docs and other connected apps.

How is the CLI different from using an MCP server for Google Docs?

MCP servers require configuration and can be token-heavy for complex workflows. The CLI gives agents a direct, lightweight interface — no server setup needed. Agents simply call composio commands like any other shell tool. It's faster to set up, more reliable for multi-step tool chaining, and works natively with how coding agents already operate.

How safe is my Google Docs data when using the Composio CLI?

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Google Docs data and credentials are handled as safely as possible. You can also bring your own OAuth credentials for full control.

Used by agents from

Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.