Quick Start
Install via Docker (recommended):
yaml# docker-compose.yml
services:
workspace-secretary:
image: ghcr.io/johnneerdael/gmail-secretary-map:latest
container_name: workspace-secretary
restart: always
ports:
- "8000:8000"
volumes:
- ./config:/app/config
environment:
- LOG_LEVEL=INFO
Important: Generate a unique bearer token for security:
bash# macOS/Linux
uuidgen
# Windows PowerShell
[guid]::NewGuid().ToString()
Add to your config.yaml:
yamlbearer_auth:
enabled: true
token: "your-generated-uuid-here"
Then start with: docker compose up -d
See Getting Started for complete installation instructions.
Why Gmail Secretary MCP?
Traditional email clients are built for humans. Gmail Secretary MCP is built for AI assistants.
- Instant reads: SQLite cache means sub-millisecond email queries
- Persistent connections: Engine maintains IMAP connection (no per-request reconnect)
- Token-efficient: Bulk email fetching with smart truncation (700 chars) for fast triage
- Context-rich: Full thread history, attachment content, and calendar context in one tool call
- Intelligence signals: VIP detection, urgency markers, question detectionβnot hardcoded decisions
- Agentic workflows: Compose specialized agents (Triage, Scheduler, Intelligence Clerk) using atomic tools
Example Workflows
Daily Briefing
"Give me my daily briefingβwhat emails need my attention today?"
The AI uses get_daily_briefing() to fetch:
- Today's calendar events
- Email candidates with 5 priority signals (VIP, urgent, questions, deadlines, meetings)
- Intelligent summary prioritizing your VIP senders and time-sensitive requests
Smart Scheduling
"I received a meeting invite from John for tomorrow at 2 PM. Check my calendar and if I'm free during working hours, draft an acceptance."
The AI:
- Checks calendar availability with
check_calendar() - Validates time is within your
working_hours - Uses
create_draft_reply() to prepare response - Shows you the draft for confirmation
Document Intelligence
"Find the invoice PDF sent by Accounting last week, read it, and tell me the total amount."
The AI:
- Searches with
search_emails(keyword='invoice', from='accounting') - Extracts PDF text with
get_attachment_content() - Parses and presents the total
What's New in v4.8.0
Database Layer Refactoring & Bug Fixes:
- ποΈ Shared Query Modules: All SQL queries extracted to
db/queries/ modules (56 functions total) - π ~1,070 Lines Removed: Eliminated duplicate SQL between engine and web layers
- π§ Bug Fixes:
- Calendar page no longer returns 500 error (missing
strftime filter) - Email sync works correctly (boolean type mismatch fixed)
- Embedding sync no longer errors (missing methods added)
- CSRF tokens now sent correctly with HTMX requests
See the Architecture Documentation for the new database layer structure.
What's New in v4.7.x
Critical Bug Fixes:
- π OAuth2 Token Persistence: Refreshed tokens now properly saved to disk (v4.7.2)
- π§ Embedding Dimensions: Fixed config path for embedding dimensions (v4.7.1)
- ποΈ Shared Database Layer: New
workspace_secretary/db/ module for unified access
What's New in v4.6.0
Calendar Caching & Offline-First Architecture:
- β‘ Instant Calendar Reads: 10x faster queries via intelligent caching
- π Offline-First Events: Create/edit/delete events without internet
- π Background Worker: Autonomous sync daemon with incremental updates
- π·οΈ Status Badges: Visual indicators for pending sync and conflicts
- βοΈ Calendar Selection: Choose which calendars to display in settings
What's New in v4.4.0
Web UI Configuration:
- π Config Documentation: Added web UI configuration options to
config.sample.yaml
What's New in v4.3.3
Phase 4 Dashboard:
- π Dashboard Stats: Email statistics overview (total, unread, today's count)
- β‘ Priority Queue: Priority email list with quick actions
- β¨οΈ Keyboard Shortcuts: j/k navigation, o to open, r to reply
What's New in v4.3.2
halfvec Support for High Dimensions:
- π§ Automatic Quantization: 16-bit
halfvec type for dimensions > 2000 - π§ HNSW Fix: Resolves "column cannot have more than 2000 dimensions" error
- π 50% Storage Savings: halfvec uses half the space with ~0.1% recall loss
What's New in v4.3.0
Gemini Embeddings & Provider Fallback:
- π§ Google Gemini Provider: Native
google-genai SDK with task_type optimization - π Automatic Fallback: Switch providers on rate limit (Cohere β Gemini or vice versa)
- π L2 Normalization: Auto-normalizes Gemini vectors for dimensions β 3072
- π Detailed Guides: Copy-paste configs with rate limits, sync time estimates, batch calculators
| Provider | Free Tier Sync (25k emails) | Paid Tier Sync |
|---|
| Gemini Free | ~25 days (1k RPD limit) | N/A |
| Gemini Tier 1 | N/A | ~17 minutes |
| Cohere Trial | Limited (1k calls/month) | Varies by plan |
See Embeddings Guide for configuration details.
What's New in v4.2.7
Gap Sync & Accurate Counters:
- π Set Difference Sync: Compares IMAP UIDs vs DB UIDs to find exactly what's missing
- π Real Progress: Counters reflect actual DB state, not estimates
- π§ Gap Recovery: Fixes sync when emails were synced from both ends leaving a gap
What's New in v4.2.6
Resumable Sync & Stability Fixes:
- π Resume on Restart: Sync picks up where it left off using stored
uidnext - π‘ IDLE Starts Immediately: Real-time email detection even during initial sync
- π‘οΈ Embeddings Stability: Filters invalid texts, prevents 400 errors from empty emails
- π Accurate Progress: Shows "Resuming (16000/26000 done, 10000 remaining)"
What's New in v4.2.5
Lockstep Sync+Embed Architecture β Fixes critical race conditions:
- π Lockstep Processing: Sync 50 emails β embed those 50 β repeat (no parallel race)
- π Oldest-First Sync: Now processes all emails from oldest to newest UID
- β‘ Event Loop Fixes: Pool init runs in executor, httpx client reused with semaphore
- π‘οΈ Race Condition Fixed: Embeddings can no longer exceed synced email count
What's New in v4.2.4
Parallel Sync & Smart Scheduling:
- β‘ Parallel Folder Sync: Up to 5 concurrent IMAP connections via connection pool
- π IDLE + Catch-up Strategy: Real-time INBOX push, 30-min periodic catch-up for other folders
- ποΈ Configurable:
MAX_SYNC_CONNECTIONS and SYNC_CATCHUP_INTERVAL env vars
What's New in v4.2.3
Fix for IDLE Blocking Issues:
- Threaded IDLE Operation:
- Moved
idle_start, idle_done, idle_check to a dedicated thread. - Prevents event loop blocking during IMAP IDLE.
- Event-loop Safe Communication:
- Uses
loop.call_soon_threadsafe() for updates.
- Updated Documentation:
- Added architecture section for threaded IDLE pattern.
What's New in v4.2.2
Bug Fixes & Documentation Overhaul:
- π§ Database Init Fix: Engine now properly initializes database connection pool
- π PostgreSQL Support: Docker image includes psycopg drivers out of the box
- π Sync Logging: INFO-level logs show sync progress ("Synced N emails from INBOX")
- π Docs Refresh: Simplified OAuth setup, added PostgreSQL guide, updated threading docs
What's New in v4.2.1
Authentication UX Improvements β Easier setup with better error messages:
- π Fixed OAuth Token Storage:
auth_setup now saves client_id and client_secret in token.json (fixes "Missing client_id or client_secret" error) - π Better Setup Instructions: Startup warning now shows both OAuth2 and App Password options
- π Hardcoded Config Paths: Removed user-configurable output paths to prevent misconfiguration
What's New in v4.2.0
Calendar API Passthrough β Simplified architecture with real-time calendar access:
- ποΈ Direct API Access: Calendar operations now go directly to Google Calendar API (no local caching)
- β‘ Real-Time Data: All calendar queries return live data, no sync staleness
- π§Ή Simplified Architecture: Removed calendar database tables and sync complexity
- π§ New Endpoints: Added 6 new calendar API endpoints for fine-grained control
New Calendar API Endpoints
| Endpoint | Purpose |
|---|
GET /api/calendar/list | List all user's calendars |
GET /api/calendar/{id} | Get calendar details |
GET /api/calendar/{id}/events/{event_id} | Get single event |
PATCH /api/calendar/{id}/events/{event_id} | Update event |
DELETE /api/calendar/{id}/events/{event_id} | Delete event |
POST /api/calendar/freebusy | Query free/busy for multiple calendars |
Removed
calendar_cache.py β Calendar caching layer removedgmail_client.py β Deprecated Gmail REST API client removedCalendarSync class β No longer needed without caching- Calendar database tables (calendars, events, attendees)
calendar_cache_path config option (ignored if present)
What's New in v4.1.0
CONDSTORE & IDLE Support β Efficient incremental sync with push notifications:
- β‘ CONDSTORE (RFC 7162): Skip sync when mailbox unchanged, fetch only changed flags via CHANGEDSINCE
- π¬ IMAP IDLE (RFC 2177): Push-based notifications for instant new mail detection
- π·οΈ Gmail Extensions: Native X-GM-MSGID, X-GM-THRID, X-GM-LABELS support
- π Attachment Metadata:
has_attachments and attachment_filenames stored in database - π Debounced Sync: Mutations trigger 2-second debounced sync to batch rapid changes
| Scenario | Before | After |
|---|
| Unchanged mailbox | Fetch all UIDs, compare | Skip entirely (HIGHESTMODSEQ) |
| Flag changes only | Re-fetch entire message | Fetch only changed flags |
| New mail detection | 5-minute poll interval | Instant via IDLE |
| Rapid mutations | Sync per mutation | Single batched sync |
What's New in v4.0.0
Complete Architecture Rewrite β Read/Write Split for reliability and consistency:
- π Engine Owns All Writes: Engine now uses
DatabaseInterface for all database mutations - π MCP is Read-Only: MCP reads directly from database, calls Engine API only for mutations
- ποΈ Unified Database: Both Engine and MCP use the same
DatabaseInterface abstraction - π
Integrated Calendar Sync: Calendar operations now use direct API passthrough (no local caching)
- π§ Auto Embeddings: Engine generates embeddings automatically after email sync (PostgreSQL)
- π Graceful Enrollment: Engine starts in "no account" mode, auto-connects when OAuth tokens appear
New Engine API Endpoints
| Endpoint | Purpose |
|---|
GET /api/calendar/events | List calendar events in time range |
GET /api/calendar/availability | Get free/busy information |
POST /api/email/setup-labels | Create Secretary label hierarchy |
POST /api/email/send | Send email via Gmail API |
POST /api/email/draft-reply | Create draft reply in Gmail |
See the Architecture Documentation for the complete technical overview.
What's New in v3.2.0
Standardized Docker Paths & OAuth Consolidation:
- π Config Path:
/app/config/config.yaml is now the default (Docker-first) - π Single OAuth Entry:
auth_setup.py handles all OAuth flows (browser_auth removed) - π
Calendar Scope: OAuth now includes Gmail + Calendar scopes by default
- π οΈ Token Output:
--token-output flag for Docker-friendly token management
What's New in v3.1.0
Single Container Architecture β Simplified deployment with supervisor-managed processes:
- π¦ One Container: Engine + MCP server run together via supervisord
- π Unix Socket IPC: Internal communication between processes
- β‘ Persistent IMAP: Engine maintains connection (no per-request reconnect)
- π Background Sync: Continuous incremental sync every 5 minutes
- π Better Docs: Added credentials.json example format
What's New in v3.0.0
Dual-Process Architecture β Complete separation of concerns for reliability:
- π Engine + MCP Split: Independent sync daemon + MCP server
- π
Calendar Sync: Full calendar synchronization with local SQLite cache
- π§ Semantic Search: Optional PostgreSQL + pgvector backend with embeddings
- β‘ Database Options: SQLite (default) or PostgreSQL with pgvector for AI features
- π« IMAP-Only: Removed deprecated API mode (
oauth_mode config removed)
Database Options
| Backend | When to Use | Features |
|---|
| SQLite (default) | Simple deployment, single user | FTS5 keyword search, WAL mode |
| PostgreSQL + pgvector | AI features needed | Semantic search, embeddings, similarity matching |
See the Architecture Documentation for technical details.
What's New in v2.2.0
RFC 5256 Threading Support β Full conversation threading with automatic backfill:
- π§΅ Server-Side Threading: Uses IMAP
THREAD command (RFC 5256) when available - π Automatic Backfill: Existing emails get thread headers populated on first sync
- π Thread Data Model:
in_reply_to, references, thread_root_uid stored in SQLite - β‘ Cache-First Threads:
get_email_thread queries local cache instead of IMAP
See the Threading Guide for details.
Previous Releases
v2.1.0 and earlier
v2.1.0
- π Comprehensive v2.0 documentation overhaul
- π§ Fixed sync direction (newest-first for immediate usability)
- π Cache update fixes for triage tools
v2.0.0 - Local-First Architecture
- β‘ SQLite Cache: Email queries hit local databaseβinstant response times
- π Background Sync: Continuous incremental sync keeps cache fresh
- πΎ Persistent Storage: Cache survives restarts
- π RFC-Compliant: Proper UIDVALIDITY/UIDNEXT tracking per RFC 3501/4549
v1.1.0
- Third-party OAuth Support (Thunderbird/GNOME credentials)
- SMTP with XOAUTH2
- Calendar independent of email backend
v0.2.0
- Timezone-aware scheduling
- Working hours constraints
- Intelligent email signals
- VIP sender detection
See Migration Guide for upgrading from earlier versions.
Built with β€οΈ for the AI-native future
Licensed under MIT β’ Β© 2024-present John Neerdael