Local-first Gmail labeling and archiving with Gmail API plus a local LLM served by LM Studio.
Email content stays on your machine and is sent only to your local LM Studio server. No external LLM API is required by this project.
This project is still in MVP shape.
- intended use: personal local automation
- current stability: usable, but still evolving
- non-goals for now: multi-account orchestration, team workflows, hosted deployment
- fetches Gmail messages with OAuth
- classifies them with a local LLM
- validates outputs against a managed label taxonomy
- can create and apply Gmail labels under
0-LGA/... - can archive eligible messages by removing the
INBOXlabel - writes a local decision log for auditability
- can analyze past classifications and suggest stable sender/domain rules
- supports account-scoped runtime data under
data/accounts/<account>/ - skips messages already marked with the managed
LLM/Reviewedlabel unless--reprocessis used
uv venv
uv sync
cp .env.example .envThe project targets Python 3.12+.
Verify the CLI:
uv run local-gmail-agent --helpRun the tests and coverage:
uv run pytest
make coveragemacOS: supported for the full workflow, including built-in automation vialaunchdLinux: core CLI should work, but built-in automation is not implemented yetWindows: not supported yet
In practice:
auth,classify,labels,accounts, andanalysisare intended to stay portableautomation enableand the current scheduler integration are macOS-specific today
- Put
credentials.jsonin the project root. - Start LM Studio and load a local model.
- Authenticate in read-only mode:
uv run local-gmail-agent auth- Run a safe dry-run classification:
uv run local-gmail-agent classify --limit 20 --dry-run- When you are ready to mutate Gmail:
uv run local-gmail-agent auth --modify
uv run local-gmail-agent labels sync
uv run local-gmail-agent classify --applyTo create an additional account profile first:
uv run local-gmail-agent accounts add "Work Gmail" --email you@company.com
uv run local-gmail-agent auth --account work-gmailTo create an automation job:
uv run local-gmail-agent automation add --name "Nightly Cleanup" --daily-at 01:30 --limit 100 --apply
uv run local-gmail-agent automation enable --id <uuid>To inspect repeated classification patterns and surface candidate rules:
uv run local-gmail-agent analysis suggestions --account default- defaults to dry-run
- never mutates Gmail unless
--applyis used - never deletes emails
- falls back to
LLM/To Reviewfor invalid or low-confidence classifications - never archives action labels configured as protected
src/local_gmail_agent/
tests/
data/
docs/