Google MailPilot
Allows AI agents to read, search, triage, and draft emails with human-in-the-loop safety and Gmail-specific threading and labels.
Provides calendar access, event creation, editing, and deletion with offline-first operations and background sync.
Required for OAuth2 authentication and enabling the Google Calendar API integration.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Google MailPilot
The AI-native command center for Gmail and Google Workspace
Google MailPilot is the renamed successor to Gmail Secretary, built so LLMs can read, triage, respond to, and calendar-manage Gmail with a production-grade MCP control plane.
β οΈ Release Notice: v5.0.0 is the first public release under the Google MailPilot brand; it fixes MCP tool registration, tightens triage/compose coverage, adds new booking-link helpers, and keeps every mutation human-in-the-loop.
Release highlights:
Tools now register as soon as
workspace_secretary.toolsimports, preventing FastMCP registration bugs.Triage/compose tooling gained synchronous tests plus
tests/test_triage_priority_emails.pyandtests/test_web_compose.pyto cover CLI-aware workflows.Engine/web routes, booking links, and
raw:continuation-state handling now align with Google MailPilot expectations.
π¦ Stability Matrix
We believe in transparency. Here is the current readiness of our stack:
Component | Status | Stability Notes |
IMAP Sync Engine | π’ Stable | RFC-compliant, IDLE support, tested on >24k emails. |
Read Operations | π’ Stable | Search, Threading (X-GM-THRID), and Summarization work perfectly. |
Write Operations | π‘ Beta | Draft creation is stable. Auto-sending is currently disabled via the Safety Interceptor. |
Web Dashboard | π Alpha | Early preview. UI may change rapidly. |
A Google MailPilot IMAP/SMTP control plane for AI agents with calendar integration
Built for LLMs that need to read, search, triage, and respond to email autonomously. Not just an MCP wrapper β a full-featured IMAP control plane engineered for AI orchestration workflows.
π Documentation Β· ποΈ Architecture Β· β‘ Quick Start
Related MCP server: Gmail MCP Server
Why This Exists
Most email integrations for AI are thin API wrappers. They poll. They re-fetch. They timeout. They don't understand email threading, modification sequences, or push notifications.
Google MailPilot is different. It's a production-grade IMAP control plane that:
Syncs intelligently β CONDSTORE tracks what changed, IDLE pushes new mail instantly
Caches locally β SQLite or PostgreSQL, your AI reads from local DB in milliseconds
Understands Gmail β Native X-GM-THRID threading, X-GM-LABELS, X-GM-RAW search
Never sends without approval β Human-in-the-loop by design, drafts first
π‘ RFC Compliance
We implement these IMAP extensions for efficient, real-time email sync:
RFC | Extension | What It Does | Benefit |
IMAP4rev1 | Core protocol | Full IMAP compliance | |
CONDSTORE | Tracks modification sequences | Skip sync when mailbox unchanged | |
CHANGEDSINCE | Fetch only changed flags | 10x faster incremental sync | |
IDLE | Push notifications | Instant new mail detection | |
ID | Client identification | Better server compatibility |
Gmail-Specific Extensions
Extension | Purpose |
| Native Gmail thread ID β no heuristic threading needed |
| Stable message identifier across folders |
| Full Gmail label support (stored as JSONB) |
| Gmail's powerful search syntax for targeted sync |
β‘ Performance
Real benchmarks against a 50,000 email mailbox:
Operation | Traditional IMAP | Google MailPilot |
Check for new mail | 2-5s (fetch all UIDs) | < 50ms (HIGHESTMODSEQ compare) |
Sync flag changes | Re-fetch messages | Flags only (CHANGEDSINCE) |
New mail notification | 5-min poll interval | Instant (IDLE push) |
Search emails | Server roundtrip | < 10ms (local SQLite FTS5) |
Thread reconstruction | Parse References headers | Instant (X-GM-THRID) |
How CONDSTORE Works
Traditional Sync:
1. SELECT INBOX
2. FETCH 1:* (FLAGS) β Downloads ALL flags every time
3. Compare with cache
4. Fetch changed messages
CONDSTORE Sync:
1. SELECT INBOX
2. Compare HIGHESTMODSEQ β Single integer comparison
3. If unchanged β done β Skip everything
4. If changed β FETCH 1:* (FLAGS) CHANGEDSINCE <modseq>
β Only changed messagesποΈ Architecture
Dual-process design separating sync from AI interface:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Layer (Claude, etc.) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MCP Server (read-only) β
β β’ Exposes 25+ tools for email/calendar operations β
β β’ Reads directly from local database β
β β’ Mutations proxied to Engine API β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββ΄ββββββββββββββββββ
βΌ βΌ
ββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββ
β SQLite / PostgreSQL β β Secretary Engine β
β β’ Email cache (FTS5) ββββββββββ β’ IMAP sync (CONDSTORE) β
β β’ Gmail labels (JSONB) β β β’ IDLE monitor β
β β’ Embeddings (pgvector) β β β’ OAuth2 management β
ββββββββββββββββββββββββββββ β β’ SMTP send/draft β
ββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββ
β Gmail IMAP β
β Gmail SMTP β
β Calendar API β
ββββββββββββββββββββWhy Two Processes?
Concern | Engine | MCP Server |
Sync | Owns IMAP connection, IDLE loop | Never touches IMAP |
Database | All writes | Read-only |
Uptime | Always running | Scales with AI requests |
Credentials | Holds OAuth tokens | Stateless |
π― AI-Native Features
Calendar Integration:
β‘ Instant Calendar Access: Sub-50ms queries via intelligent caching layer
π Offline-First Operations: Create/edit/delete events without internet, sync transparently
π Background Sync Worker: Autonomous daemon syncs every 60s using Google Calendar API sync tokens
π·οΈ Status Indicators: Visual badges show pending/synced/conflict states for offline operations
βοΈ Multi-Calendar Support: Select which calendars to display via web UI settings
Email Intelligence:
Intelligent Signal Extraction
Every email is analyzed for actionable signals:
signals = {
"is_addressed_to_me": True, # In To: field, not just CC
"mentions_my_name": True, # Name appears in body
"has_question": True, # Contains "?" or question phrases
"mentions_deadline": True, # "EOD", "ASAP", "by Friday"
"mentions_meeting": True, # Scheduling keywords detected
"is_from_vip": True, # Sender in configured VIP list
"has_attachments": True, # PDF, DOCX, etc.
"attachment_filenames": ["Q4_Report.pdf"]
}Human-in-the-Loop Safety
The AI never sends email without explicit approval.
User: "Reply to Sarah saying I'll attend the meeting"
AI: I've drafted this reply:
To: sarah@company.com
Subject: Re: Team Meeting Tomorrow
Hi Sarah,
I'll be there. Looking forward to it!
Best regards
Send this email? (yes/no)
User: "yes"
AI: β Email sent successfullyConfidence-Based Batch Operations
Bulk operations require approval with confidence tiers:
Confidence | Batch Size | Display |
High (>90%) | Up to 100 | Date, From, Subject only |
Medium (50-90%) | Up to 10 | + First 300 chars of body |
Low (<50%) | Individual | Full context required |
π Quick Start
Prerequisites
Docker and Docker Compose
Gmail account with App Password (or OAuth2)
Google Cloud project (for Calendar integration)
1. Clone and Configure
git clone https://github.com/johnneerdael/google-mailpilot.git
cd google-mailpilot
cp config.sample.yaml config/config.yaml2. Edit Configuration
# config/config.yaml
imap:
host: imap.gmail.com
port: 993
username: your-email@gmail.com
password: your-app-password # Gmail App Password
user:
email: your-email@gmail.com
first_name: Your
last_name: Name
timezone: America/New_York
working_hours:
start: "09:00"
end: "18:00"
vip_senders:
- ceo@company.com
- important-client@example.com
database:
backend: sqlite # or "postgres" for embeddings
path: /app/config/secretary.db
bearer_auth:
enabled: true
token: "generate-with-uuidgen"3. Start Services
docker-compose up -d4. Connect Your AI
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"secretary": {
"url": "http://localhost:8000/mcp",
"headers": {
"Authorization": "Bearer your-token-here"
}
}
}
}π§ Available Tools
Email Operations
Tool | Description |
| FTS5-powered local search with Gmail query syntax |
| Full email content with signals and metadata |
| Complete thread via X-GM-THRID |
| AI-ready thread summary |
| Draft response (never auto-sends) |
| Send with explicit approval |
| Add/remove Gmail labels |
| Move between folders |
Calendar Operations
Tool | Description |
| Events in time range |
| Free/busy lookup |
| Create with timezone support |
| Find alternative meeting times |
Triage Operations
Tool | Description |
| Priority emails + today's calendar |
| Identify high-priority items |
| Batch cleanup with approval |
Semantic Search (PostgreSQL + pgvector)
Tool | Description |
| Search by meaning, not keywords |
| Similar emails to reference |
π Database Schema
Email Storage
CREATE TABLE emails (
uid INTEGER,
folder TEXT,
message_id TEXT UNIQUE,
gmail_thread_id BIGINT, -- X-GM-THRID
gmail_msgid BIGINT, -- X-GM-MSGID
gmail_labels JSONB, -- Full label set
subject TEXT,
from_addr TEXT,
to_addr TEXT,
date TIMESTAMPTZ,
internal_date TIMESTAMPTZ, -- INTERNALDATE
body_text TEXT,
body_html TEXT,
flags TEXT,
modseq BIGINT, -- CONDSTORE sequence
has_attachments BOOLEAN,
attachment_filenames JSONB,
-- FTS5 index on subject, from_addr, to_addr, body_text
);Folder State (CONDSTORE)
CREATE TABLE folder_state (
folder TEXT PRIMARY KEY,
uidvalidity INTEGER,
uidnext INTEGER,
highestmodseq BIGINT -- For CONDSTORE sync
);π Security
Layer | Protection |
Transport | TLS 1.2+ for IMAP/SMTP |
Authentication | OAuth2 or App Passwords (never plain passwords) |
API | Bearer token authentication |
Data | Local database, no cloud sync |
Actions | Human approval for all mutations |
Never Stored
Plain text passwords
OAuth refresh tokens in logs
Email content in error messages
π Documentation
Guide | Description |
Deep dive into dual-process design | |
All config options explained | |
HITL safety patterns | |
Complete tool documentation |
π οΈ Development
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run locally
python -m workspace_secretary.engine.api & # Start engine
python -m workspace_secretary.server # Start MCP serverLicense
MIT License β see LICENSE for details.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Policy-guarded Gmail for AI agents: search, read, draft and send under rules you set.
Email inboxes for AI agents: read, search, send, reply, calendar invites. Hosted MCP with OAuth.
Gmail, Outlook, Drive, OneDrive and calendars for AI agents. Many accounts, one endpoint, audit log.
Email infrastructure for AI agents β send, receive, search, and reply to email over MCP.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI agents to search, read, send, and organize Gmail emails via MCP protocol.222MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with Gmail through a standardized MCP server interface, allowing for natural language email management and automation.-
- FlicenseNot gradedqualityDmaintenanceProduction-ready MCP server for Gmail, enabling AI agents to search, read, send, draft, and manage emails, labels, and attachments via the Google Gmail API.-

agentinboxofficial
AlicenseNot gradedqualityBmaintenanceEnables AI agents to read, search, draft, send and organize Gmail through scoped credentials, guardrails and signed webhooks or an event feed, with real-time notifications of new mail.95 npm1MIT