Communityコーディング&開発github.com

googleworkspace/gws-gmail-watch

Gmail:新しいメールを監視し、NDJSONとしてストリーミング出力します。

gws-gmail-watch とは?

このスキルは、Google WorkspaceのGmail APIを使用して、指定された受信トレイ(またはラベル)に新しいメールが届いたことを監視(ウォッチ)し、その結果を改行区切りのJSON(NDJSON)形式でストリーミング出力するためのツールです。開発者はこのスキルを使って、リアルタイムに近い形でメールの受信をトリガーとしたワークフローや自動処理を構築できます。主なプラットフォームとしてはClaude CodeやCursor、CodexなどのAIエージェント環境で利用されることを想定しており、Gmail APIのWebhook通知のセットアップとポーリングを自動化します。スキルはGoogle Cloudプロジェクトの認証情報(サービスアカウントやOAuth2.0)を使用して動作し、監視対象のメールボックスやフィルター条件を柔軟に設定できます。出力されるNDJSONは、標準入力やパイプライン処理と親和性が高く、AIエージェントが後続の処理(メール解析、返信生成、データ抽出など)を逐次的に行うのに適しています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/googleworkspace/cli/tree/main/skills/gws-gmail-watch

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

gws-gmail-watch は何をしますか?

Gmail:新しいメールを監視し、NDJSONとしてストリーミング出力します。

概要

このスキルは、指定されたGmail受信トレイ(またはラベル)を監視し、新しいメールが届いたときにそのメタデータ(件名、送信者、日時、スニペットなど)をNDJSON(改行区切りJSON)の形でストリーム出力します。

使用方法

# デフォルト設定でウォッチを開始
gws-gmail-watch

# 特定のラベルを監視
gws-gmail-watch --label INBOX

# 出力をファイルにリダイレクト
gws-gmail-watch --label UNREAD > emails.ndjson

引数

引数説明デフォルト値
--label監視するGmailラベル名INBOX
--intervalポーリング間隔(秒)60
--max-results1回のポーリングで取得する最大メール数10

環境変数

変数名説明
GOOGLE_APPLICATION_CREDENTIALSGoogle CloudサービスアカウントのJSONキーファイルパス
GMAIL_USER_ID監視対象のGmailユーザーID(メールアドレス)

認証

このスキルは、Google Cloudプロジェクトで有効化されたGmail APIと、適切な権限を持つサービスアカウントまたはOAuth2.0認証情報が必要です。

  1. Google Cloud Console でプロジェクトを作成または選択
  2. Gmail APIを有効化
  3. サービスアカウントを作成し、JSONキーをダウンロード
  4. 環境変数 GOOGLE_APPLICATION_CREDENTIALS にキーファイルのパスを設定

出力形式

スキルは標準出力にNDJSONを書き出します。各行は以下のようなJSONオブジェクトです。

{"id": "18abc123def456", "threadId": "18abc123def456", "from": "[email protected]", "subject": "件名", "date": "2024-01-01T00:00:00.000Z", "snippet": "メールのスニペット..."}
{"id": "18abc789def012", "threadId": "18abc789def012", "from": "[email protected]", "subject": "別の件名", "date": "2024-01-01T00:01:00.000Z", "snippet": "別のメールのスニペット..."}

注意事項

  • Gmail APIには割り当て制限(クォータ)があります。頻繁なポーリングは制限に達する可能性があるため、適切なインターバルを設定してください。
  • サービスアカウントを使用する場合、G Suite / Google Workspaceドメイン全体の委任が必要な場合があります。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

googleworkspace/gws-admin-reports

Google Workspace Admin SDK: Audit logs and usage reports.

googleworkspace/gws-calendar

Google Calendar: Manage calendars and events.

googleworkspace/gws-calendar-agenda

Google Calendar: Show upcoming events across all calendars.

googleworkspace/gws-calendar-insert

Google Calendar: Create a new event.

googleworkspace/gws-chat

Google Chat: Manage Chat spaces and messages.

googleworkspace/gws-chat-send

Google Chat: Send a message to a space.

googleworkspace/gws-classroom

Google Classroom: Manage classes, rosters, and coursework.

googleworkspace/gws-docs

Read and write Google Docs.

googleworkspace/gws-docs-write

Google Docs: Append text to a document.

googleworkspace/gws-drive

Google Drive: Manage files, folders, and shared drives.

googleworkspace/gws-drive-upload

Google Drive: Upload a file with automatic metadata.

googleworkspace/gws-events

Subscribe to Google Workspace events.

googleworkspace/gws-events-renew

Google Workspace Events: Renew/reactivate Workspace Events subscriptions.

googleworkspace/gws-events-subscribe

Google Workspace Events: Subscribe to Workspace events and stream them as NDJSON.

googleworkspace/gws-forms

Read and write Google Forms.

googleworkspace/gws-gmail

Gmail: Send, read, and manage email.

googleworkspace/gws-gmail-forward

Gmail: Forward a message to new recipients.

googleworkspace/gws-gmail-read

Gmail: Read a message and extract its body or headers.

googleworkspace/gws-gmail-reply

Gmail: Reply to a message (handles threading automatically).

googleworkspace/gws-gmail-reply-all

Gmail: Reply-all to a message (handles threading automatically).

関連スキル