Google Sheets CLI for AI Agents

Framework Integration Gradient
Google Sheets 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 Sheets, agents can add a new sheet named 'q3 sales', update all rows where status is 'pending', create a pie chart of expenses by category, 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 Sheets automation.

Also integrate Google Sheets 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 Sheets 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 Sheets"
  3. Complete the authentication and authorization flow and your Google Sheets integration is all set.
  4. Start asking anything you want.

Supported Tools & Triggers

Tools
Triggers
Add Sheet to SpreadsheetAdds a new sheet (worksheet) to a spreadsheet.
Aggregate Column DataSearches for rows where a specific column matches a value and performs mathematical operations on data from another column.
Append DimensionTool to append new rows or columns to a sheet, increasing its size.
Batch get spreadsheetRetrieves data from specified cell ranges in a google spreadsheet; ensure the spreadsheet has at least one worksheet and any explicitly referenced sheet names in ranges exist.
Batch update spreadsheetUpdates a specified range in a google sheet with given values, or appends them as new rows if `first cell location` is omitted; ensure the target sheet exists and the spreadsheet contains at least one worksheet.
Batch Update Values by Data FilterTool to update values in ranges matching data filters.
Clear Basic FilterTool to clear the basic filter from a sheet.
Clear spreadsheet valuesClears cell content (preserving formatting and notes) from a specified a1 notation range in a google spreadsheet; the range must correspond to an existing sheet and cells.
Create Chart in Google SheetsCreate a chart in a google sheets spreadsheet using the specified data range and chart type.
Create a Google SheetCreates a new google spreadsheet in google drive using the provided title.
Create spreadsheet columnCreates a new column in a google spreadsheet, requiring a valid `spreadsheet id` and an existing `sheet id`; an out-of-bounds `insert index` may append/prepend the column.
Create spreadsheet rowInserts a new, empty row into a specified sheet of a google spreadsheet at a given index, optionally inheriting formatting from the row above.
Delete Dimension (Rows/Columns)Tool to delete specified rows or columns from a sheet in a google spreadsheet.
Delete SheetTool to delete a sheet (worksheet) from a spreadsheet.
Execute SQL on SpreadsheetExecute sql queries against google sheets tables.
Find worksheet by titleFinds a worksheet by its exact, case-sensitive title within a google spreadsheet; returns a boolean indicating if found and the complete metadata of the entire spreadsheet, regardless of whether the target worksheet is found.
Format cellApplies text and background cell formatting to a specified range in a google sheets worksheet.
Get sheet namesLists all worksheet names from a specified google spreadsheet (which must exist), useful for discovering sheets before further operations.
Get Spreadsheet by Data FilterReturns the spreadsheet at the given id, filtered by the specified data filters.
Get spreadsheet infoRetrieves comprehensive metadata for a google spreadsheet using its id, excluding cell data.
Get Table SchemaThis action is used to get the schema of a table in a google spreadsheet, call this action to get the schema of a table in a spreadsheet before you query the table.
Insert Dimension in Google SheetTool to insert new rows or columns into a sheet at a specified location.
List Tables in SpreadsheetThis action is used to list all tables in a google spreadsheet, call this action to get the list of tables in a spreadsheet.
Look up spreadsheet rowFinds the first row in a google spreadsheet where a cell's entire content exactly matches the query string, searching within a specified a1 notation range or the first sheet by default.
Query Spreadsheet TableThis action is used to query a table in a google spreadsheet, call this action to query a table in a spreadsheet.
Search Developer MetadataTool to search for developer metadata in a spreadsheet.
Search SpreadsheetsSearch for google spreadsheets using various filters including name, content, date ranges, and more.
Set Basic FilterTool to set a basic filter on a sheet in a google spreadsheet.
Create sheet from JSONCreates a new google spreadsheet and populates its first worksheet from `sheet json`, which must be non-empty as its first item's keys establish the headers.
Copy Sheet to Another SpreadsheetTool to copy a single sheet from a spreadsheet to another spreadsheet.
Append Values to SpreadsheetTool to append values to a spreadsheet.
Batch Clear Spreadsheet ValuesTool to clear one or more ranges of values from a spreadsheet.
Batch Clear Values By Data FilterClears one or more ranges of values from a spreadsheet using data filters.
Batch Get Spreadsheet Values by Data FilterTool to return one or more ranges of values from a spreadsheet that match the specified data filters.
Update Sheet PropertiesTool to update properties of a sheet (worksheet) within a google spreadsheet, such as its title, index, visibility, tab color, or grid properties.
Update Spreadsheet PropertiesTool to update properties of a spreadsheet, such as its title, locale, or auto-recalculation settings.

Universal CLI Commands for Google Sheets

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

Connect your Google Sheets account

Link your Google Sheets account and verify the connection:

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

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

Discover Google Sheets tools

Search and inspect available Google Sheets tools:

bash
# List all available Google Sheets tools
composio tools list --toolkit googlesheets

# Search for Google Sheets tools by action
composio tools search "google sheets"

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

Common Google Sheets Actions

Add Sheet to SpreadsheetAdds a new sheet (worksheet) to a spreadsheet

bash
composio tools execute GOOGLESHEETS_ADD_SHEET \
  --spreadsheetId "abc123xyz789"

Aggregate Column DataSearches for rows where a specific column matches a value and performs mathematical operations on data from another column

bash
composio tools execute GOOGLESHEETS_AGGREGATE_COLUMN_DATA \
  --sheet_name "Sheet1" \
  --search_value "HSR" \
  --search_column "A" \
  --spreadsheet_id "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"

Append DimensionTool to append new rows or columns to a sheet, increasing its size

bash
composio tools execute GOOGLESHEETS_APPEND_DIMENSION \
  --length "10" \
  --sheet_id "<integer>" \
  --dimension "ROWS" \
  --spreadsheet_id "1q2w3e4r5t6y7u8i9o0p"

Batch get spreadsheetRetrieves data from specified cell ranges in a google spreadsheet; ensure the spreadsheet has at least one worksheet and any explicitly referenced sheet names in ranges exist

bash
composio tools execute GOOGLESHEETS_BATCH_GET \
  --spreadsheet_id "<string>"

Set up Google Sheets Triggers

Listen for events in real time using triggers:

Aggregate Metric ChangedTriggers when an aggregate metric (SUM/COUNT/AVG/MIN/MAX) changes in a Google Sheets spreadsheet

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

# Create a trigger
composio triggers create GOOGLESHEETS_AGGREGATE_METRIC_CHANGED_TRIGGER \
  --connected-account-id <your-connected-account-id> \
  --trigger-config '{
  "interval": 2,
  "case_sensitive": true,
  "has_header_row": true
}'

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

Cell Range Values ChangedTriggers when values in a specified A1 range change in Google Sheets

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

# Create a trigger
composio triggers create GOOGLESHEETS_CELL_RANGE_VALUES_CHANGED_TRIGGER \
  --connected-account-id <your-connected-account-id> \
  --trigger-config '{
  "range": "Sheet1!A1",
  "interval": 2,
  "spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
}'

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

Conditional Format Rule ChangedTriggers when conditional formatting rules change in a Google Spreadsheet

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

# Create a trigger
composio triggers create GOOGLESHEETS_CONDITIONAL_FORMAT_RULE_CHANGED_TRIGGER \
  --connected-account-id <your-connected-account-id> \
  --trigger-config '{
  "interval": 2,
  "sheet_id": "<integer>",
  "sheet_title": "Sheet1"
}'

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

Generate Type Definitions

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

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

# TypeScript
composio ts generate --toolkits googlesheets

# Python
composio py generate --toolkits googlesheets

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 Sheets 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 Sheets 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 Sheets and other connected apps.

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

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 Sheets 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 Sheets 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.