productivity
Google Sheets CLI for AI Agents
Use the Google Sheets CLI from KosmoKrator to call Google Sheets tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.Google Sheets CLI Setup
Google Sheets can be configured headlessly with `kosmokrator integrations:configure google-sheets`.
# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash
# Configure and verify this integration.
kosmokrator integrations:configure google-sheets --set access_token="$GOOGLE_SHEETS_ACCESS_TOKEN" --enable --read allow --write ask --json
kosmokrator integrations:doctor google-sheets --json
kosmokrator integrations:status --json Credentials
Authentication type: OAuth browser flow oauth2_authorization_code. Configure credentials once, then reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.
| Key | Env var | Type | Required | Label |
|---|---|---|---|---|
access_token | GOOGLE_SHEETS_ACCESS_TOKEN | OAuth token oauth | yes | Google Account |
Command Patterns
The generic command is stable across every integration. The provider shortcut is shorter for humans.
kosmo integrations:call google-sheets.google_sheets_add_filter '{"spreadsheet_id":"example_spreadsheet_id","range":"example_range"}' --json kosmo integrations:google-sheets google_sheets_add_filter '{"spreadsheet_id":"example_spreadsheet_id","range":"example_range"}' --json Discovery
These commands return structured output for coding agents that need to inspect capabilities before choosing a function.
kosmo integrations:docs google-sheets --json
kosmo integrations:docs google-sheets.google_sheets_add_filter --json
kosmo integrations:schema google-sheets.google_sheets_add_filter --json
kosmo integrations:search "Google Sheets" --json
kosmo integrations:list --json Automation Contexts
The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.
CLI Functions
Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.
google-sheets.google_sheets_add_filter
Apply filter dropdowns to a range in a Google Sheets sheet/tab.
write - Parameters
- spreadsheet_id, range
kosmo integrations:call google-sheets.google_sheets_add_filter '{"spreadsheet_id":"example_spreadsheet_id","range":"example_range"}' --json kosmo integrations:google-sheets google_sheets_add_filter '{"spreadsheet_id":"example_spreadsheet_id","range":"example_range"}' --json google-sheets.google_sheets_add_sheet
Add a new sheet/tab to a Google Spreadsheet.
write - Parameters
- spreadsheet_id, title
kosmo integrations:call google-sheets.google_sheets_add_sheet '{"spreadsheet_id":"example_spreadsheet_id","title":"example_title"}' --json kosmo integrations:google-sheets google_sheets_add_sheet '{"spreadsheet_id":"example_spreadsheet_id","title":"example_title"}' --json google-sheets.google_sheets_append
Append rows after the last data row in a Google Spreadsheet. Auto-detects the table boundary. Provide the range (e.g., "Sheet1" or "Sheet1!A:D") and a 2D array of rows to append.
read - Parameters
- spreadsheet_id, range, values, input
kosmo integrations:call google-sheets.google_sheets_append '{"spreadsheet_id":"example_spreadsheet_id","range":"example_range","values":"example_values","input":"example_input"}' --json kosmo integrations:google-sheets google_sheets_append '{"spreadsheet_id":"example_spreadsheet_id","range":"example_range","values":"example_values","input":"example_input"}' --json google-sheets.google_sheets_batch_read
Read multiple ranges from a Google Spreadsheet in one call. Provide an array of A1 notation ranges (e.g., ["Sheet1!A1:B5", "Sheet2!C1:D10"]). Returns results keyed by range.
read - Parameters
- spreadsheet_id, ranges, render
kosmo integrations:call google-sheets.google_sheets_batch_read '{"spreadsheet_id":"example_spreadsheet_id","ranges":"example_ranges","render":"example_render"}' --json kosmo integrations:google-sheets google_sheets_batch_read '{"spreadsheet_id":"example_spreadsheet_id","ranges":"example_ranges","render":"example_render"}' --json google-sheets.google_sheets_batch_write
Write to multiple ranges in a Google Spreadsheet in one call. Provide an array of {range, values} objects to update several areas at once.
read - Parameters
- spreadsheet_id, data, input
kosmo integrations:call google-sheets.google_sheets_batch_write '{"spreadsheet_id":"example_spreadsheet_id","data":"example_data","input":"example_input"}' --json kosmo integrations:google-sheets google_sheets_batch_write '{"spreadsheet_id":"example_spreadsheet_id","data":"example_data","input":"example_input"}' --json google-sheets.google_sheets_clear
Clear all values from a Google Sheets range (keeps formatting intact). Specify the range in A1 notation.
read - Parameters
- spreadsheet_id, range
kosmo integrations:call google-sheets.google_sheets_clear '{"spreadsheet_id":"example_spreadsheet_id","range":"example_range"}' --json kosmo integrations:google-sheets google_sheets_clear '{"spreadsheet_id":"example_spreadsheet_id","range":"example_range"}' --json google-sheets.google_sheets_create
Create a new empty Google Spreadsheet with a given title. Returns the new spreadsheet ID and URL.
read - Parameters
- title
kosmo integrations:call google-sheets.google_sheets_create '{"title":"example_title"}' --json kosmo integrations:google-sheets google_sheets_create '{"title":"example_title"}' --json google-sheets.google_sheets_delete_columns
Delete columns from a Google Sheets sheet/tab. Uses 0-based indexing.
write - Parameters
- spreadsheet_id, sheet, start_index, count
kosmo integrations:call google-sheets.google_sheets_delete_columns '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet","start_index":1,"count":1}' --json kosmo integrations:google-sheets google_sheets_delete_columns '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet","start_index":1,"count":1}' --json google-sheets.google_sheets_delete_rows
Delete rows from a Google Sheets sheet/tab. Uses 0-based indexing.
write - Parameters
- spreadsheet_id, sheet, start_index, count
kosmo integrations:call google-sheets.google_sheets_delete_rows '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet","start_index":1,"count":1}' --json kosmo integrations:google-sheets google_sheets_delete_rows '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet","start_index":1,"count":1}' --json google-sheets.google_sheets_delete_sheet
Delete a sheet/tab from a Google Spreadsheet.
write - Parameters
- spreadsheet_id, sheet
kosmo integrations:call google-sheets.google_sheets_delete_sheet '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet"}' --json kosmo integrations:google-sheets google_sheets_delete_sheet '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet"}' --json google-sheets.google_sheets_duplicate_sheet
Copy a sheet/tab within the same Google Spreadsheet.
write - Parameters
- spreadsheet_id, sheet, title
kosmo integrations:call google-sheets.google_sheets_duplicate_sheet '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet","title":"example_title"}' --json kosmo integrations:google-sheets google_sheets_duplicate_sheet '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet","title":"example_title"}' --json google-sheets.google_sheets_find
Search for text within a Google Spreadsheet. Searches all sheets by default, or specify a sheet name to narrow the search. Returns match count and number of sheets containing matches.
read - Parameters
- spreadsheet_id, query, sheet, match_case, match_entire_cell
kosmo integrations:call google-sheets.google_sheets_find '{"spreadsheet_id":"example_spreadsheet_id","query":"example_query","sheet":"example_sheet","match_case":true,"match_entire_cell":true}' --json kosmo integrations:google-sheets google_sheets_find '{"spreadsheet_id":"example_spreadsheet_id","query":"example_query","sheet":"example_sheet","match_case":true,"match_entire_cell":true}' --json google-sheets.google_sheets_get_metadata
Get spreadsheet title and list of sheets/tabs with their names, IDs, and dimensions. Use this first to discover sheet names and structure before reading or writing data.
read - Parameters
- spreadsheet_id
kosmo integrations:call google-sheets.google_sheets_get_metadata '{"spreadsheet_id":"example_spreadsheet_id"}' --json kosmo integrations:google-sheets google_sheets_get_metadata '{"spreadsheet_id":"example_spreadsheet_id"}' --json google-sheets.google_sheets_insert_columns
Insert blank columns into a Google Sheets sheet/tab. Uses 0-based indexing.
read - Parameters
- spreadsheet_id, sheet, start_index, count
kosmo integrations:call google-sheets.google_sheets_insert_columns '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet","start_index":1,"count":1}' --json kosmo integrations:google-sheets google_sheets_insert_columns '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet","start_index":1,"count":1}' --json google-sheets.google_sheets_insert_rows
Insert blank rows into a Google Sheets sheet/tab. Uses 0-based indexing.
read - Parameters
- spreadsheet_id, sheet, start_index, count
kosmo integrations:call google-sheets.google_sheets_insert_rows '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet","start_index":1,"count":1}' --json kosmo integrations:google-sheets google_sheets_insert_rows '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet","start_index":1,"count":1}' --json google-sheets.google_sheets_read_range
Read cell values from a Google Sheets range using A1 notation. A1 notation examples: `Sheet1!A1:D10` (range), `Sheet1!A:A` (whole column), `Sheet1` (entire sheet). Sheet names with spaces need quotes: `'My Sheet'!A1:B2`.
read - Parameters
- spreadsheet_id, range, render
kosmo integrations:call google-sheets.google_sheets_read_range '{"spreadsheet_id":"example_spreadsheet_id","range":"example_range","render":"example_render"}' --json kosmo integrations:google-sheets google_sheets_read_range '{"spreadsheet_id":"example_spreadsheet_id","range":"example_range","render":"example_render"}' --json google-sheets.google_sheets_remove_filter
Remove the filter from a Google Sheets sheet/tab.
write - Parameters
- spreadsheet_id, sheet
kosmo integrations:call google-sheets.google_sheets_remove_filter '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet"}' --json kosmo integrations:google-sheets google_sheets_remove_filter '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet"}' --json google-sheets.google_sheets_rename_sheet
Rename a sheet/tab in a Google Spreadsheet.
read - Parameters
- spreadsheet_id, sheet, title
kosmo integrations:call google-sheets.google_sheets_rename_sheet '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet","title":"example_title"}' --json kosmo integrations:google-sheets google_sheets_rename_sheet '{"spreadsheet_id":"example_spreadsheet_id","sheet":"example_sheet","title":"example_title"}' --json google-sheets.google_sheets_sort_range
Sort data by column(s) in a Google Sheets range.
read - Parameters
- spreadsheet_id, range, sort_column, ascending
kosmo integrations:call google-sheets.google_sheets_sort_range '{"spreadsheet_id":"example_spreadsheet_id","range":"example_range","sort_column":1,"ascending":true}' --json kosmo integrations:google-sheets google_sheets_sort_range '{"spreadsheet_id":"example_spreadsheet_id","range":"example_range","sort_column":1,"ascending":true}' --json google-sheets.google_sheets_write_range
Write values to a Google Sheets range. Values format: `[["Name", "Age"], ["Alice", 30]]` — each inner array is one row. Formulas work with user_entered input mode (default): `[["=SUM(A1:A10)"]]`.
read - Parameters
- spreadsheet_id, range, values, input
kosmo integrations:call google-sheets.google_sheets_write_range '{"spreadsheet_id":"example_spreadsheet_id","range":"example_range","values":"example_values","input":"example_input"}' --json kosmo integrations:google-sheets google_sheets_write_range '{"spreadsheet_id":"example_spreadsheet_id","range":"example_range","values":"example_values","input":"example_input"}' --json Function Schemas
Use these parameter tables when building CLI payloads without calling integrations:schema first.
google-sheets.google_sheets_add_filter 2 parameters
kosmo integrations:schema google-sheets.google_sheets_add_filter --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
range | string | yes | A1 notation range including header row (e.g., "Sheet1!A1:D10"). |
google-sheets.google_sheets_add_sheet 2 parameters
kosmo integrations:schema google-sheets.google_sheets_add_sheet --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
title | string | yes | Name for the new sheet/tab. |
google-sheets.google_sheets_append 4 parameters
kosmo integrations:schema google-sheets.google_sheets_append --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
range | string | yes | A1 notation range (e.g., "Sheet1" or "Sheet1!A:D"). |
values | array | yes | 2D array of rows to append (e.g., [["Alice", 30], ["Bob", 25]]). |
input | string | no | Input mode: "user_entered" (default, parses formulas/dates) or "raw" (literal strings). |
google-sheets.google_sheets_batch_read 3 parameters
kosmo integrations:schema google-sheets.google_sheets_batch_read --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
ranges | array | yes | Array of A1 notation ranges (e.g., ["Sheet1!A1:B5", "Sheet2!C1:D10"]). |
render | string | no | Value rendering: "formatted" (default, as displayed), "unformatted" (raw numbers), or "formula" (shows formulas). |
google-sheets.google_sheets_batch_write 3 parameters
kosmo integrations:schema google-sheets.google_sheets_batch_write --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
data | array | yes | Array of {range, values} objects (e.g., [{"range": "Sheet1!A1:B2", "values": [["a", "b"]]}]). |
input | string | no | Input mode: "user_entered" (default, parses formulas/dates) or "raw" (literal strings). |
google-sheets.google_sheets_clear 2 parameters
kosmo integrations:schema google-sheets.google_sheets_clear --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
range | string | yes | A1 notation range to clear (e.g., "Sheet1!A1:D10"). |
google-sheets.google_sheets_create 1 parameters
kosmo integrations:schema google-sheets.google_sheets_create --json | Parameter | Type | Required | Description |
|---|---|---|---|
title | string | yes | Title for the new spreadsheet. |
google-sheets.google_sheets_delete_columns 4 parameters
kosmo integrations:schema google-sheets.google_sheets_delete_columns --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
sheet | string | yes | Sheet/tab name. |
start_index | integer | yes | 0-based column index to start deleting from. |
count | integer | no | Number of columns to delete (default 1). |
google-sheets.google_sheets_delete_rows 4 parameters
kosmo integrations:schema google-sheets.google_sheets_delete_rows --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
sheet | string | yes | Sheet/tab name. |
start_index | integer | yes | 0-based row index to start deleting from. |
count | integer | no | Number of rows to delete (default 1). |
google-sheets.google_sheets_delete_sheet 2 parameters
kosmo integrations:schema google-sheets.google_sheets_delete_sheet --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
sheet | string | yes | Sheet/tab name to delete. |
google-sheets.google_sheets_duplicate_sheet 3 parameters
kosmo integrations:schema google-sheets.google_sheets_duplicate_sheet --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
sheet | string | yes | Source sheet/tab name to duplicate. |
title | string | no | Name for the copy (defaults to "Copy of {name}"). |
google-sheets.google_sheets_find 5 parameters
kosmo integrations:schema google-sheets.google_sheets_find --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
query | string | yes | Text to search for. |
sheet | string | no | Sheet name to search in. Omit to search all sheets. |
match_case | boolean | no | Case-sensitive search. Default false. |
match_entire_cell | boolean | no | Match entire cell content only. Default false. |
google-sheets.google_sheets_get_metadata 1 parameters
kosmo integrations:schema google-sheets.google_sheets_get_metadata --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
google-sheets.google_sheets_insert_columns 4 parameters
kosmo integrations:schema google-sheets.google_sheets_insert_columns --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
sheet | string | yes | Sheet/tab name. |
start_index | integer | yes | 0-based column index to insert at. |
count | integer | no | Number of columns to insert (default 1). |
google-sheets.google_sheets_insert_rows 4 parameters
kosmo integrations:schema google-sheets.google_sheets_insert_rows --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
sheet | string | yes | Sheet/tab name. |
start_index | integer | yes | 0-based row index to insert at. |
count | integer | no | Number of rows to insert (default 1). |
google-sheets.google_sheets_read_range 3 parameters
kosmo integrations:schema google-sheets.google_sheets_read_range --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
range | string | yes | A1 notation range (e.g., "Sheet1!A1:D10", "Sheet1!A:A", "Sheet1"). |
render | string | no | Value rendering: "formatted" (default, as displayed), "unformatted" (raw numbers), or "formula" (shows formulas). |
google-sheets.google_sheets_remove_filter 2 parameters
kosmo integrations:schema google-sheets.google_sheets_remove_filter --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
sheet | string | yes | Sheet/tab name to remove the filter from. |
google-sheets.google_sheets_rename_sheet 3 parameters
kosmo integrations:schema google-sheets.google_sheets_rename_sheet --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
sheet | string | yes | Current sheet/tab name. |
title | string | yes | New name for the sheet/tab. |
google-sheets.google_sheets_sort_range 4 parameters
kosmo integrations:schema google-sheets.google_sheets_sort_range --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
range | string | yes | A1 notation range to sort (e.g., "Sheet1!A1:D10"). |
sort_column | integer | yes | 0-based column index within the range to sort by. |
ascending | boolean | no | Sort ascending (true, default) or descending (false). |
google-sheets.google_sheets_write_range 4 parameters
kosmo integrations:schema google-sheets.google_sheets_write_range --json | Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Spreadsheet ID (from the URL). |
range | string | yes | A1 notation range (e.g., "Sheet1!A1:D10"). |
values | array | yes | 2D array of values. Each inner array is a row (e.g., [["Name", "Age"], ["Alice", 30]]). |
input | string | no | Input mode: "user_entered" (default, parses formulas/dates) or "raw" (literal strings). |
Permissions
Headless calls still follow the integration read/write permission policy. Configure read/write defaults with
integrations:configure. Add --force only for trusted automation that should bypass that policy.