| name | jgmcli |
| description | Gmail CLI (Java) for searching emails, reading threads, sending messages, managing drafts, and handling labels/attachments. |
Gmail CLI (Java)
Command-line interface for Gmail operations. Java port of gmcli.
Source: https://github.com/maxandersen/jgmcli
Installation
Option 1: Run directly with JBang (no install)
jbang jgmcli@maxandersen/skills --help
Option 2: Install as command
jbang app install jgmcli@maxandersen/skills
jgmcli --help
Setup
Google Cloud Console (one-time)
- Create a new project (or select existing)
- Enable the Gmail API
- Set app name in OAuth branding
- Add test users (all Gmail addresses you want to use)
- Create OAuth client:
- Click "Create Client"
- Application type: "Desktop app"
- Download the JSON file
Configure jgmcli
First check if already configured:
jgmcli accounts list
If no accounts, guide the user through setup:
- Ask if they have a Google Cloud project with Gmail API enabled
- If not, walk them through the Google Cloud Console steps above
- Have them download the OAuth credentials JSON
- Run:
jgmcli accounts credentials ~/path/to/credentials.json
- Run:
jgmcli accounts add <email> (use --manual for browserless OAuth)
Shared Credentials
Credentials in ~/.jgcli/ are shared across jgccli, jgmcli, and jgdcli. Set up once, use with all three.
For separate credentials, use named credentials:
jgmcli accounts credentials ~/work-creds.json --name work
jgmcli accounts add work@company.com --credentials work
Usage
Run jgmcli --help for full command reference.
Common operations:
jgmcli search <email> "<query>" - Search emails using Gmail query syntax
jgmcli thread <email> <threadId> - Read a thread with all messages
jgmcli send <email> --to <emails> --subject <s> --body <b> - Send email
jgmcli labels <email> list - List all labels
jgmcli drafts <email> list - List drafts
Gmail Query Syntax
in:inbox, in:sent, in:drafts, in:trash
is:unread, is:starred, is:important
from:sender@example.com, to:recipient@example.com
subject:keyword, has:attachment, filename:pdf
after:2024/01/01, before:2024/12/31
label:Work, label:UNREAD
Combine: "in:inbox is:unread from:boss@company.com"
Data Storage
~/.jgcli/credentials.json - OAuth client credentials (shared with jgccli, jgdcli)
~/.jgcli/accounts-gmail.json - Account tokens
~/.jgcli/attachments/ - Downloaded attachments