KosmoKrator

productivity

Google Docs CLI for AI Agents

Use the Google Docs CLI from KosmoKrator to call Google Docs tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

14 functions 11 read 3 write OAuth browser flow auth

Google Docs CLI Setup

Google Docs can be configured headlessly with `kosmokrator integrations:configure google_docs`.

# 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_docs --set access_token="$GOOGLE_DOCS_ACCESS_TOKEN" --enable --read allow --write ask --json
kosmokrator integrations:doctor google_docs --json
kosmokrator integrations:status --json

Credentials

Authentication type: OAuth browser flow oauth2_authorization_code. Configure credentials once, then use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
access_token GOOGLE_DOCS_ACCESS_TOKEN OAuth token oauth yes Google Account

Call Google Docs Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

kosmo integrations:call google_docs.google_docs_add_bullets '{
  "document_id": "example_document_id",
  "start_index": 1,
  "end_index": 1,
  "preset": "example_preset"
}' --json

Use the provider shortcut form for shorter human-facing commands.

kosmo integrations:google_docs google_docs_add_bullets '{
  "document_id": "example_document_id",
  "start_index": 1,
  "end_index": 1,
  "preset": "example_preset"
}' --json

Agent Discovery Commands

These commands return structured output for coding agents that need to inspect capabilities before choosing a function.

kosmo integrations:docs google_docs --json
kosmo integrations:docs google_docs.google_docs_add_bullets --json
kosmo integrations:schema google_docs.google_docs_add_bullets --json
kosmo integrations:search "Google Docs" --json
kosmo integrations:list --json

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to Google Docs.

google_docs.google_docs_add_bullets

Write write

Add bullet or numbered list formatting to a range in a Google Docs document. Default preset is BULLET_DISC_CIRCLE_SQUARE. Use NUMBERED_DECIMAL_ALPHA_ROMAN for numbered lists.

Parameters
document_id, start_index, end_index, preset

Generic CLI call

kosmo integrations:call google_docs.google_docs_add_bullets '{"document_id":"example_document_id","start_index":1,"end_index":1,"preset":"example_preset"}' --json

Provider shortcut

kosmo integrations:google_docs google_docs_add_bullets '{"document_id":"example_document_id","start_index":1,"end_index":1,"preset":"example_preset"}' --json

google_docs.google_docs_create

Read read

Create a new blank Google Docs document. Returns the document ID and URL.

Parameters
title

Generic CLI call

kosmo integrations:call google_docs.google_docs_create '{"title":"example_title"}' --json

Provider shortcut

kosmo integrations:google_docs google_docs_create '{"title":"example_title"}' --json

google_docs.google_docs_delete_range

Write write

Delete content in a Google Docs document by index range. Use google_docs_get_structure first to find the correct indexes.

Parameters
document_id, start_index, end_index

Generic CLI call

kosmo integrations:call google_docs.google_docs_delete_range '{"document_id":"example_document_id","start_index":1,"end_index":1}' --json

Provider shortcut

kosmo integrations:google_docs google_docs_delete_range '{"document_id":"example_document_id","start_index":1,"end_index":1}' --json

google_docs.google_docs_format_text

Read read

Apply formatting to a text range in a Google Docs document. Supports bold, italic, underline, strikethrough, fontSize (points), fontFamily, foregroundColor (hex like "#FF0000"), and link (URL).

Parameters
document_id, start_index, end_index, bold, italic, underline, strikethrough, font_size, font_family, foreground_color, link

Generic CLI call

kosmo integrations:call google_docs.google_docs_format_text '{"document_id":"example_document_id","start_index":1,"end_index":1,"bold":true,"italic":true,"underline":true,"strikethrough":true,"font_size":1}' --json

Provider shortcut

kosmo integrations:google_docs google_docs_format_text '{"document_id":"example_document_id","start_index":1,"end_index":1,"bold":true,"italic":true,"underline":true,"strikethrough":true,"font_size":1}' --json

google_docs.google_docs_get

Read read

Get the content of a Google Docs document. Returns plain text by default, or a structured outline with character indexes when format is "structured". The document ID is the long string in the URL: docs.google.com/document/d/{documentId}/edit

Parameters
document_id, format

Generic CLI call

kosmo integrations:call google_docs.google_docs_get '{"document_id":"example_document_id","format":"example_format"}' --json

Provider shortcut

kosmo integrations:google_docs google_docs_get '{"document_id":"example_document_id","format":"example_format"}' --json

google_docs.google_docs_get_structure

Read read

Get a simplified structure of a Google Docs document showing heading hierarchy, paragraph indexes, and table positions. Essential before performing index-based editing operations. The document ID is the long string in the URL: docs.google.com/document/d/{documentId}/edit

Parameters
document_id

Generic CLI call

kosmo integrations:call google_docs.google_docs_get_structure '{"document_id":"example_document_id"}' --json

Provider shortcut

kosmo integrations:google_docs google_docs_get_structure '{"document_id":"example_document_id"}' --json

google_docs.google_docs_insert_image

Read read

Insert an image from a URL into a Google Docs document. Supports PNG, JPEG, and GIF. Optionally specify width and height in points.

Parameters
document_id, image_url, index, width, height

Generic CLI call

kosmo integrations:call google_docs.google_docs_insert_image '{"document_id":"example_document_id","image_url":"example_image_url","index":1,"width":1,"height":1}' --json

Provider shortcut

kosmo integrations:google_docs google_docs_insert_image '{"document_id":"example_document_id","image_url":"example_image_url","index":1,"width":1,"height":1}' --json

google_docs.google_docs_insert_page_break

Read read

Insert a page break into a Google Docs document. Omit index or set to -1 to insert at end.

Parameters
document_id, index

Generic CLI call

kosmo integrations:call google_docs.google_docs_insert_page_break '{"document_id":"example_document_id","index":1}' --json

Provider shortcut

kosmo integrations:google_docs google_docs_insert_page_break '{"document_id":"example_document_id","index":1}' --json

google_docs.google_docs_insert_table

Read read

Insert a table into a Google Docs document. Specify rows and columns. Omit index or set to -1 to insert at end.

Parameters
document_id, rows, columns, index

Generic CLI call

kosmo integrations:call google_docs.google_docs_insert_table '{"document_id":"example_document_id","rows":1,"columns":1,"index":1}' --json

Provider shortcut

kosmo integrations:google_docs google_docs_insert_table '{"document_id":"example_document_id","rows":1,"columns":1,"index":1}' --json

google_docs.google_docs_insert_text

Read read

Insert text into a Google Docs document at a specific position or at the end. Omit index or set to -1 to append at end.

Parameters
document_id, text, index

Generic CLI call

kosmo integrations:call google_docs.google_docs_insert_text '{"document_id":"example_document_id","text":"example_text","index":1}' --json

Provider shortcut

kosmo integrations:google_docs google_docs_insert_text '{"document_id":"example_document_id","text":"example_text","index":1}' --json

google_docs.google_docs_remove_bullets

Write write

Remove bullet or numbered list formatting from a range in a Google Docs document.

Parameters
document_id, start_index, end_index

Generic CLI call

kosmo integrations:call google_docs.google_docs_remove_bullets '{"document_id":"example_document_id","start_index":1,"end_index":1}' --json

Provider shortcut

kosmo integrations:google_docs google_docs_remove_bullets '{"document_id":"example_document_id","start_index":1,"end_index":1}' --json

google_docs.google_docs_replace_all

Read read

Find and replace all occurrences of text in a Google Docs document. No indexes needed — this is the simplest way to edit text.

Parameters
document_id, find, replace, match_case

Generic CLI call

kosmo integrations:call google_docs.google_docs_replace_all '{"document_id":"example_document_id","find":"example_find","replace":"example_replace","match_case":true}' --json

Provider shortcut

kosmo integrations:google_docs google_docs_replace_all '{"document_id":"example_document_id","find":"example_find","replace":"example_replace","match_case":true}' --json

google_docs.google_docs_search_text

Read read

Find all occurrences of text in a Google Docs document with their start/end indexes. Useful before format_text or delete_range operations. The document ID is the long string in the URL: docs.google.com/document/d/{documentId}/edit

Parameters
document_id, query, match_case

Generic CLI call

kosmo integrations:call google_docs.google_docs_search_text '{"document_id":"example_document_id","query":"example_query","match_case":true}' --json

Provider shortcut

kosmo integrations:google_docs google_docs_search_text '{"document_id":"example_document_id","query":"example_query","match_case":true}' --json

google_docs.google_docs_set_heading

Read read

Set paragraph style (heading level) for a range in a Google Docs document. Valid styles: HEADING_1 through HEADING_6, TITLE, SUBTITLE, NORMAL_TEXT.

Parameters
document_id, start_index, end_index, style

Generic CLI call

kosmo integrations:call google_docs.google_docs_set_heading '{"document_id":"example_document_id","start_index":1,"end_index":1,"style":"example_style"}' --json

Provider shortcut

kosmo integrations:google_docs google_docs_set_heading '{"document_id":"example_document_id","start_index":1,"end_index":1,"style":"example_style"}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

google_docs.google_docs_add_bullets

Add bullet or numbered list formatting to a range in a Google Docs document. Default preset is BULLET_DISC_CIRCLE_SQUARE. Use NUMBERED_DECIMAL_ALPHA_ROMAN for numbered lists.

Operation
Write write
Schema command
kosmo integrations:schema google_docs.google_docs_add_bullets --json
ParameterTypeRequiredDescription
document_id string yes Google Docs document ID (from the URL).
start_index integer yes Start index of the range.
end_index integer yes End index of the range.
preset string no Bullet preset. Default BULLET_DISC_CIRCLE_SQUARE. Use NUMBERED_DECIMAL_ALPHA_ROMAN for numbered lists.

google_docs.google_docs_create

Create a new blank Google Docs document. Returns the document ID and URL.

Operation
Read read
Schema command
kosmo integrations:schema google_docs.google_docs_create --json
ParameterTypeRequiredDescription
title string yes Title for the new document.

google_docs.google_docs_delete_range

Delete content in a Google Docs document by index range. Use google_docs_get_structure first to find the correct indexes.

Operation
Write write
Schema command
kosmo integrations:schema google_docs.google_docs_delete_range --json
ParameterTypeRequiredDescription
document_id string yes Google Docs document ID (from the URL).
start_index integer yes Start index of the range to delete.
end_index integer yes End index of the range to delete.

google_docs.google_docs_format_text

Apply formatting to a text range in a Google Docs document. Supports bold, italic, underline, strikethrough, fontSize (points), fontFamily, foregroundColor (hex like "#FF0000"), and link (URL).

Operation
Read read
Schema command
kosmo integrations:schema google_docs.google_docs_format_text --json
ParameterTypeRequiredDescription
document_id string yes Google Docs document ID (from the URL).
start_index integer yes Start index of the text range to format.
end_index integer yes End index of the text range to format.
bold boolean no Apply bold formatting.
italic boolean no Apply italic formatting.
underline boolean no Apply underline formatting.
strikethrough boolean no Apply strikethrough formatting.
font_size number no Font size in points (e.g., 12, 14, 18).
font_family string no Font name (e.g., "Arial", "Times New Roman").
foreground_color string no Hex color (e.g., "#FF0000" for red).
link string no URL to link the text to.

google_docs.google_docs_get

Get the content of a Google Docs document. Returns plain text by default, or a structured outline with character indexes when format is "structured". The document ID is the long string in the URL: docs.google.com/document/d/{documentId}/edit

Operation
Read read
Schema command
kosmo integrations:schema google_docs.google_docs_get --json
ParameterTypeRequiredDescription
document_id string yes Google Docs document ID (from the URL).
format string no "text" (default, plain text) or "structured" (outline with character indexes for editing).

google_docs.google_docs_get_structure

Get a simplified structure of a Google Docs document showing heading hierarchy, paragraph indexes, and table positions. Essential before performing index-based editing operations. The document ID is the long string in the URL: docs.google.com/document/d/{documentId}/edit

Operation
Read read
Schema command
kosmo integrations:schema google_docs.google_docs_get_structure --json
ParameterTypeRequiredDescription
document_id string yes Google Docs document ID (from the URL).

google_docs.google_docs_insert_image

Insert an image from a URL into a Google Docs document. Supports PNG, JPEG, and GIF. Optionally specify width and height in points.

Operation
Read read
Schema command
kosmo integrations:schema google_docs.google_docs_insert_image --json
ParameterTypeRequiredDescription
document_id string yes Google Docs document ID (from the URL).
image_url string yes Image URL (PNG/JPEG/GIF).
index integer no Insert position (1-based). Omit or -1 for end of document.
width number no Width in points (optional).
height number no Height in points (optional).

google_docs.google_docs_insert_page_break

Insert a page break into a Google Docs document. Omit index or set to -1 to insert at end.

Operation
Read read
Schema command
kosmo integrations:schema google_docs.google_docs_insert_page_break --json
ParameterTypeRequiredDescription
document_id string yes Google Docs document ID (from the URL).
index integer no Insert position (1-based). Omit or -1 for end of document.

google_docs.google_docs_insert_table

Insert a table into a Google Docs document. Specify rows and columns. Omit index or set to -1 to insert at end.

Operation
Read read
Schema command
kosmo integrations:schema google_docs.google_docs_insert_table --json
ParameterTypeRequiredDescription
document_id string yes Google Docs document ID (from the URL).
rows integer yes Number of rows.
columns integer yes Number of columns.
index integer no Insert position (1-based). Omit or -1 for end of document.

google_docs.google_docs_insert_text

Insert text into a Google Docs document at a specific position or at the end. Omit index or set to -1 to append at end.

Operation
Read read
Schema command
kosmo integrations:schema google_docs.google_docs_insert_text --json
ParameterTypeRequiredDescription
document_id string yes Google Docs document ID (from the URL).
text string yes Text to insert.
index integer no Insert position (1-based). Omit or -1 for end of document.

google_docs.google_docs_remove_bullets

Remove bullet or numbered list formatting from a range in a Google Docs document.

Operation
Write write
Schema command
kosmo integrations:schema google_docs.google_docs_remove_bullets --json
ParameterTypeRequiredDescription
document_id string yes Google Docs document ID (from the URL).
start_index integer yes Start index of the range.
end_index integer yes End index of the range.

google_docs.google_docs_replace_all

Find and replace all occurrences of text in a Google Docs document. No indexes needed — this is the simplest way to edit text.

Operation
Read read
Schema command
kosmo integrations:schema google_docs.google_docs_replace_all --json
ParameterTypeRequiredDescription
document_id string yes Google Docs document ID (from the URL).
find string yes Text to find.
replace string yes Replacement text.
match_case boolean no Case-sensitive match (default true).

google_docs.google_docs_search_text

Find all occurrences of text in a Google Docs document with their start/end indexes. Useful before format_text or delete_range operations. The document ID is the long string in the URL: docs.google.com/document/d/{documentId}/edit

Operation
Read read
Schema command
kosmo integrations:schema google_docs.google_docs_search_text --json
ParameterTypeRequiredDescription
document_id string yes Google Docs document ID (from the URL).
query string yes Text to search for.
match_case boolean no Case-sensitive search (default false).

google_docs.google_docs_set_heading

Set paragraph style (heading level) for a range in a Google Docs document. Valid styles: HEADING_1 through HEADING_6, TITLE, SUBTITLE, NORMAL_TEXT.

Operation
Read read
Schema command
kosmo integrations:schema google_docs.google_docs_set_heading --json
ParameterTypeRequiredDescription
document_id string yes Google Docs document ID (from the URL).
start_index integer yes Start index of the paragraph range.
end_index integer yes End index of the paragraph range.
style string yes Paragraph style: HEADING_1, HEADING_2, HEADING_3, HEADING_4, HEADING_5, HEADING_6, TITLE, SUBTITLE, or NORMAL_TEXT.

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.