| name | skill-google-gmail-tool |
| description | Access Google Gmail, Calendar, Tasks, Drive APIs |
When to use
- Access Gmail messages, send emails, export to Obsidian
- Manage Google Calendar events and export schedules
- Work with Google Tasks and to-do lists
- Search, upload, download Google Drive files
Google Gmail Tool Skill
Purpose
The google-gmail-tool is a professional CLI that provides comprehensive access to Google services including Gmail, Calendar, Tasks, and Drive. It enables agent-friendly JSON output, human-readable text formats, multi-level verbosity logging, and seamless Obsidian integration.
When to Use This Skill
Use this skill when:
- Reading or sending Gmail messages programmatically
- Managing calendar events and schedules
- Working with Google Tasks and to-do lists
- Searching, uploading, or downloading files from Google Drive
- Exporting Google data to Obsidian markdown notes
- Automating Google service workflows
Do NOT use this skill for:
- Direct Google API programming (this is a CLI wrapper)
- Google Workspace admin tasks (requires different APIs)
- Real-time synchronization (uses polling-based access)
CLI Tool: google-gmail-tool
A CLI that provides access to Google services with OAuth2 authentication, supporting Gmail, Calendar, Tasks, and Drive operations.
Installation
git clone https://github.com/dnvriend/google-gmail-tool.git
cd google-gmail-tool
uv tool install .
google-gmail-tool --version
Prerequisites
- Python: 3.14 or higher
- OAuth Credentials: Google Cloud Console OAuth 2.0 Client ID (Desktop application)
- Environment Variables:
GOOGLE_GMAIL_TOOL_CREDENTIALS: Path to credentials JSON file
GOOGLE_GMAIL_TOOL_CREDENTIALS_JSON: Full OAuth2 credentials as JSON string
OBSIDIAN_ROOT: Path to Obsidian vault (for export commands)
Quick Start
export GOOGLE_GMAIL_TOOL_CREDENTIALS=~/.config/google-gmail-tool/credentials.json
google-gmail-tool auth check
google-gmail-tool mail list --today
google-gmail-tool calendar list --this-week
Progressive Disclosure
📧 Gmail Commands (Click to expand)
mail list - List Gmail messages or threads
List Gmail messages or threads with optional filtering, supporting full Gmail search syntax.
Usage:
google-gmail-tool mail list [OPTIONS]
Options:
--query "TEXT": Gmail search query (supports full Gmail search syntax)
--today: Filter emails from today only
--max-results N / -n N: Maximum results (default: 50, max: 500)
--format FORMAT / -f FORMAT: Output format (json, text)
--text: Shorthand for --format text
--message-mode: List individual messages instead of threads
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Gmail Search Operators:
is:unread, is:read, is:starred - Message status
has:attachment, filename:pdf - Attachments
from:email@example.com - Sender
to:email@example.com - Recipient
subject:keyword - Subject line
after:YYYY/MM/DD, before:YYYY/MM/DD - Date range
older_than:2d, newer_than:1m - Relative dates
label:important, in:inbox - Labels
Examples:
google-gmail-tool mail list
google-gmail-tool mail list --today --query "is:unread"
google-gmail-tool mail list --query "from:team@company.com" -n 10
google-gmail-tool mail list --query "has:attachment" --text
google-gmail-tool mail list \
--query "from:john@example.com subject:report after:2025/01/01" \
--message-mode
Output (JSON):
[
{
"id": "19a90f13e3c7af52",
"threadId": "19a90f13e3c7af52",
"snippet": "Meeting notes from...",
"from": "sender@example.com",
"to": "recipient@example.com",
"subject": "Meeting Notes",
"date": "2025-11-20T10:30:00Z"
}
]
mail send - Send email via Gmail
Send emails via Gmail API with support for HTML, CC, BCC, and attachments.
Usage:
google-gmail-tool mail send [OPTIONS]
Options:
--to EMAIL: Recipient email (required)
--subject TEXT: Email subject (required)
--body TEXT: Email body (required)
--from EMAIL: Sender email (optional, uses default)
--cc EMAIL: CC recipients (comma-separated)
--bcc EMAIL: BCC recipients (comma-separated)
--html: Send as HTML instead of plain text
--dry-run: Preview email without sending
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Examples:
google-gmail-tool mail send \
--to "user@example.com" \
--subject "Meeting Notes" \
--body "Here are the notes from today's meeting..."
google-gmail-tool mail send \
--to "user@example.com" \
--cc "team@example.com" \
--subject "Weekly Report" \
--body "<h1>Report</h1><p>Details...</p>" \
--html
google-gmail-tool mail send \
--to "user@example.com" \
--subject "Test" \
--body "Test email" \
--dry-run
mail get - Get email message details
Retrieve detailed information about a specific Gmail message.
Usage:
google-gmail-tool mail get MESSAGE_ID [OPTIONS]
Options:
MESSAGE_ID: Gmail message ID (required)
--format FORMAT / -f FORMAT: Output format (json, text)
--include-body: Include full message body
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Examples:
google-gmail-tool mail get 19a90f13e3c7af52
google-gmail-tool mail get 19a90f13e3c7af52 --include-body
google-gmail-tool mail get 19a90f13e3c7af52 --include-body --format text
mail export-obsidian - Export Gmail to Obsidian
Export Gmail threads to Obsidian markdown notes with attachments.
Usage:
google-gmail-tool mail export-obsidian [OPTIONS]
Options:
--query "TEXT": Gmail search query
--today: Export emails from today only
--max-results N / -n N: Maximum threads to export
--obsidian-root PATH: Obsidian vault root path (or use OBSIDIAN_ROOT env var)
--download-attachments: Download email attachments (default)
--no-download-attachments: Skip downloading attachments
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Obsidian Structure:
$OBSIDIAN_ROOT/emails/<timestamp>-<sender>-<subject>/
├── thread.md # Thread with all messages
└── attachments/ # Downloaded attachments
├── document.pdf
└── image.png
Examples:
google-gmail-tool mail export-obsidian --today
google-gmail-tool mail export-obsidian --query "from:important@example.com"
google-gmail-tool mail export-obsidian \
--query "subject:report" \
--no-download-attachments
📅 Calendar Commands (Click to expand)
calendar list - List calendar events
List calendar events with time range and query filtering.
Usage:
google-gmail-tool calendar list [OPTIONS]
Options:
--today: Events for today
--tomorrow: Events for tomorrow
--this-week: Events this week (Monday-Sunday, default)
--next-week: Events next week
--days N: Events for next N days
--date YYYY-MM-DD: Events for specific date
--range-start YYYY-MM-DD: Start of custom range
--range-end YYYY-MM-DD: End of custom range
--query "TEXT": Free-text search (title, description, location)
--max-results N / -n N: Maximum results (default: 100)
--format FORMAT / -f FORMAT: Output format (json, text)
--text: Shorthand for --format text
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Examples:
google-gmail-tool calendar list
google-gmail-tool calendar list --today
google-gmail-tool calendar list --days 7
google-gmail-tool calendar list --query "team meeting"
google-gmail-tool calendar list \
--range-start 2025-11-20 \
--range-end 2025-11-27
Output (JSON):
[
{
"id": "event123",
"summary": "Team Meeting",
"start": "2025-11-20T10:00:00Z",
"end": "2025-11-20T11:00:00Z",
"location": "Conference Room A",
"attendees": ["user1@example.com", "user2@example.com"]
}
]
calendar create - Create calendar event
Create a new calendar event with optional attendees and Google Meet.
Usage:
google-gmail-tool calendar create [OPTIONS]
Options:
--title TEXT / -t TEXT: Event title (required)
--start DATETIME: Start datetime (YYYY-MM-DD HH:MM)
--end DATETIME: End datetime (YYYY-MM-DD HH:MM)
--date YYYY-MM-DD: Date for all-day event
--all-day: Create all-day event (requires --date)
--location TEXT / -l TEXT: Event location
--description TEXT / -d TEXT: Event description
--attendees EMAILS / -a EMAILS: Comma-separated attendee emails
--add-meet: Add Google Meet video conferencing
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Examples:
google-gmail-tool calendar create \
--title "Team Meeting" \
--start "2025-11-20 10:00" \
--end "2025-11-20 11:00"
google-gmail-tool calendar create \
--title "Remote Standup" \
--start "2025-11-21 09:00" \
--end "2025-11-21 09:30" \
--add-meet
google-gmail-tool calendar create \
--title "Conference" \
--date "2025-11-25" \
--all-day
google-gmail-tool calendar create \
--title "Project Review" \
--start "2025-11-22 14:00" \
--end "2025-11-22 15:00" \
--location "Room 301" \
--attendees "user1@example.com,user2@example.com"
calendar export-obsidian - Export calendar to Obsidian
Export calendar events to Obsidian daily notes as checklist items.
Usage:
google-gmail-tool calendar export-obsidian [OPTIONS]
Options:
--today: Export today's events
--this-week: Export this week's events (default)
--date YYYY-MM-DD: Export specific date
--range-start YYYY-MM-DD: Start of custom range
--range-end YYYY-MM-DD: End of custom range
--query "TEXT": Filter events by search query
--obsidian-root PATH: Obsidian vault root path
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Smart Merge Logic:
- Preserves checked-off items
- Updates event times if changed
- Removes cancelled events
- Adds new events
Examples:
google-gmail-tool calendar export-obsidian --today
google-gmail-tool calendar export-obsidian --this-week
google-gmail-tool calendar export-obsidian --query "meeting"
✅ Task Commands (Click to expand)
task list - List Google Tasks
List Google Tasks with status and date filtering.
Usage:
google-gmail-tool task list [OPTIONS]
Options:
--completed: Show only completed tasks
--incomplete: Show only incomplete tasks (default)
--show-all: Show both completed and incomplete
--today: Tasks due today
--overdue: Tasks past due date
--max-results N / -n N: Maximum results (default: 100)
--format FORMAT / -f FORMAT: Output format (json, text)
--text: Shorthand for --format text
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Examples:
google-gmail-tool task list
google-gmail-tool task list --show-all
google-gmail-tool task list --today
google-gmail-tool task list --overdue
google-gmail-tool task list --incomplete -n 10
Output (JSON):
[
{
"id": "task123",
"title": "Review PR #456",
"notes": "Check code quality and tests",
"due": "2025-11-20",
"status": "needsAction",
"updated": "2025-11-19T15:30:00Z"
}
]
task create - Create new task
Create a new Google Task with optional notes and due date.
Usage:
google-gmail-tool task create [OPTIONS]
Options:
--title TEXT / -t TEXT: Task title (required)
--notes TEXT / -n TEXT: Task notes/description
--due YYYY-MM-DD / -d YYYY-MM-DD: Due date
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Examples:
google-gmail-tool task create --title "Review PR #123"
google-gmail-tool task create \
--title "Submit report" \
--due "2025-11-25"
google-gmail-tool task create \
--title "Team meeting prep" \
--notes "Prepare slides and agenda" \
--due "2025-11-20"
task complete - Mark tasks as completed
Mark one or more tasks as completed.
Usage:
google-gmail-tool task complete TASK_ID [TASK_ID...] [OPTIONS]
Options:
TASK_ID: One or more task IDs (space-separated)
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Examples:
google-gmail-tool task complete abc123xyz
google-gmail-tool task complete abc123 def456 ghi789
TASK_ID=$(google-gmail-tool task list -n 1 | jq -r '.[0].id')
google-gmail-tool task complete "$TASK_ID"
task export-obsidian - Export tasks to Obsidian
Export Google Tasks to Obsidian daily notes as checklist items.
Usage:
google-gmail-tool task export-obsidian [OPTIONS]
Options:
--today: Export tasks due today
--this-week: Export tasks due this week
--date YYYY-MM-DD: Export tasks for specific date
--range-start YYYY-MM-DD: Start of custom range
--range-end YYYY-MM-DD: End of custom range
--obsidian-root PATH: Obsidian vault root path
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Smart Merge Logic:
- Preserves checked-off items
- Updates task details if changed
- Removes completed tasks (optional)
- Adds new tasks
Examples:
google-gmail-tool task export-obsidian --today
google-gmail-tool task export-obsidian --this-week
google-gmail-tool task export-obsidian \
--range-start 2025-11-20 \
--range-end 2025-11-27
📁 Drive Commands (Click to expand)
drive list - List Drive files
List files in Google Drive with filtering and sorting.
Usage:
google-gmail-tool drive list [OPTIONS]
Options:
--query "TEXT": Drive query string
--max-results N / -n N: Maximum results (default: 50)
--folder FOLDER_ID: List files in specific folder
--order-by FIELD: Sort by field (name, createdTime, modifiedTime desc)
--format FORMAT / -f FORMAT: Output format (json, text)
--text: Shorthand for --format text
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Examples:
google-gmail-tool drive list
google-gmail-tool drive list --folder 0ALlMmd1yT2TNUk9PVA
google-gmail-tool drive list --order-by name -n 20
Output (JSON):
[
{
"id": "1abc...xyz",
"name": "document.pdf",
"mimeType": "application/pdf",
"size": "1048576",
"modifiedTime": "2025-11-20T10:30:00Z",
"webViewLink": "https://drive.google.com/..."
}
]
drive search - Search Drive files
Search for files and folders with common filters.
Usage:
google-gmail-tool drive search [OPTIONS]
Options:
--name "TEXT": Search by file/folder name
--type TYPE: Filter by type (document, spreadsheet, presentation, folder, pdf, image)
--owner OWNER: Filter by owner (me, others, anyone)
--shared: Show only shared files
--max-results N / -n N: Maximum results (default: 50)
--format FORMAT / -f FORMAT: Output format (json, text)
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Examples:
google-gmail-tool drive search --name "report"
google-gmail-tool drive search --type pdf --owner me
google-gmail-tool drive search --type spreadsheet --shared
google-gmail-tool drive search \
--name "2025" \
--type document \
--owner me \
-n 100
drive upload-file - Upload file to Drive
Upload a local file to Google Drive.
Usage:
google-gmail-tool drive upload-file LOCAL_PATH [PARENT_ID] [OPTIONS]
Options:
LOCAL_PATH: Local file path (required)
PARENT_ID: Parent folder ID (optional, defaults to My Drive root)
--name NAME: Drive file name (defaults to local filename)
--description TEXT: File description
--mime-type TYPE: Override MIME type
--force / -f: Skip duplicate check
--format FORMAT: Output format (json, text)
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Examples:
google-gmail-tool drive upload-file document.pdf
google-gmail-tool drive upload-file report.pdf 0ALlMmd1yT2TNUk9PVA
google-gmail-tool drive upload-file data.csv \
--name "Sales Report 2025.csv"
drive download - Download file from Drive
Download a file from Google Drive to local filesystem.
Usage:
google-gmail-tool drive download FILE_ID OUTPUT_PATH [OPTIONS]
Options:
FILE_ID: Drive file ID (required)
OUTPUT_PATH: Local output path (required)
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Examples:
google-gmail-tool drive download 1abc...xyz document.pdf
google-gmail-tool drive download 1abc...xyz ~/Downloads/report.pdf
🔐 Authentication Commands (Click to expand)
auth check - Verify credentials
Verify Google OAuth credentials and API access.
Usage:
google-gmail-tool auth check [-v|-vv|-vvv]
Environment Variables:
GOOGLE_GMAIL_TOOL_CREDENTIALS_JSON: Full OAuth2 credentials as JSON string
GOOGLE_GMAIL_TOOL_CREDENTIALS: Path to OAuth2 credentials JSON file
Validates:
- OAuth credential format and validity
- Access token refresh capability
- Gmail API access
- Calendar API access
- Tasks API access
- Drive API access
Examples:
google-gmail-tool auth check
google-gmail-tool auth check -vv
Output:
🔐 Checking Google OAuth credentials...
✓ Credentials loaded successfully
✓ Gmail API access granted
✓ Calendar API access granted
✓ Tasks API access granted
✓ Drive API access granted
auth login - Complete OAuth flow
Complete OAuth flow to generate authorized credentials.
Usage:
google-gmail-tool auth login [OPTIONS]
Options:
--client-id ID: OAuth Client ID
--client-secret SECRET: OAuth Client Secret
--json-file PATH: Path to client secret JSON (alternative)
--output PATH / -o PATH: Output file for credentials (default: ~/.config/google-gmail-tool/credentials.json)
-v/-vv/-vvv: Verbosity (INFO/DEBUG/TRACE)
Examples:
google-gmail-tool auth login \
--client-id "123...apps.googleusercontent.com" \
--client-secret "GOCSPX-..."
google-gmail-tool auth login \
--json-file ~/Downloads/client_secret.json
google-gmail-tool auth login \
--json-file ~/Downloads/client_secret.json \
--output ~/.credentials/google.json
⚙️ Advanced Features (Click to expand)
Multi-Level Verbosity
Control logging detail with -v/-vv/-vvv flags:
- No flag (WARNING): Only critical issues
-v (INFO): High-level operations, important events
-vv (DEBUG): Detailed operations, API calls, validation steps
-vvv (TRACE): Full request/response, library internals
Examples:
google-gmail-tool mail list
google-gmail-tool mail list -v
google-gmail-tool mail list -vv
google-gmail-tool mail list -vvv
Shell Completion
Install tab completion for bash, zsh, or fish:
Bash:
eval "$(google-gmail-tool completion bash)"
Zsh:
eval "$(google-gmail-tool completion zsh)"
Fish:
google-gmail-tool completion fish > ~/.config/fish/completions/google-gmail-tool.fish
Output Formats
All commands support JSON and text output:
JSON (default):
google-gmail-tool mail list | jq '.[] | .subject'
Text (human-readable):
google-gmail-tool mail list --text
Pipeline Integration
Designed for Unix pipeline integration:
Examples:
google-gmail-tool mail list | jq -r '.[] | .subject'
google-gmail-tool mail list --query "is:unread" | jq 'length'
TASK_ID=$(google-gmail-tool task list -n 1 | jq -r '.[0].id')
google-gmail-tool task complete "$TASK_ID"
FILE_ID=$(google-gmail-tool drive search --name "report" | jq -r '.[0].id')
google-gmail-tool drive download "$FILE_ID" report.pdf
🔧 Troubleshooting (Click to expand)
Common Issues
Issue: "Credentials not found"
[ERROR] Credentials not found
Solution:
- Set credentials environment variable:
export GOOGLE_GMAIL_TOOL_CREDENTIALS=~/.config/google-gmail-tool/credentials.json
- Or use
auth login to generate credentials:
google-gmail-tool auth login --json-file ~/Downloads/client_secret.json
Issue: "API access denied"
Solution:
- Check API is enabled in Google Cloud Console
- Verify OAuth scopes include required permissions
- Re-run auth check:
google-gmail-tool auth check -vv
Issue: "Token expired"
Solution:
Credentials include refresh token, should auto-refresh. If not:
google-gmail-tool auth login --json-file ~/Downloads/client_secret.json
Issue: "Obsidian export fails"
Solution:
- Set
OBSIDIAN_ROOT environment variable:
export OBSIDIAN_ROOT=~/Documents/ObsidianVault
- Or use
--obsidian-root flag:
google-gmail-tool mail export-obsidian --obsidian-root ~/Documents/ObsidianVault
Getting Help
google-gmail-tool --help
google-gmail-tool mail --help
google-gmail-tool calendar --help
google-gmail-tool mail list --help
google-gmail-tool task create --help
Exit Codes
0: Success
1: General error (authentication, API error, validation failure)
2: Not found (message/event/task/file not found)
Output Formats
JSON (default):
- Agent-friendly structured data
- Suitable for parsing with jq
- Consistent schema across commands
Text (--text flag):
- Human-readable format
- Tabular or list output
- Good for terminal viewing
Best Practices
- Use Environment Variables: Set
GOOGLE_GMAIL_TOOL_CREDENTIALS and OBSIDIAN_ROOT for convenience
- Enable Verbosity for Debugging: Use
-vv or -vvv when troubleshooting
- JSON Output for Scripts: Default JSON output is ideal for automation
- Obsidian Integration: Use export commands to maintain synchronized notes
- Pipeline with jq: Combine with jq for powerful data processing
- Shell Completion: Install completion for better CLI experience
Resources