gmaillm
LLM-friendly Gmail API wrapper with CLI and progressive disclosure patterns.
Installation
Recommended: Using Makefile (Easiest)
For the simplest installation with automatic setup:
cd /path/to/gmaillm
make install
make verify
make install-completion
See make help for all available targets.
Alternative: Manual Installation
cd /path/to/gmaillm
pip3 install --break-system-packages -e .
With Shell Completion (Recommended)
For faster typing with tab-completion support:
pip3 install --break-system-packages -e .
gmail --install-completion
exec $SHELL
Note: After running --install-completion, you'll see a message confirming the completion script was installed. Restart your shell to activate it.
Supported Shells
- bash - Uses
~/.bash_completion.d/ or ~/.bashrc
- zsh - Uses
~/.zshrc or completion directory
- fish - Uses
~/.config/fish/completions/
- PowerShell - Uses profile completion directory
Setup & Authentication
Configuration Locations
gmaillm automatically detects whether it's running as a plugin or standalone:
First Time Setup
Troubleshooting
If you see "Credentials file is empty" error:
python3 -m gmaillm.setup_auth
python3 -m gmaillm.setup_auth --port 8081
If you see "Address already in use" error:
pkill -f "gmaillm.setup_auth"
python3 -m gmaillm.setup_auth --port 9999
Quick Start
CLI Usage
gmail verify
gmail list
gmail list --folder SENT --max 5
gmail read <message_id>
gmail read <message_id> --full
gmail thread <message_id>
gmail search "from:example@gmail.com has:attachment"
gmail reply <message_id> --body "Thanks for the update!"
gmail send --to user@example.com --subject "Test" --body "Hello"
gmail folders
gmail label list
gmail label create MyLabel
gmail styles list
gmail styles show professional-formal
gmail styles create my-style
gmail styles validate my-style
gmail styles validate-all --fix
Email Styles
gmaillm supports a flexible email style system that allows you to define different writing styles for various contexts. Each style includes templates, formatting guidelines, and usage patterns.
Style Commands
gmail styles list
gmail styles show professional-formal
gmail styles create my-new-style
gmail styles edit casual-friend
gmail styles delete old-style
gmail styles delete old-style --force
gmail styles validate my-style
gmail styles validate my-style --fix
gmail styles validate-all
gmail styles validate-all --fix
Style Format
Each style file uses YAML frontmatter and XML-like sections:
---
name: "Style Name"
description: "When to use: Context description with usage guidance."
---
<examples>
Example email 1
---
Example email 2
</examples>
<greeting>
- "Hi [Name],"
- "Hello [Name],"
</greeting>
<body>
- Writing guideline 1
- Writing guideline 2
</body>
<closing>
- "Best,"
- "Thanks,"
</closing>
<do>
- What to do
- Best practices
</do>
<dont>
- What to avoid
- Common mistakes
</dont>
Required sections (in strict order):
examples - Example emails showing the style in action
greeting - Greeting patterns and guidelines
body - Body content guidelines
closing - Closing patterns
do - Best practices
dont - Things to avoid
See STYLES.md for complete style guide documentation.
Workflows
Interactive Workflows
Process emails interactively with prompts for each action:
gmail workflows run clear
gmail workflows run --query "is:unread from:boss@example.com"
LLM-Friendly Workflows (Programmatic)
Process emails programmatically with continuation tokens for automation:
gmail workflows start clear
gmail workflows continue <token> archive
gmail workflows continue <token> skip
gmail workflows continue <token> reply --reply-body "Thanks!"
gmail workflows continue <token> view
gmail workflows continue <token> quit
JSON Response:
{
"success": true,
"token": "abc123...",
"email": { },
"message": "Archived",
"progress": {"total": 10, "processed": 3, "remaining": 7, "current": 4},
"completed": false
}
Automation Example:
TOKEN=$(gmail workflows start clear | jq -r '.token')
while [ "$TOKEN" != "null" ]; do
RESULT=$(gmail workflows continue "$TOKEN" archive)
TOKEN=$(echo "$RESULT" | jq -r '.token')
done
Workflow Management
gmail workflows list
gmail workflows show clear
gmail workflows create daily \
--query "is:unread" \
--auto-mark-read
gmail workflows cleanup
Python Library
from gmaillm import GmailClient
client = GmailClient()
result = client.list_emails(folder='INBOX', max_results=10)
print(result.to_markdown())
email = client.read_email(message_id, format="summary")
print(email.to_markdown())
Tips & Tricks
Speed Up Typing with Completions
Once you've installed shell completions (gmail --install-completion), you can:
- Type
gmail l and press <TAB> → expands to available commands
- Type
gmail send --to user and press <TAB> → shows field completions
- Type
gmail and press <TAB> → shows all available commands
Quick Command Reference
gmail verify
gmail status
gmail list
gmail search "from:someone@example.com"
gmail send --to user@example.com \
--subject "Hello" --body "Hi there"
Help for Any Command
gmail send --help
gmail search --help
Documentation
User Guides
Technical Documentation
Testing
make test
uv run pytest tests/