Sync Gmail message metadata into EvolutionDB long-term memory.
Project description
evolutiondb-gmail-sync
Pull Gmail message metadata — subject, from, to, snippet, labels — into EvolutionDB long-term memory so an AI assistant can answer "did Ahmet ever reply to that procurement thread?" weeks later.
This package stays in metadata mode: the message body is not captured. The snippet Gmail provides (~150 characters) plus subject
- sender + recipient + date covers most recall use-cases without walking the multipart MIME tree.
Setup
The Gmail API does not accept simple bearer tokens — you need an OAuth client in your own Google Cloud project. Five-minute setup:
- https://console.cloud.google.com/apis/library/gmail.googleapis.com → Enable.
- APIs & Services → OAuth consent screen → External → fill in the app name + your email. Add yourself as a Test User.
- APIs & Services → Credentials → Create credentials → OAuth client ID → Application type Desktop app.
- Copy the generated Client ID and Client secret into your
.env(GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET).
The package only requests gmail.readonly — it cannot send mail,
mark messages, or modify labels.
Install
pip install evolutiondb-gmail-sync
# or, from this repo:
pip install -e client/gmail-sync
First-time auth
The first run opens a browser tab for Google's consent screen. The
package spins up a one-shot HTTP listener on a random 127.0.0.1
port, captures the redirect, exchanges the code for a refresh
token, and stores the result at $GMAIL_TOKEN_CACHE (default
~/.evosql/gmail_token.json, mode 0600).
evolutiondb-gmail-sync --auth
Subsequent runs are silent — the refresh token is used to mint fresh access tokens as needed.
Run
# One pass; pull the last 7 days. First-time bootstrap.
evolutiondb-gmail-sync --once --since 7d
# Daemon mode.
evolutiondb-gmail-sync --interval 900
# Skip promotions + social and only keep real correspondence.
evolutiondb-gmail-sync --once --since 30d \
--query "-category:promotions -category:social"
# Verify auth without writing.
evolutiondb-gmail-sync --once --dry-run
Each pass prints a one-line JSON summary:
{"ok": true, "messages": 42, "skipped": 8, "errors": 0}
What gets indexed
| Field | Source |
|---|---|
| subject | Subject header |
| from | From header |
| to / cc | To, Cc headers |
| snippet | Gmail's pre-computed ~150-char preview |
| labels | Resolved against users/me/labels |
| thread_id | Gmail thread id (for thread recall) |
| internal_date_ms | Server-side receipt time |
Records use the Gmail message id as key (gmail_msg_<id>), so
re-sync UPSERTS.
What's not indexed
- Message bodies — keeps records small and avoids multipart
MIME parsing. If you need full text, set
format=fullinapi.GmailClient.get_message_metadataand add a body walker; Gmail returns base64url-encoded payloads. - Attachments — same reasoning. The header line says "see attached file foo.pdf"; that signal is in the snippet already.
Rate limits
Gmail's per-user quota is 250 quota units/second; metadata fetches
cost 5 units each. A 1,000-email backfill takes ~20s of wall time.
The client retries once on 429 with Retry-After.
Privacy
Everything you read with this token lands in EvolutionDB and
becomes searchable by anyone with the matching MCP_USER_ID. Use a
dedicated Google account for noisy mailing lists or
work-confidential mail rather than pointing this at your primary
inbox.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file evolutiondb_gmail_sync-0.1.0.tar.gz.
File metadata
- Download URL: evolutiondb_gmail_sync-0.1.0.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad37598456988ab58838465bdc497520a7360a607f075c3df3f33470ad7d19f3
|
|
| MD5 |
70a9175ed1dbeba0838f4f98eea462b1
|
|
| BLAKE2b-256 |
26343dfe7c1297aacb99db4e6b6b87a66e01f8b3dcf34ec345a774d493c54f79
|
Provenance
The following attestation bundles were made for evolutiondb_gmail_sync-0.1.0.tar.gz:
Publisher:
gmail-sync-release.yml on alptekin/evolutiondb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
evolutiondb_gmail_sync-0.1.0.tar.gz -
Subject digest:
ad37598456988ab58838465bdc497520a7360a607f075c3df3f33470ad7d19f3 - Sigstore transparency entry: 1526511016
- Sigstore integration time:
-
Permalink:
alptekin/evolutiondb@ecead590d3a542df71f401d9b77286621e784459 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/alptekin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
gmail-sync-release.yml@ecead590d3a542df71f401d9b77286621e784459 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file evolutiondb_gmail_sync-0.1.0-py3-none-any.whl.
File metadata
- Download URL: evolutiondb_gmail_sync-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d11ed4fe10d563b31ebf17ad62f4d0332195d37ecf9871af2c5005963a5b195
|
|
| MD5 |
268ed7fab17cd6a8a2194a1002c1b65d
|
|
| BLAKE2b-256 |
24eb30e9eb012e26585af0f72a750d836692cef7fdff799949c50bf60160c5db
|
Provenance
The following attestation bundles were made for evolutiondb_gmail_sync-0.1.0-py3-none-any.whl:
Publisher:
gmail-sync-release.yml on alptekin/evolutiondb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
evolutiondb_gmail_sync-0.1.0-py3-none-any.whl -
Subject digest:
9d11ed4fe10d563b31ebf17ad62f4d0332195d37ecf9871af2c5005963a5b195 - Sigstore transparency entry: 1526511106
- Sigstore integration time:
-
Permalink:
alptekin/evolutiondb@ecead590d3a542df71f401d9b77286621e784459 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/alptekin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
gmail-sync-release.yml@ecead590d3a542df71f401d9b77286621e784459 -
Trigger Event:
workflow_dispatch
-
Statement type: