mcpField
G
google-workspace-cli

google-workspace-cli

github.com/hoodini生産性291455 回インストール今日更新
リポジトリ

google-workspace-cli について

google-workspace-cli(gws)は、Google Workspaceを操作する人やAIエージェント向けのコマンドラインツールです。GoogleのDiscovery Serviceからコマンドを動的に構築し、構造化JSONを出力します。100以上のエージェントスキルを含みますが、Googleの公式サポート製品ではありません。

主な機能

  1. 01各種Google Workspaceサービスへのアクセス
  2. 02Discovery Serviceに基づくコマンド生成
  3. 03構造化JSON出力
  4. 04複数アカウントとOAuthログイン
  5. 05100以上のエージェントスキルを収録
  6. 06ページネーションとリクエスト確認

活用シーン

  1. 01コマンドラインからDriveのファイルを管理
  2. 02GmailのメールやCalendarの予定を検索
  3. 03Sheets、Docs、Slidesの読み書き
  4. 04AIエージェントによるWorkspace APIの呼び出し

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/hoodini/ai-agents-skills --skill google-workspace-cli

インストール後、Claude Code で/google-workspace-cliを入力して読み込まれたか確認します。

詳細

Google Workspace CLI (gws)

Google Workspace のすべてに対応する 1 つの CLI です。Drive、Gmail、Calendar、Sheets、Docs、Slides、Chat、Tasks、Admin、Meet、Forms、Keep、その他すべての Workspace API を利用できます。人間と AI エージェント向けに構築されています。構造化された JSON 出力に対応しています。100 種類以上のエージェントスキルが含まれています。

注: これは Google が公式にサポートする製品ではありません。

重要: このプロジェクトは現在も開発中です。v1.0 に向けた開発に伴い、破壊的変更が発生する可能性があります。

リポジトリ: https://github.com/googleworkspace/cli

仕組み

gws はコマンドの静的な一覧を同梱していません。実行時に Google 独自の Discovery Service を読み込み、コマンドの全体を動的に構築します。Google が新しい API エンドポイントやメソッドを追加すると、gws が自動的に取り込みます。更新は不要です。

前提条件

  • Node.js 18 以降 — npm install に必要です(または GitHub Releases からビルド済みバイナリをダウンロードしてください)
  • Google Cloud プロジェクト — OAuth 認証情報に必要です。Google Cloud Console、gcloud CLI、または gws auth setup コマンドで作成できます。
  • Google Workspace にアクセスできる Google アカウント

インストール

# Install globally via npm (recommended — bundles native binaries, no Rust needed)
npm install -g @googleworkspace/cli

# Verify installation
gws --version

その他のインストール方法:

# From GitHub Releases (pre-built binaries)
# Download from: https://github.com/googleworkspace/cli/releases

# Build from source (requires Rust toolchain)
cargo install --git https://github.com/googleworkspace/cli --locked

# Nix flake
nix run github:googleworkspace/cli

クイックスタート

gws auth setup     # walks you through Google Cloud project config
gws auth login     # subsequent OAuth login
gws drive files list --params '{"pageSize": 5}'

認証

どのセットアップ方法を使えばよいですか?
手元にあるもの…使用する方法
gcloud がインストール済みで、認証も済んでいるgws auth setup(最速 — 1 つのコマンドで完了)
GCP プロジェクトはあるが、gcloud がないCloud Console で OAuth を手動設定
既存の OAuth アクセストークンGOOGLE_WORKSPACE_CLI_TOKEN 環境変数
既存の認証情報 JSON(サービスアカウントまたはエクスポートしたもの)GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE 環境変数
クイックセットアップ(推奨 — gcloud CLI が必要です)
gws auth setup       # one-time: creates a Cloud project, enables APIs, logs you in
gws auth login       # subsequent logins with scope selection

認証情報は、OS のキーチェーンに保存された鍵を使用して、保存時に暗号化されます(AES-256-GCM)。

スコープを指定したログイン(未確認/テスト用 OAuth アプリ向け、約 25 スコープまで)

警告: 未確認(テストモード)のアプリで使用できる OAuth スコープは約 25 個までです。recommended スコーププリセットには 85 個以上のスコープが含まれているため、未確認アプリでは失敗します(特に @gmail.com アカウントの場合)。代わりに個別のサービスを選択してください。

# Select only the services you need to stay under the scope limit
gws auth login -s drive,gmail,sheets
gws auth login --scopes drive,gmail,calendar,docs,chat
複数アカウント
gws auth login --account [email protected]
gws auth login --account [email protected]

gws auth list                                    # list registered accounts
gws auth default [email protected]                   # set the default

gws --account [email protected] drive files list  # one-off override
export [email protected]  # env var override

認証情報はアカウントごとに ~/.config/gws/ 内の credentials.<b64-email>.enc として保存されます。デフォルトを管理する accounts.json レジストリも保存されます。

OAuth の手動設定(gcloud なし)

gws auth setup でプロジェクトやクライアントの作成を自動化できない場合、または明示的に制御したい場合に使用します。

  1. 対象のプロジェクトで Google Cloud Console を開きます:
    • OAuth 同意画面:https://console.cloud.google.com/apis/credentials/consent?project=<PROJECT_ID>
    • 認証情報:https://console.cloud.google.com/apis/credentials?project=<PROJECT_ID>
  2. 求められた場合は、OAuth のブランディング/対象ユーザーを設定します — アプリの種類:External(テストモードでも問題ありません)
  3. Test users に自分のアカウントを追加します
  4. OAuth クライアントを作成します — 種類:Desktop app
  5. クライアント JSON をダウンロードし、~/.config/gws/client_secret.json に保存します

重要: 自分自身をテストユーザーとして追加する必要があります。OAuth 同意画面で Test users → Add users をクリックし、自分の Google アカウントのメールアドレスを入力してください。これを行わないと、ログイン時に汎用的な「Access blocked」エラーが発生します。

次に、以下を実行します:

gws auth login
ヘッドレス環境/CI
# On a machine with a browser:
gws auth export --unmasked > credentials.json

# On the headless machine:
export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/credentials.json
gws drive files list   # just works
サービスアカウント(サーバー間通信)
export GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE=/path/to/service-account.json
gws drive files list

# For Domain-Wide Delegation:
export [email protected]
取得済みアクセストークン
export GOOGLE_WORKSPACE_CLI_TOKEN=$(gcloud auth print-access-token)
ブラウザーを利用した認証(AI エージェント向け)

エージェントはブラウザー自動化を使って OAuth を完了できます。

  • 人間によるフロー: gws auth login を実行し、表示された URL を開いて、スコープを承認します。
  • エージェント支援フロー: エージェントが URL を開き、アカウントを選択し、同意プロンプトに対応して、localhost のコールバックが成功したら制御を戻します。

同意画面に「Google hasn't verified this app」(テストモード)と表示された場合は、Continue をクリックします。スコープのチェックボックスが表示された場合は、続行する前に必要なスコープ(または Select all)を選択します。

認証の優先順位
優先順位方法ソース
1アクセストークンGOOGLE_WORKSPACE_CLI_TOKEN
2認証情報ファイルGOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE
3アカウントごとの暗号化された認証情報gws auth login --account EMAIL
4平文の認証情報~/.config/gws/credentials.json

アカウントの解決順序:--account フラグ > GOOGLE_WORKSPACE_CLI_ACCOUNT 環境変数 > accounts.json のデフォルト値。

すべての環境変数は、プロジェクトのルートにある .env ファイルにも設定できます。

コマンドの構造

すべての gws コマンドに共通するパターン:

gws <service> <resource> <method> [--params '{ JSON }'] [--json '{ JSON }'] [flags]
グローバルフラグ
フラグ説明
--help任意のサービス、リソース、メソッドのヘルプを表示します
--params '{ JSON }'JSON 形式の URL/クエリパラメーター
--json '{ JSON }'JSON 形式のリクエスト本文
--dry-run実行せずに HTTP リクエストをプレビューします
--page-all自動ページネーションを行い、ページごとに 1 行の JSON を出力します(NDJSON)
--page-limit <N>取得するページの最大数(デフォルト:10)
--page-delay <MS>ページ間の遅延(デフォルト:100ms)
--upload <path>マルチパートファイルのアップロード
--account <email>特定の認証済みアカウントを使用します
`--sanitize
スキーマの確認
# See the full request/response schema for any method
gws schema drive.files.list
gws schema gmail.users.messages.send
gws schema calendar.events.insert

コアサービス — コマンドと使用例

Google Drive
# List files (paginated)
gws drive files list --params '{"pageSize": 10}'

# List ALL files (auto-paginate as NDJSON)
gws drive files list --params '{"pageSize": 100}' --page-all

# Search for files
gws drive files list --params '{"q": "name contains '\''report'\'' and mimeType = '\''application/pdf'\''", "pageSize": 20}'

# Get file metadata
gws drive files get --params '{"fileId": "FILE_ID"}'

# Upload a file
gws drive files create --json '{"name": "report.pdf", "parents": ["FOLDER_ID"]}' --upload ./report.pdf

# Create a folder
gws drive files create --json '{"name": "Project Docs", "mimeType": "application/vnd.google-apps.folder"}'

# Move a file to a folder
gws drive files update --params '{"fileId": "FILE_ID", "addParents": "FOLDER_ID", "removeParents": "OLD_PARENT_ID"}'

# Share a file
gws drive permissions create --params '{"fileId": "FILE_ID"}' --json '{"role": "writer", "type": "user", "emailAddress": "[email protected]"}'

# Download a file (export Google Docs as PDF)
gws drive files export --params '{"fileId": "FILE_ID", "mimeType": "application/pdf"}'

# Delete a file
gws drive files delete --params '{"fileId": "FILE_ID"}'

# List shared drives
gws drive drives list --params '{"pageSize": 10}'

# Create a shared drive
gws drive drives create --params '{"requestId": "unique-id"}' --json '{"name": "Team Drive"}'
Gmail
# List messages in inbox
gws gmail users messages list --params '{"userId": "me", "maxResults": 10}'

# Search messages
gws gmail users messages list --params '{"userId": "me", "q": "from:[email protected] is:unread", "maxResults": 20}'

# Get a specific message
gws gmail users messages get --params '{"userId": "me", "id": "MESSAGE_ID"}'

# Send an email
gws gmail users messages send --params '{"userId": "me"}' --json '{
  "raw": "<BASE64_ENCODED_RFC2822_MESSAGE>"
}'

# List labels
gws gmail users labels list --params '{"userId": "me"}'

# Create a label
gws gmail users labels create --params '{"userId": "me"}' --json '{"name": "Important/Projects"}'

# Modify message labels
gws gmail users messages modify --params '{"userId": "me", "id": "MESSAGE_ID"}' --json '{"addLabelIds": ["LABEL_ID"], "removeLabelIds": ["INBOX"]}'

# Trash a message
gws gmail users messages trash --params '{"userId": "me", "id": "MESSAGE_ID"}'

# List drafts
gws gmail users drafts list --params '{"userId": "me"}'

# Create a draft
gws gmail users drafts create --params '{"userId": "me"}' --json '{
  "message": {"raw": "<BASE64_ENCODED_RFC2822_MESSAGE>"}
}'

# Set vacation auto-reply
gws gmail users settings updateVacation --params '{"userId": "me"}' --json '{
  "enableAutoReply": true,
  "responseSubject": "Out of Office",
  "responseBodyPlainText": "I am out of office until March 10.",
  "restrictToContacts": false,
  "restrictToDomain": false
}'
Google Calendar
# List upcoming events
gws calendar events list --params '{"calendarId": "primary", "timeMin": "2026-03-05T00:00:00Z", "maxResults": 10, "singleEvents": true, "orderBy": "startTime"}'

# Get a specific event
gws calendar events get --params '{"calendarId": "primary", "eventId": "EVENT_ID"}'

# Create an event
gws calendar events insert --params '{"calendarId": "primary"}' --json '{
  "summary": "Team Standup",
  "description": "Daily standup meeting",
  "start": {"dateTime": "2026-03-06T09:00:00-05:00", "timeZone": "America/New_York"},
  "end": {"dateTime": "2026-03-06T09:30:00-05:00", "timeZone": "America/New_York"},
  "attendees": [{"email": "[email protected]"}, {"email": "[email protected]"}]
}'

# Update an event
gws calendar events update --params '{"calendarId": "primary", "eventId": "EVENT_ID"}' --json '{
  "summary": "Updated Standup",
  "start": {"dateTime": "2026-03-06T10:00:00-05:00"},
  "end": {"dateTime": "2026-03-06T10:30:00-05:00"}
}'

# Delete an event
gws calendar events delete --params '{"calendarId": "primary", "eventId": "EVENT_ID"}'

# List calendars
gws calendar calendarList list

# Check free/busy
gws calendar freebusy query --json '{
  "timeMin": "2026-03-06T08:00:00Z",
  "timeMax": "2026-03-06T18:00:00Z",
  "items": [{"id": "[email protected]"}, {"id": "[email protected]"}]
}'

# Create a recurring event
gws calendar events insert --params '{"calendarId": "primary"}' --json '{
  "summary": "Weekly Review",
  "recurrence": ["RRULE:FREQ=WEEKLY;BYDAY=FR"],
  "start": {"dateTime": "2026-03-06T16:00:00-05:00", "timeZone": "America/New_York"},
  "end": {"dateTime": "2026-03-06T17:00:00-05:00", "timeZone": "America/New_York"}
}'
Google Sheets

重要: Sheets の範囲には ! が使われており、bash では履歴展開として解釈されます。値は必ずシングルクォートで囲んでください。

# Create a spreadsheet
gws sheets spreadsheets create --json '{"properties": {"title": "Q1 Budget"}}'

# Read cells
gws sheets spreadsheets values get --params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1:C10"}'

# Write cells
gws sheets spreadsheets values update --params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' --json '{"values": [["Name", "Score"], ["Alice", 95], ["Bob", 87]]}'

# Append rows
gws sheets spreadsheets values append --params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1", "valueInputOption": "USER_ENTERED"}' --json '{"values": [["Charlie", 92]]}'

# Get spreadsheet metadata
gws sheets spreadsheets get --params '{"spreadsheetId": "SPREADSHEET_ID"}'

# Clear a range
gws sheets spreadsheets values clear --params '{"spreadsheetId": "SPREADSHEET_ID", "range": "Sheet1!A1:C10"}'

# Batch update (add sheet, format cells, etc.)
gws sheets spreadsheets batchUpdate --params '{"spreadsheetId": "SPREADSHEET_ID"}' --json '{
  "requests": [
    {"addSheet": {"properties": {"title": "March Data"}}},
    {"repeatCell": {
      "range": {"sheetId": 0, "startRowIndex": 0, "endRowIndex": 1},
      "cell": {"userEnteredFormat": {"textFormat": {"bold": true}}},
      "fields": "userEnteredFormat.textFormat.bold"
    }}
  ]
}'
Google Docs
# Create a document
gws docs documents create --json '{"title": "Meeting Notes"}'

# Get document content
gws docs documents get --params '{"documentId": "DOC_ID"}'

# Update document (insert text)
gws docs documents batchUpdate --params '{"documentId": "DOC_ID"}' --json '{
  "requests": [
    {"insertText": {"location": {"index": 1}, "text": "Hello, World!\n"}}
  ]
}'
Google Slides
# Create a presentation
gws slides presentations create --json '{"title": "Q1 Review"}'

# Get presentation
gws slides presentations get --params '{"presentationId": "PRES_ID"}'

# Add a slide
gws slides presentations batchUpdate --params '{"presentationId": "PRES_ID"}' --json '{
  "requests": [
    {"createSlide": {"slideLayoutReference": {"predefinedLayout": "TITLE_AND_BODY"}}}
  ]
}'
Google Chat
# List spaces
gws chat spaces list

# Send a message to a space
gws chat spaces messages create --params '{"parent": "spaces/SPACE_ID"}' --json '{"text": "Deploy complete."}'

# Get a message
gws chat spaces messages get --params '{"name": "spaces/SPACE_ID/messages/MSG_ID"}'

# List messages in a space
gws chat spaces messages list --params '{"parent": "spaces/SPACE_ID", "pageSize": 25}'

# Create a space
gws chat spaces create --json '{"displayName": "Project Alpha", "spaceType": "SPACE"}'
Google Tasks
# List task lists
gws tasks tasklists list

# Create a task list
gws tasks tasklists insert --json '{"title": "Sprint 42"}'

# List tasks in a list
gws tasks tasks list --params '{"tasklist": "TASKLIST_ID"}'

# Create a task
gws tasks tasks insert --params '{"tasklist": "TASKLIST_ID"}' --json '{"title": "Review PR #123", "due": "2026-03-07T00:00:00Z"}'

# Complete a task
gws tasks tasks update --params '{"tasklist": "TASKLIST_ID", "task": "TASK_ID"}' --json '{"status": "completed"}'
Google Meet
# Create a meeting space
gws meet spaces create --json '{}'

# Get meeting space info
gws meet spaces get --params '{"name": "spaces/SPACE_ID"}'
Google Forms
# Create a form
gws forms forms create --json '{"info": {"title": "Feedback Survey"}}'

# Get form
gws forms forms get --params '{"formId": "FORM_ID"}'

# List responses
gws forms forms responses list --params '{"formId": "FORM_ID"}'
Google Admin(Directory)
# List users
gws admin users list --params '{"domain": "example.com", "maxResults": 100}'

# Get a user
gws admin users get --params '{"userKey": "[email protected]"}'

# Create a user
gws admin users insert --json '{
  "primaryEmail": "[email protected]",
  "name": {"givenName": "Jane", "familyName": "Doe"},
  "password": "TempP@ssw0rd!"
}'

# List groups
gws admin groups list --params '{"domain": "example.com"}'

# Add member to group
gws admin members insert --params '{"groupKey": "[email protected]"}' --json '{"email": "[email protected]", "role": "MEMBER"}'
Google Keep
# List notes
gws keep notes list

# Get a note
gws keep notes get --params '{"name": "notes/NOTE_ID"}'
Google People(連絡先とプロフィール)
# List contacts
gws people people connections list --params '{"resourceName": "people/me", "personFields": "names,emailAddresses,phoneNumbers", "pageSize": 50}'

# Get a specific contact
gws people people get --params '{"resourceName": "people/PERSON_ID", "personFields": "names,emailAddresses,organizations"}'

# Search contacts
gws people people searchContacts --params '{"query": "Alice", "readMask": "names,emailAddresses"}'

# Create a contact
gws people people createContact --json '{
  "names": [{"givenName": "Jane", "familyName": "Smith"}],
  "emailAddresses": [{"value": "[email protected]"}],
  "phoneNumbers": [{"value": "+1-555-0100"}]
}'

# List directory (domain contacts)
gws people people listDirectoryPeople --params '{"readMask": "names,emailAddresses", "sources": ["DIRECTORY_SOURCE_TYPE_DOMAIN_PROFILE"], "pageSize": 100}'
Google Workspace Events
# Create a subscription to watch for changes
gws events subscriptions create --json '{
  "targetResource": "//calendar.googleapis.com/calendars/primary",
  "eventTypes": ["google.workspace.calendar.event.v1.created"],
  "notificationEndpoint": {"pubsubTopic": "projects/PROJECT/topics/TOPIC"},
  "payloadOptions": {"includeResource": true}
}'

# List subscriptions
gws events subscriptions list

# Delete a subscription
gws events subscriptions delete --params '{"name": "subscriptions/SUB_ID"}'
Google Vault(電子情報開示)
# List matters
gws vault matters list

# Create a matter
gws vault matters create --json '{"name": "Investigation Q1", "description": "Q1 compliance audit"}'

# Create a hold
gws vault matters holds create --params '{"matterId": "MATTER_ID"}' --json '{
  "name": "Email Hold",
  "corpus": "MAIL",
  "accounts": [{"accountId": "[email protected]"}]
}'
Google Classroom
# List courses
gws classroom courses list

# Create a course
gws classroom courses create --json '{"name": "CS101", "section": "Fall 2026", "ownerId": "me"}'

# List students in a course
gws classroom courses students list --params '{"courseId": "COURSE_ID"}'

# Create coursework
gws classroom courses courseWork create --params '{"courseId": "COURSE_ID"}' --json '{
  "title": "Assignment 1",
  "workType": "ASSIGNMENT",
  "dueDate": {"year": 2026, "month": 3, "day": 15}
}'
Admin Reports(監査ログ)
# List admin activities
gws admin-reports activities list --params '{"userKey": "all", "applicationName": "admin", "maxResults": 50}'

# List login activities
gws admin-reports activities list --params '{"userKey": "all", "applicationName": "login", "maxResults": 50}'

# List Drive audit logs
gws admin-reports activities list --params '{"userKey": "all", "applicationName": "drive", "maxResults": 50}'
Alert Center(セキュリティアラート)
# List alerts
gws alertcenter alerts list

# Get alert details
gws alertcenter alerts get --params '{"alertId": "ALERT_ID"}'
Cloud Identity
# List groups
gws cloudidentity groups list --params '{"parent": "customers/CUSTOMER_ID"}'

# Search groups
gws cloudidentity groups search --params '{"query": "parent == \"customers/CUSTOMER_ID\""}'

# List memberships
gws cloudidentity groups memberships list --params '{"parent": "groups/GROUP_ID"}'
Groups Settings
# Get group settings
gws groupssettings groups get --params '{"groupUniqueId": "[email protected]"}'

# Update group settings
gws groupssettings groups update --params '{"groupUniqueId": "[email protected]"}' --json '{
  "whoCanPostMessage": "ALL_MEMBERS_CAN_POST",
  "messageModerationLevel": "MODERATE_NONE"
}'
Licensing
# List license assignments
gws licensing licenseAssignments listForProduct --params '{"productId": "Google-Apps", "customerId": "CUSTOMER_ID"}'

# Assign a license
gws licensing licenseAssignments insert --params '{"productId": "Google-Apps", "skuId": "SKU_ID"}' --json '{"userId": "[email protected]"}'
Reseller
# List subscriptions
gws reseller subscriptions list --params '{"customerId": "CUSTOMER_ID"}'

# Get a subscription
gws reseller subscriptions get --params '{"customerId": "CUSTOMER_ID", "subscriptionId": "SUB_ID"}'
Apps Script
# List projects
gws apps-script projects list

# Get project content
gws apps-script projects getContent --params '{"scriptId": "SCRIPT_ID"}'

# Deploy a project
gws apps-script projects deployments create --params '{"scriptId": "SCRIPT_ID"}' --json '{"versionNumber": 1}'

# Run a function
gws apps-script scripts run --params '{"scriptId": "SCRIPT_ID"}' --json '{"function": "myFunction", "parameters": []}'

ワークフローヘルパー(ショートカットコマンド)

gws には、よくある複数ステップの操作向けに、より高度なヘルパーコマンドが用意されています。

# --- Drive ---
# Upload a file to Drive with automatic metadata
gws drive-upload ./report.pdf

# --- Sheets ---
# Append a row to a sheet
gws sheets-append --spreadsheet-id ID --range 'Sheet1!A1' --values '[["Name", "Score"]]'

# Read sheet values
gws sheets-read --spreadsheet-id ID --range 'Sheet1!A1:C10'

# --- Gmail ---
# Send an email (simplified)
gws gmail-send --to [email protected] --subject "Hello" --body "Hi there"

# Triage inbox — show unread summary (sender, subject, date)
gws gmail-triage

# Watch for new emails and stream them as NDJSON
gws gmail-watch

# --- Calendar ---
# Show upcoming calendar agenda across all calendars
gws calendar-agenda

# Insert a calendar event quickly
gws calendar-insert --summary "Lunch" --start "2026-03-06T12:00:00" --end "2026-03-06T13:00:00"

# --- Docs ---
# Append text to a Google Doc
gws docs-write --document-id DOC_ID --text "New paragraph here"

# --- Chat ---
# Send a Chat message to a space
gws chat-send --space "spaces/SPACE_ID" --text "Hello team!"

# --- Apps Script ---
# Upload local files to an Apps Script project
gws apps-script-push --script-id SCRIPT_ID --source ./src

# --- Workspace Events ---
# Subscribe to Workspace events and stream them as NDJSON
gws events-subscribe --target "//calendar.googleapis.com/calendars/primary" --event-types "google.workspace.calendar.event.v1.created"

# Renew/reactivate Workspace Events subscriptions
gws events-renew --subscription-id SUB_ID

# --- Model Armor ---
# Sanitize a user prompt through a Model Armor template
gws modelarmor-sanitize-prompt --template "projects/P/locations/L/templates/T" --text "user input here"

# Sanitize a model response through a Model Armor template
gws modelarmor-sanitize-response --template "projects/P/locations/L/templates/T" --text "model output here"

# Create a new Model Armor template
gws modelarmor-create-template --project PROJECT --location LOCATION --template-id my-template

# --- Cross-service Workflows ---
# Today's standup report (meetings + open tasks)
gws workflow-standup-report

# Meeting prep (agenda, attendees, linked docs)
gws workflow-meeting-prep

# Convert email to task
gws workflow-email-to-task --message-id MSG_ID

# Weekly digest (meetings + unread count)
gws workflow-weekly-digest

# Announce a Drive file in a Chat space
gws workflow-file-announce --file-id FILE_ID --space "spaces/SPACE_ID"

エージェントプロジェクトへの gws スキルのインストール

gws リポジトリには、エージェントのスキルディレクトリに直接インストールできる 100 個以上の SKILL.md ファイルが用意されています。

# Install ALL gws skills at once
npx skills add https://github.com/googleworkspace/cli

# Or pick only what you need
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-drive
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-gmail
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-calendar
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-sheets
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-docs
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-chat
OpenClaw のセットアップ
# Symlink all skills (stays in sync with repo)
ln -s $(pwd)/skills/gws-* ~/.openclaw/skills/

# Or copy specific skills
cp -r skills/gws-drive skills/gws-gmail ~/.openclaw/skills/

gws-shared スキルには install ブロックが含まれており、gws が PATH 上にない場合、OpenClaw が npm 経由で CLI を自動インストールします。

これにより、SKILL.md ファイルがプロジェクトの .github/skills/(Copilot)、.claude/skills/(Claude Code)、または同等のディレクトリに配置され、エージェントがサービスごとの詳細な知識を利用できるようになります。

ペルソナ(役割別スキルバンドル)

gws リポジトリには、一般的な役割に合わせて複数のサービスを組み合わせた、構築済みのペルソナバンドルが 10 個含まれています。

ペルソナ 説明 使用サービス persona-exec-assistant 役員のスケジュール、受信トレイ、コミュニケーションを管理します Calendar、Gmail、Chat、Tasks persona-project-manager プロジェクトを調整します — タスクの追跡、会議のスケジュール設定、ドキュメントの共有 Tasks、Calendar、Drive、Chat persona-hr-coordinator 人事ワークフローを処理します — オンボーディング、告知、従業員とのコミュニケーション Admin、Gmail、Calendar、Docs persona-sales-ops 営業ワークフローを管理します — 商談の追跡、通話のスケジュール設定、顧客とのコミュニケーション Sheets、Gmail、Calendar、Chat persona-it-admin IT を管理します — ユーザーの管理、セキュリティの監視、Workspace の設定 Admin、Alert Center、Cloud Identity persona-content-creator Workspace 全体でコンテンツを作成、整理、配布します Docs、Slides、Drive、Gmail persona-customer-support カスタマーサポートを管理します — チケットの追跡、返信、問題のエスカレーション Gmail、Sheets、Chat、Tasks persona-event-coordinator イベントを計画、管理します — スケジュール設定、招待、運営 Calendar、Gmail、Drive、Chat persona-team-lead チームを率います — 朝会の実施、タスクの調整、コミュニケーション Calendar、Tasks、Chat、Gmail persona-researcher 調査を整理します — 参考資料、メモ、共同作業の管理 Drive、Docs、Keep、Sheets

ペルソナをインストールします:

npx skills add https://github.com/googleworkspace/cli/tree/main/skills/persona-exec-assistant
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/persona-it-admin

レシピ(複数ステップのタスクシーケンス)

gws リポジトリには、実際のコマンドを使った複数ステップのタスクシーケンスである、厳選された50個のレシピが含まれています。主なレシピは次のとおりです。

レシピ 内容 recipe-audit-external-sharing 組織外と共有されている Drive ファイルを見つけて確認します recipe-label-and-archive-emails 条件に一致するメッセージに Gmail ラベルを付けてアーカイブします recipe-send-personalized-emails Sheets からデータを読み込み、各行の宛先にパーソナライズした Gmail を送信します recipe-draft-email-from-doc Google ドキュメントを読み込み、その内容を Gmail の本文として使用します recipe-organize-drive-folder フォルダ構成を作成し、ファイルを適切な場所に移動します recipe-share-folder-with-team Drive フォルダを共同作業者と共有します recipe-email-drive-link ファイルを共有し、リンクをメールで送信します recipe-create-doc-from-template Docs テンプレートをコピーし、内容を入力して共有します recipe-create-expense-tracker 経費管理用の Sheets を設定します recipe-block-focus-time Calendar に定期的な集中時間を作成します recipe-reschedule-meeting イベントを移動し、参加者に通知します recipe-search-and-export-emails 条件に一致する Gmail メッセージを検索してエクスポートします recipe-create-gmail-filter 受信メッセージにラベルやスターを自動で付けます recipe-cancel-and-notify イベントを削除し、キャンセルメールを送信します recipe-find-free-time 複数のユーザーの予定の空き状況を照会します recipe-bulk-download-folder Drive フォルダ内のすべてのファイルをダウンロードします recipe-find-large-files ストレージを消費している大きな Drive ファイルを特定します recipe-create-shared-drive 共有ドライブを作成し、メンバーを追加します recipe-transfer-file-ownership ユーザー間で Drive ファイルの所有権を移行します recipe-post-mortem-setup ドキュメントを作成し、Calendar の振り返りを予定して、Chat で通知します recipe-save-email-attachments Gmail の添付ファイルを Drive に保存します recipe-send-team-announcement Gmail と Chat で同時にお知らせを送信します recipe-create-feedback-form フォームを作成し、Gmail で共有します recipe-sync-contacts-to-sheet 連絡先ディレクトリを Sheets にエクスポートします recipe-create-events-from-sheet Sheets のデータを読み込み、Calendar のイベントを作成します recipe-generate-report-from-sheet Sheets のデータを読み込み、Docs のレポートを作成します recipe-save-email-to-doc Gmail メッセージの本文をドキュメントに保存してアーカイブします recipe-batch-reply-to-emails 条件に一致するメールを検索し、定型の返信を送信します recipe-batch-rename-files Drive ファイルの名前を統一した形式に変更します recipe-create-vacation-responder Gmail の不在時自動返信を有効にします recipe-triage-security-alerts Workspace のセキュリティ アラートを確認します recipe-deploy-apps-script ローカルファイルを Apps Script プロジェクトにプッシュします recipe-create-meet-space Meet スペースを作成し、参加リンクを共有します recipe-create-presentation 最初のスライドを含む Slides プレゼンテーションを作成します recipe-create-classroom-course Classroom のコースを作成し、生徒を招待します

レシピをインストールします。

npx skills add https://github.com/googleworkspace/cli/tree/main/skills/recipe-send-personalized-emails
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/recipe-audit-external-sharing

全レシピの一覧:https://github.com/googleworkspace/cli/blob/main/docs/skills.md

MCP サーバーとの連携

gws mcp は stdio 経由で Model Context Protocol サーバーを起動し、Google Workspace API を構造化されたツールとして、MCP 対応の任意のクライアントに公開します。

# Start MCP server for specific services
gws mcp -s drive                  # Drive only
gws mcp -s drive,gmail,calendar   # multiple services
gws mcp -s all                    # all services (many tools!)

# Include workflow and helper tools
gws mcp -s drive,gmail -w -e

# Compact tool mode — reduces context window usage for LLMs
gws mcp -s drive,gmail --compact
MCP クライアントの設定

VS Code / Copilot(settings.json または .vscode/mcp.json):

{
  "mcpServers": {
    "gws": {
      "command": "gws",
      "args": ["mcp", "-s", "drive,gmail,calendar,sheets,docs"]
    }
  }
}

Claude Desktop(claude_desktop_config.json):

{
  "mcpServers": {
    "gws": {
      "command": "gws",
      "args": ["mcp", "-s", "drive,gmail,calendar,sheets,docs"]
    }
  }
}

Cursor(.cursor/mcp.json):

{
  "mcpServers": {
    "gws": {
      "command": "gws",
      "args": ["mcp", "-s", "drive,gmail,calendar"]
    }
  }
}

Gemini CLI 拡張機能:

gws auth setup
gemini extensions install https://github.com/googleworkspace/cli

Gemini 拡張機能をインストールすると、Gemini CLI エージェントからすべての gws コマンドとスキルに直接アクセスできるようになります。この拡張機能は、ターミナルの認証情報を自動的に引き継ぎます。

**ヒント:**各サービスで追加されるツールは、およそ10~80個です。クライアントのツール上限(通常50~100個)を超えないよう、実際に必要なものだけに絞ってください。コンテキストウィンドウの使用量を減らすには、--compact フラグを使用します。

MCP フラグ
フラグ 説明 -s, --services <list> 公開するサービスをカンマ区切りで指定します。または all を指定します -w, --workflows ワークフローツールも公開します -e, --helpers ヘルパーツールも公開します --compact コンパクトなツールモードです。ツールの説明を短縮して、コンテキストウィンドウを節約します

高度な使い方

ドライラン(リクエストを実行せずにプレビュー)
gws drive files list --params '{"pageSize": 5}' --dry-run
ページネーション
# Auto-paginate everything as NDJSON
gws drive files list --params '{"pageSize": 100}' --page-all

# Limit pages
gws drive files list --params '{"pageSize": 100}' --page-all --page-limit 5

# Delay between pages (rate limiting)
gws drive files list --params '{"pageSize": 100}' --page-all --page-delay 200
出力のパイプ処理と加工

すべての出力は構造化 JSON です。加工するには jq にパイプします。

# Get just file names
gws drive files list --params '{"pageSize": 100}' --page-all | jq -r '.files[].name'

# Get unread email subjects
gws gmail users messages list --params '{"userId": "me", "q": "is:unread", "maxResults": 5}' | jq '.messages[].id'

# Count events this week
gws calendar events list --params '{"calendarId": "primary", "timeMin": "2026-03-02T00:00:00Z", "timeMax": "2026-03-08T00:00:00Z", "singleEvents": true}' | jq '.items | length'
マルチパートアップロード
gws drive files create --json '{"name": "report.pdf"}' --upload ./report.pdf
Model Armor(レスポンスのサニタイズ)

エージェントに届く前に、API レスポンスをスキャンしてプロンプトインジェクションを検出します。

gws gmail users messages get --params '{"userId": "me", "id": "MSG_ID"}' \
  --sanitize "projects/P/locations/L/templates/T"
環境変数 説明 GOOGLE_WORKSPACE_CLI_SANITIZE_TEMPLATE デフォルトの Model Armor テンプレート GOOGLE_WORKSPACE_CLI_SANITIZE_MODE warn(デフォルト)または block

エージェントの判断ガイド

ユーザーの依頼に応じて実行する gws コマンドを決めるには、この表を使用します。

ユーザーの意図 サービス コマンド例 ファイルの一覧表示、検索、アップロード、ダウンロード、共有 drive gws drive files list フォルダの作成、権限の管理 drive gws drive files create, gws drive permissions create メールの閲覧、送信、検索、ラベル付け gmail gws gmail users messages list/send 下書きの作成、フィルタの管理 gmail gws gmail users drafts create カレンダーイベントの表示、作成、更新、削除 calendar gws calendar events list/insert/update/delete 空き状況/予定あり・なしの確認 calendar gws calendar freebusy query スプレッドシートデータの読み取り、書き込み、追記 sheets gws sheets spreadsheets values get/update/append スプレッドシートの作成、セルの書式設定 sheets gws sheets spreadsheets create/batchUpdate ドキュメントの作成、読み取り、編集 docs gws docs documents create/get/batchUpdate プレゼンテーションの作成、編集 slides gws slides presentations create/batchUpdate メッセージの送信、チャットスペースの管理 chat gws chat spaces messages create タスクや To-Do リストの管理 tasks gws tasks tasks list/insert/update 会議リンクの作成 meet gws meet spaces create フォームの作成、回答の閲覧 forms gws forms forms create, gws forms forms responses list 連絡先やプロフィールの管理 people gws people people connections list ユーザー、グループ、デバイスの管理 admin gws admin users list, gws admin groups list メモの管理 keep gws keep notes list Apps Script プロジェクトの実行/デプロイ apps-script gws apps-script projects list 監査ログと使用状況レポート admin-reports gws admin-reports activities list セキュリティアラートの管理 alertcenter gws alertcenter alerts list ID とグループの管理 cloudidentity gws cloudidentity groups list Workspace イベントのサブスクライブ events gws events subscriptions create Google Vault(電子情報開示)の管理 vault gws vault matters list Workspace ライセンスの管理 licensing gws licensing licenseAssignments list Google Classroom の管理 classroom gws classroom courses list Google Groups の設定 groupssettings gws groupssettings groups get/update Workspace サブスクリプションの管理 reseller gws reseller subscriptions list 安全性確保のためのコンテンツのサニタイズ modelarmor gws modelarmor-sanitize-prompt

環境変数リファレンス

変数 説明 GOOGLE_WORKSPACE_CLI_TOKEN 事前に取得した OAuth アクセストークン GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE 認証情報 JSON(サービスアカウントまたはエクスポート済み)のパス GOOGLE_WORKSPACE_CLI_ACCOUNT デフォルトのアカウントメールアドレス GOOGLE_WORKSPACE_CLI_IMPERSONATED_USER なりすますユーザー(ドメイン全体の委任) GOOGLE_WORKSPACE_CLI_SANITIZE_TEMPLATE デフォルトの Model Armor テンプレート GOOGLE_WORKSPACE_CLI_SANITIZE_MODE warn または block

トラブルシューティング

エラー 解決方法 ログイン中の「Access blocked」または 403 OAuth 同意画面で自分をテストユーザーに追加します 「Google hasn't verified this app」 「Advanced」→「Continue」をクリックします(個人利用であれば安全です) スコープが多すぎるというエラー gws auth login -s drive,gmail,sheets を使って、選択するサービスを減らします gcloud CLI が見つからない gcloud をインストールするか、Cloud Console で OAuth を手動で設定します redirect_uri_mismatch OAuth クライアントを Desktop アプリタイプとして再作成します accessNotConfigured 以下の詳細な解決方法を参照してください 認証情報が古い gws auth login を実行して再認証します
API が有効になっていない — accessNotConfigured

必要な Google API が GCP プロジェクトで有効になっていない場合、403 エラーが表示されます。

{
  "error": {
    "code": 403,
    "message": "Gmail API has not been used in project 549352339482 ...",
    "reason": "accessNotConfigured",
    "enable_url": "https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482"
  }
}

gws は stderr に実行可能なヒントも出力します。

💡 API not enabled for your GCP project.
   Enable it at: https://console.developers.google.com/apis/api/gmail.googleapis.com/overview?project=549352339482
   After enabling, wait a few seconds and retry your command.

解決手順:

  1. enable_url のリンクをクリックします(または JSON の enable_url フィールドからコピーします)。
  2. GCP Console で Enable をクリックします。
  3. 約 10 秒待ってから、gws コマンドを再試行します。

ヒント: gws auth setup を実行することもできます。これにより、プロジェクトで必要なすべての API を有効にする手順が自動的に案内されます。

アーキテクチャ

gws は 2 段階の解析方式を使用します。

  1. argv[1] を読み取り、サービス(例:drive)を識別します。
  2. サービスの Discovery Document を取得します(24 時間キャッシュされます)。
  3. ドキュメント内のリソースとメソッドから clap::Command ツリーを構築します。
  4. 残りの引数を再解析します。
  5. 認証し、HTTP リクエストを構築して実行します。

成功、エラー、ダウンロードのメタデータなど、すべての出力は構造化 JSON です。つまり、エージェントはテキストを抽出せずに、すべての応答を直接解析できます。

リソース

ライセンス

Apache-2.0

コメント