REST API wrappers for Google services, designed for Seren Publisher integration.
| Service | Port | Google API | Publisher Slug |
|---|---|---|---|
| Gmail | 8001 | https://gmail.googleapis.com/gmail/v1 |
gmail |
| Calendar | 8002 | https://www.googleapis.com/calendar/v3 |
google-calendar |
User/Agent → Seren Gateway → Publisher → This Service → Google API
│ │
└── Token Exchange ─────────┘
(Seren API key → Google access token)
- First-time authorization: User visits
/auth/googleto authorize Google access - Token storage: Refresh token stored (keyed by Seren user)
- API calls: Seren Gateway exchanges API key for Google access token via
/token/exchange - Token refresh: Access tokens refreshed automatically when expired
| Method | Endpoint | Description |
|---|---|---|
| GET | /auth/google |
Initiate Google OAuth flow |
| GET | /auth/google/callback |
OAuth callback, stores refresh token |
| POST | /token/exchange |
Exchange Seren API key for Google access token |
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Health check |
| GET | /messages |
List messages (query params: q, maxResults, pageToken) |
| GET | /messages/{id} |
Get message by ID |
| POST | /messages/send |
Send email |
| DELETE | /messages/{id} |
Delete message |
| POST | /messages/{id}/trash |
Move to trash |
| POST | /messages/{id}/modify |
Add/remove labels |
| GET | /labels |
List labels |
| GET | /threads |
List threads |
| GET | /threads/{id} |
Get thread with messages |
| GET | /drafts |
List drafts |
| POST | /drafts |
Create draft |
| Method | Endpoint | Description |
|---|---|---|
| GET | /health |
Health check |
| GET | /calendars |
List calendars |
| GET | /calendars/{id} |
Get calendar |
| GET | /events |
List events (query params: timeMin, timeMax, q) |
| GET | /events/{id} |
Get event |
| POST | /events |
Create event |
| PUT | /events/{id} |
Update event |
| PATCH | /events/{id} |
Partial update event |
| DELETE | /events/{id} |
Delete event |
| POST | /quickAdd |
Create event from natural language |
| POST | /freebusy |
Query free/busy times |
| GET | /colors |
Get calendar colors |
# Install dependencies
cd gmail && pip install -r requirements.txt
cd calendar && pip install -r requirements.txt
# Run services
cd gmail && uvicorn main:app --port 8001 --reload
cd calendar && uvicorn main:app --port 8002 --reload# Build and run both services
docker-compose up --build
# Or individually
docker build -t seren-gmail ./gmail
docker build -t seren-calendar ./calendar# Required for OAuth flow
GOOGLE_CLIENT_ID=your-client-id
GOOGLE_CLIENT_SECRET=your-client-secret
GOOGLE_REDIRECT_URI=https://google-api.serendb.com/auth/google/callback
# Database for token storage
DATABASE_URL=postgresql://user:pass@host:5432/db
# Encryption key for refresh tokens
TOKEN_ENCRYPTION_KEY=your-32-byte-key
# Optional - for local testing
GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.jsonDeploy to Google Cloud Run:
# Gmail service
gcloud run deploy seren-gmail \
--source ./gmail \
--region us-central1 \
--allow-unauthenticated
# Calendar service
gcloud run deploy seren-calendar \
--source ./calendar \
--region us-central1 \
--allow-unauthenticated# Check publisher health
seren mcp call execute_paid_api --publisher gmail --method GET --path /health
# List messages (requires OAuth authorization first)
seren mcp call execute_paid_api --publisher gmail --method GET --path /messagesGmail:
https://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/gmail.sendhttps://www.googleapis.com/auth/gmail.modify
Calendar:
https://www.googleapis.com/auth/calendarhttps://www.googleapis.com/auth/calendar.events
- Seren Publishers:
gmail,google-calendar - Backend API: https://docs.serendb.com
MIT License - see LICENSE for details.