Google Workspace CLI with multi-profile support for Gmail, Calendar, and Drive. Designed for both human use and LLM agent integration.
This CLI was built specifically to give LLM agents (like Claude Code) access to Google Workspace.
Why CLI instead of MCP? CLIs are more context-efficient. MCP servers require tool schemas to be loaded into the agent's context window on every request. A CLI skill only needs a concise command reference, and the agent invokes it via standard shell execution. Same capabilities, fewer tokens.
The JSON output mode provides structured data that agents can parse and act on.
Use cases:
- Let Claude Code read and respond to your emails
- Have an AI agent manage your calendar
- Search and retrieve Google Drive files programmatically
- Multi-account support - Named profiles like AWS CLI (e.g.,
personal,work) - Gmail - List, search, read, archive, draft, send, reply
- Calendar - List calendars, view events, create/update/delete events
- Drive - List, search, download files, export Google Docs/Sheets/Slides
- Flexible output - JSON (for agents), table, or text format
git clone https://github.com/ianpatrickhines/google-workspace-cli.git
cd google-workspace-cli
npm install
npm run build
npm link- Go to Google Cloud Console
- Create a new project (or select existing)
- Enable APIs:
- Gmail API
- Google Calendar API
- Google Drive API
- Go to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- Select Desktop app as application type
- Download the JSON file
gwcli profiles add personal --client ~/Downloads/client_secret_*.jsonThis opens a browser for Google authentication. After authorizing, the tokens are stored locally.
gwcli profiles set-default personalgwcli --profile work gmail list # Use specific profile
GWCLI_PROFILE=work gwcli gmail list # Via environment variable
gwcli gmail list # Uses default profile# List recent emails
gwcli gmail list
gwcli gmail list --unread --limit 20
# Search emails
gwcli gmail search "from:[email protected]"
gwcli gmail search "subject:invoice is:unread"
# Read email
gwcli gmail read <message-id>
gwcli gmail thread <thread-id>
# Compose and send
gwcli gmail draft --to [email protected] --subject "Hello" --body "Message"
gwcli gmail send <draft-id>
gwcli gmail send --to [email protected] --subject "Hello" --body "Message"
# Reply to a message
gwcli gmail reply <message-id> --body "Thanks for your email"
# Archive or trash
gwcli gmail archive <message-id>
gwcli gmail trash <message-id># List calendars
gwcli calendar list
# View upcoming events
gwcli calendar events
gwcli calendar events --days 14 --limit 20
# Search events
gwcli calendar search "meeting"
# Create event
gwcli calendar create "Team Meeting" --start "2025-01-15 10:00" --end "2025-01-15 11:00"
gwcli calendar create "Lunch" --start "tomorrow 12:00"
# Update event
gwcli calendar update <event-id> --title "New Title" --start "2025-01-15 14:00"
# Delete event
gwcli calendar delete <event-id># List files
gwcli drive list
gwcli drive list --folder <folder-id> --limit 50
# Search files
gwcli drive search "name contains 'report'"
gwcli drive search "mimeType = 'application/pdf'"
# Download file
gwcli drive download <file-id>
gwcli drive download <file-id> --output ~/Downloads/report.pdf
# Export Google Docs/Sheets/Slides
gwcli drive export <doc-id> --format pdf
gwcli drive export <sheet-id> --format xlsx
gwcli drive export <slide-id> --format pptxgwcli gmail list --format json # JSON (for scripting/Claude Code)
gwcli gmail list --format table # Formatted table (default)
gwcli gmail list --format text # Plain textgwcli profiles list # List all profiles
gwcli profiles add <name> --client <path> # Add new profile
gwcli profiles remove <name> # Delete profile
gwcli profiles set-default <name> # Set default profileConfig files are stored in ~/.config/gwcli/:
~/.config/gwcli/
├── config.json # Global settings, default profile
└── profiles/
├── personal/
│ ├── credentials.json # OAuth tokens
│ └── config.json # Profile metadata
└── work/
└── credentials.json
To use with Claude Code, create a skill file that teaches it how to use the CLI.
Example skill (~/.claude/skills/gwcli/SKILL.md):
---
name: gwcli
description: "Google Workspace CLI for Gmail, Calendar, and Drive. Use when reading/sending emails, managing calendar events, or accessing Drive files."
---Then add command reference and examples in the skill body. The key is using --format json so Claude can parse the output:
# Claude can parse this structured output
gwcli gmail list --format json
gwcli calendar events --format jsonAny agent that can execute shell commands can use this CLI. The JSON output mode provides structured data:
# Returns JSON array of emails
gwcli gmail list --format json
# Returns JSON array of calendar events
gwcli calendar events --days 7 --format json
# Returns JSON array of files
gwcli drive list --format jsonFor Claude Code, you can pre-approve gwcli commands in your settings so the agent can run them without confirmation:
{
"permissions": {
"allow": [
"Bash(gwcli:*)"
]
}
}MIT