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.

7 functions 5 read 2 write Manual OAuth token 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: Manual OAuth token oauth2_manual_token. 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 Secret secret yes Access Token
url GOOGLE_DOCS_URL URL url no Docs API URL

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.gdocs_list_documents '{
  "pageSize": 1,
  "pageToken": "example_pageToken",
  "q": "example_q"
}' --json

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

kosmo integrations:google-docs gdocs_list_documents '{
  "pageSize": 1,
  "pageToken": "example_pageToken",
  "q": "example_q"
}' --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.gdocs_list_documents --json
kosmo integrations:schema google-docs.gdocs_list_documents --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.gdocs_list_documents

Read read

List Google Docs documents visible to the authenticated user. Returns document IDs, names, owners, and modification times. Supports pagination and custom Drive API query filters.

Parameters
pageSize, pageToken, q

Generic CLI call

kosmo integrations:call google-docs.gdocs_list_documents '{"pageSize":1,"pageToken":"example_pageToken","q":"example_q"}' --json

Provider shortcut

kosmo integrations:google-docs gdocs_list_documents '{"pageSize":1,"pageToken":"example_pageToken","q":"example_q"}' --json

google-docs.gdocs_get_document

Read read

Get the full content and structure of a Google Docs document by its ID. Returns the document title, body content (paragraphs, text runs), and styling information.

Parameters
documentId

Generic CLI call

kosmo integrations:call google-docs.gdocs_get_document '{"documentId":"example_documentId"}' --json

Provider shortcut

kosmo integrations:google-docs gdocs_get_document '{"documentId":"example_documentId"}' --json

google-docs.gdocs_create_document

Write write

Create a new Google Docs document with a given title. Returns the document ID and a link to edit the document in the browser.

Parameters
title

Generic CLI call

kosmo integrations:call google-docs.gdocs_create_document '{"title":"example_title"}' --json

Provider shortcut

kosmo integrations:google-docs gdocs_create_document '{"title":"example_title"}' --json

google-docs.gdocs_batch_update

Write write

Send batch update requests to a Google Docs document. Supports inserting text, updating text styles, creating paragraphs, and other document modifications. Each request in the array is a Google Docs API request object.

Parameters
documentId, requests

Generic CLI call

kosmo integrations:call google-docs.gdocs_batch_update '{"documentId":"example_documentId","requests":"example_requests"}' --json

Provider shortcut

kosmo integrations:google-docs gdocs_batch_update '{"documentId":"example_documentId","requests":"example_requests"}' --json

google-docs.gdocs_list_permissions

Read read

List all permissions (sharing settings) for a Google Docs document. Returns who has access, their roles (owner, writer, reader), and their email addresses.

Parameters
fileId, pageSize

Generic CLI call

kosmo integrations:call google-docs.gdocs_list_permissions '{"fileId":"example_fileId","pageSize":1}' --json

Provider shortcut

kosmo integrations:google-docs gdocs_list_permissions '{"fileId":"example_fileId","pageSize":1}' --json

google-docs.gdocs_get_permission

Read read

Get details of a specific permission for a Google Docs document. Returns the permission type, role, and email address for a single permission entry.

Parameters
fileId, permissionId

Generic CLI call

kosmo integrations:call google-docs.gdocs_get_permission '{"fileId":"example_fileId","permissionId":"example_permissionId"}' --json

Provider shortcut

kosmo integrations:google-docs gdocs_get_permission '{"fileId":"example_fileId","permissionId":"example_permissionId"}' --json

google-docs.gdocs_get_current_user

Read read

Get the authenticated Google user's profile information. Returns user ID, email address, display name, and profile picture URL. Use this to verify which Google account is being used.

Parameters
none

Generic CLI call

kosmo integrations:call google-docs.gdocs_get_current_user '{}' --json

Provider shortcut

kosmo integrations:google-docs gdocs_get_current_user '{}' --json

Function Schemas

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

google-docs.gdocs_list_documents

List Google Docs documents visible to the authenticated user. Returns document IDs, names, owners, and modification times. Supports pagination and custom Drive API query filters.

Operation
Read read
Schema command
kosmo integrations:schema google-docs.gdocs_list_documents --json
ParameterTypeRequiredDescription
pageSize integer no Maximum number of documents to return per page (default: 100, max: 1000).
pageToken string no Token for the next page of results, from a previous response.
q string no Drive API query string for filtering. Defaults to mimeType="application/vnd.google-apps.document". Example: "name contains 'report' and modifiedTime > '2025-01-01'".

google-docs.gdocs_get_document

Get the full content and structure of a Google Docs document by its ID. Returns the document title, body content (paragraphs, text runs), and styling information.

Operation
Read read
Schema command
kosmo integrations:schema google-docs.gdocs_get_document --json
ParameterTypeRequiredDescription
documentId string yes The ID of the Google Docs document. Can be extracted from the document URL: https://docs.google.com/document/d/{documentId}/edit

google-docs.gdocs_create_document

Create a new Google Docs document with a given title. Returns the document ID and a link to edit the document in the browser.

Operation
Write write
Schema command
kosmo integrations:schema google-docs.gdocs_create_document --json
ParameterTypeRequiredDescription
title string yes The title for the new document.

google-docs.gdocs_batch_update

Send batch update requests to a Google Docs document. Supports inserting text, updating text styles, creating paragraphs, and other document modifications. Each request in the array is a Google Docs API request object.

Operation
Write write
Schema command
kosmo integrations:schema google-docs.gdocs_batch_update --json
ParameterTypeRequiredDescription
documentId string yes The ID of the document to update.
requests array yes Array of Google Docs API request objects. Each request is an object with one key (e.g., insertText, updateTextStyle, createParagraphBullets). See Google Docs API reference for all request types.

google-docs.gdocs_list_permissions

List all permissions (sharing settings) for a Google Docs document. Returns who has access, their roles (owner, writer, reader), and their email addresses.

Operation
Read read
Schema command
kosmo integrations:schema google-docs.gdocs_list_permissions --json
ParameterTypeRequiredDescription
fileId string yes The ID of the Google Docs document (same as the document ID).
pageSize integer no Maximum number of permissions to return per page (default: 100).

google-docs.gdocs_get_permission

Get details of a specific permission for a Google Docs document. Returns the permission type, role, and email address for a single permission entry.

Operation
Read read
Schema command
kosmo integrations:schema google-docs.gdocs_get_permission --json
ParameterTypeRequiredDescription
fileId string yes The ID of the Google Docs document.
permissionId string yes The ID of the permission to retrieve. Obtain this from gdocs_list_permissions.

google-docs.gdocs_get_current_user

Get the authenticated Google user's profile information. Returns user ID, email address, display name, and profile picture URL. Use this to verify which Google account is being used.

Operation
Read read
Schema command
kosmo integrations:schema google-docs.gdocs_get_current_user --json
ParameterTypeRequiredDescription
No parameters.

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.