KosmoKrator

productivity

Google Drive CLI for AI Agents

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

15 functions 13 read 2 write OAuth browser flow auth

Google Drive CLI Setup

Google Drive can be configured headlessly with `kosmokrator integrations:configure google_drive`.

# 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_drive --set access_token="$GOOGLE_DRIVE_ACCESS_TOKEN" --enable --read allow --write ask --json
kosmokrator integrations:doctor google_drive --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_DRIVE_ACCESS_TOKEN OAuth token oauth yes Google Account

Call Google Drive Headlessly

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

kosmo integrations:call google_drive.google_drive_copy '{
  "file_id": "example_file_id",
  "name": "example_name",
  "parent_id": "example_parent_id"
}' --json

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

kosmo integrations:google_drive google_drive_copy '{
  "file_id": "example_file_id",
  "name": "example_name",
  "parent_id": "example_parent_id"
}' --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_drive --json
kosmo integrations:docs google_drive.google_drive_copy --json
kosmo integrations:schema google_drive.google_drive_copy --json
kosmo integrations:search "Google Drive" --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 Drive.

google_drive.google_drive_copy

Read read

Duplicate a file in Google Drive.

Parameters
file_id, name, parent_id

Generic CLI call

kosmo integrations:call google_drive.google_drive_copy '{"file_id":"example_file_id","name":"example_name","parent_id":"example_parent_id"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_copy '{"file_id":"example_file_id","name":"example_name","parent_id":"example_parent_id"}' --json

google_drive.google_drive_create_file

Write write

Create an empty Google Doc, Sheet, or Presentation in Google Drive.

Parameters
name, type, parent_id

Generic CLI call

kosmo integrations:call google_drive.google_drive_create_file '{"name":"example_name","type":"example_type","parent_id":"example_parent_id"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_create_file '{"name":"example_name","type":"example_type","parent_id":"example_parent_id"}' --json

google_drive.google_drive_create_folder

Write write

Create a folder in Google Drive.

Parameters
name, parent_id

Generic CLI call

kosmo integrations:call google_drive.google_drive_create_folder '{"name":"example_name","parent_id":"example_parent_id"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_create_folder '{"name":"example_name","parent_id":"example_parent_id"}' --json

google_drive.google_drive_delete

Read read

Permanently delete a file from Google Drive (irreversible).

Parameters
file_id

Generic CLI call

kosmo integrations:call google_drive.google_drive_delete '{"file_id":"example_file_id"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_delete '{"file_id":"example_file_id"}' --json

google_drive.google_drive_move

Read read

Move a file to a different folder in Google Drive.

Parameters
file_id, target_folder_id

Generic CLI call

kosmo integrations:call google_drive.google_drive_move '{"file_id":"example_file_id","target_folder_id":"example_target_folder_id"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_move '{"file_id":"example_file_id","target_folder_id":"example_target_folder_id"}' --json

google_drive.google_drive_rename

Read read

Rename a file or folder in Google Drive.

Parameters
file_id, name

Generic CLI call

kosmo integrations:call google_drive.google_drive_rename '{"file_id":"example_file_id","name":"example_name"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_rename '{"file_id":"example_file_id","name":"example_name"}' --json

google_drive.google_drive_get_file

Read read

Get file metadata by ID from Google Drive. For Google Docs/Sheets/Slides, use `export_as` to get content as text, csv, or markdown.

Parameters
file_id, export_as

Generic CLI call

kosmo integrations:call google_drive.google_drive_get_file '{"file_id":"example_file_id","export_as":"example_export_as"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_get_file '{"file_id":"example_file_id","export_as":"example_export_as"}' --json

google_drive.google_drive_list_permissions

Read read

List all permissions (sharing settings) on a Google Drive file or folder.

Parameters
file_id

Generic CLI call

kosmo integrations:call google_drive.google_drive_list_permissions '{"file_id":"example_file_id"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_list_permissions '{"file_id":"example_file_id"}' --json

google_drive.google_drive_search_files

Read read

Search for files in Google Drive using Drive query syntax (default: 20 results, max: 100). Trashed files are excluded by default. Drive query syntax examples: - By name: `name contains 'budget'` or `name = 'Q1 Report'` - By type: `mimeType = 'application/vnd.google-apps.spreadsheet'` (also: document, presentation, folder) - In folder: `'FOLDER_ID' in parents` - Recent: `modifiedTime > '2026-01-01'` - Shared with me: `sharedWithMe = true` - Starred: `starred = true` - By owner: `'[email protected]' in owners` - Combine: `name contains 'report' and mimeType = 'application/vnd.google-apps.spreadsheet'`

Parameters
query, max_results, page_token, order_by

Generic CLI call

kosmo integrations:call google_drive.google_drive_search_files '{"query":"example_query","max_results":1,"page_token":"example_page_token","order_by":"example_order_by"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_search_files '{"query":"example_query","max_results":1,"page_token":"example_page_token","order_by":"example_order_by"}' --json

google_drive.google_drive_share_file

Read read

Share a Google Drive file or folder. Provide `fileId`, `role` ("reader", "writer", "commenter"), and one of: - `email`: share with a specific user (e.g., "[email protected]") - `domain`: share with an entire domain (e.g., "example.com") - `type` set to `"anyone"`: make accessible to anyone with the link (no email/domain needed) - `notify` (optional, default true): send email notification (only for email shares)

Parameters
file_id, role, type, email, domain, notify

Generic CLI call

kosmo integrations:call google_drive.google_drive_share_file '{"file_id":"example_file_id","role":"example_role","type":"example_type","email":"example_email","domain":"example_domain","notify":"example_notify"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_share_file '{"file_id":"example_file_id","role":"example_role","type":"example_type","email":"example_email","domain":"example_domain","notify":"example_notify"}' --json

google_drive.google_drive_unshare_file

Read read

Remove a permission from a Google Drive file or folder. Use google_drive_list_permissions first to find the permission ID.

Parameters
file_id, permission_id

Generic CLI call

kosmo integrations:call google_drive.google_drive_unshare_file '{"file_id":"example_file_id","permission_id":"example_permission_id"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_unshare_file '{"file_id":"example_file_id","permission_id":"example_permission_id"}' --json

google_drive.google_drive_star

Read read

Mark a file as starred/favorite in Google Drive.

Parameters
file_id

Generic CLI call

kosmo integrations:call google_drive.google_drive_star '{"file_id":"example_file_id"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_star '{"file_id":"example_file_id"}' --json

google_drive.google_drive_trash

Read read

Move a file to trash in Google Drive (reversible).

Parameters
file_id

Generic CLI call

kosmo integrations:call google_drive.google_drive_trash '{"file_id":"example_file_id"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_trash '{"file_id":"example_file_id"}' --json

google_drive.google_drive_unstar

Read read

Remove star from a file in Google Drive.

Parameters
file_id

Generic CLI call

kosmo integrations:call google_drive.google_drive_unstar '{"file_id":"example_file_id"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_unstar '{"file_id":"example_file_id"}' --json

google_drive.google_drive_untrash

Read read

Restore a file from trash in Google Drive.

Parameters
file_id

Generic CLI call

kosmo integrations:call google_drive.google_drive_untrash '{"file_id":"example_file_id"}' --json

Provider shortcut

kosmo integrations:google_drive google_drive_untrash '{"file_id":"example_file_id"}' --json

Function Schemas

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

google_drive.google_drive_copy

Duplicate a file in Google Drive.

Operation
Read read
Schema command
kosmo integrations:schema google_drive.google_drive_copy --json
ParameterTypeRequiredDescription
file_id string yes File ID to copy.
name string no Name for the copy (optional).
parent_id string no Target folder ID for the copy (optional).

google_drive.google_drive_create_file

Create an empty Google Doc, Sheet, or Presentation in Google Drive.

Operation
Write write
Schema command
kosmo integrations:schema google_drive.google_drive_create_file --json
ParameterTypeRequiredDescription
name string yes File name.
type string yes File type: "document", "spreadsheet", or "presentation".
parent_id string no Parent folder ID (defaults to root).

google_drive.google_drive_create_folder

Create a folder in Google Drive.

Operation
Write write
Schema command
kosmo integrations:schema google_drive.google_drive_create_folder --json
ParameterTypeRequiredDescription
name string yes Folder name.
parent_id string no Parent folder ID (defaults to root).

google_drive.google_drive_delete

Permanently delete a file from Google Drive (irreversible).

Operation
Read read
Schema command
kosmo integrations:schema google_drive.google_drive_delete --json
ParameterTypeRequiredDescription
file_id string yes File ID to permanently delete.

google_drive.google_drive_move

Move a file to a different folder in Google Drive.

Operation
Read read
Schema command
kosmo integrations:schema google_drive.google_drive_move --json
ParameterTypeRequiredDescription
file_id string yes File ID to move.
target_folder_id string yes Destination folder ID.

google_drive.google_drive_rename

Rename a file or folder in Google Drive.

Operation
Read read
Schema command
kosmo integrations:schema google_drive.google_drive_rename --json
ParameterTypeRequiredDescription
file_id string yes File or folder ID to rename.
name string yes New name for the file or folder.

google_drive.google_drive_get_file

Get file metadata by ID from Google Drive. For Google Docs/Sheets/Slides, use `export_as` to get content as text, csv, or markdown.

Operation
Read read
Schema command
kosmo integrations:schema google_drive.google_drive_get_file --json
ParameterTypeRequiredDescription
file_id string yes File ID to retrieve.
export_as string no Export format for Google Docs/Sheets/Slides: "text", "csv", or "markdown".

google_drive.google_drive_list_permissions

List all permissions (sharing settings) on a Google Drive file or folder.

Operation
Read read
Schema command
kosmo integrations:schema google_drive.google_drive_list_permissions --json
ParameterTypeRequiredDescription
file_id string yes File/folder ID to list permissions for.

google_drive.google_drive_search_files

Search for files in Google Drive using Drive query syntax (default: 20 results, max: 100). Trashed files are excluded by default. Drive query syntax examples: - By name: `name contains 'budget'` or `name = 'Q1 Report'` - By type: `mimeType = 'application/vnd.google-apps.spreadsheet'` (also: document, presentation, folder) - In folder: `'FOLDER_ID' in parents` - Recent: `modifiedTime > '2026-01-01'` - Shared with me: `sharedWithMe = true` - Starred: `starred = true` - By owner: `'[email protected]' in owners` - Combine: `name contains 'report' and mimeType = 'application/vnd.google-apps.spreadsheet'`

Operation
Read read
Schema command
kosmo integrations:schema google_drive.google_drive_search_files --json
ParameterTypeRequiredDescription
query string no Drive search query (e.g., "name contains 'report' and mimeType = 'application/vnd.google-apps.folder'").
max_results integer no Max results per page (default: 20, max: 100).
page_token string no Pagination token from previous response.
order_by string no Sort order (e.g., "modifiedTime desc", "name").

google_drive.google_drive_share_file

Share a Google Drive file or folder. Provide `fileId`, `role` ("reader", "writer", "commenter"), and one of: - `email`: share with a specific user (e.g., "[email protected]") - `domain`: share with an entire domain (e.g., "example.com") - `type` set to `"anyone"`: make accessible to anyone with the link (no email/domain needed) - `notify` (optional, default true): send email notification (only for email shares)

Operation
Read read
Schema command
kosmo integrations:schema google_drive.google_drive_share_file --json
ParameterTypeRequiredDescription
file_id string yes File/folder ID to share.
role string yes Permission role: "reader", "writer", or "commenter".
type string no Set to "anyone" to share with anyone who has the link.
email string no Email address to share with a specific user.
domain string no Domain to share with (e.g., "example.com").
notify string no Send email notification: "true" (default) or "false".

google_drive.google_drive_unshare_file

Remove a permission from a Google Drive file or folder. Use google_drive_list_permissions first to find the permission ID.

Operation
Read read
Schema command
kosmo integrations:schema google_drive.google_drive_unshare_file --json
ParameterTypeRequiredDescription
file_id string yes File/folder ID to remove permission from.
permission_id string yes Permission ID to remove.

google_drive.google_drive_star

Mark a file as starred/favorite in Google Drive.

Operation
Read read
Schema command
kosmo integrations:schema google_drive.google_drive_star --json
ParameterTypeRequiredDescription
file_id string yes File ID to star.

google_drive.google_drive_trash

Move a file to trash in Google Drive (reversible).

Operation
Read read
Schema command
kosmo integrations:schema google_drive.google_drive_trash --json
ParameterTypeRequiredDescription
file_id string yes File ID to trash.

google_drive.google_drive_unstar

Remove star from a file in Google Drive.

Operation
Read read
Schema command
kosmo integrations:schema google_drive.google_drive_unstar --json
ParameterTypeRequiredDescription
file_id string yes File ID to unstar.

google_drive.google_drive_untrash

Restore a file from trash in Google Drive.

Operation
Read read
Schema command
kosmo integrations:schema google_drive.google_drive_untrash --json
ParameterTypeRequiredDescription
file_id string yes File ID to restore from trash.

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.