Fast Gmail integration for AI coding agents via the Fast Gateway Protocol (FGP).
- 10x faster than MCP-based Gmail tools (10-30ms vs 200-500ms)
- Multi-agent support: Works with Claude Code, Cursor, Windsurf
- One install:
fgp install gmailconfigures all your AI agents - OAuth2: Secure authentication with Google
fgp install gmailThis will:
- Install the Gmail daemon to
~/.fgp/services/gmail/ - Detect your installed AI agents
- Copy skill files to each agent's config directory
- Configure OAuth (first run prompts for authorization)
- Python 3.8+
- Google Cloud project with Gmail API enabled
- OAuth2 credentials (Desktop app type)
-
Get OAuth credentials:
- Go to Google Cloud Console
- Create a project and enable Gmail API
- Create OAuth 2.0 credentials (Desktop application)
- Download
credentials.json
-
Place credentials:
mkdir -p ~/.fgp/auth/google mv credentials.json ~/.fgp/auth/google/
-
Build and run:
cargo build --release ./target/release/fgp-gmail
-
Authorize (first run only):
- Browser opens for Google OAuth
- Grant permissions
- Token saved to
~/.fgp/auth/google/gmail_token.pickle
fgp call gmail.inbox -p '{"limit": 10}'fgp call gmail.unreadfgp call gmail.search -p '{"query": "from:newsletter", "limit": 5}'Gmail search syntax supported:
from:sender@example.comto:recipient@example.comsubject:keywordis:unreadafter:2025/01/01has:attachment
fgp call gmail.send -p '{"to": "user@example.com", "subject": "Hello", "body": "Message body"}'fgp call gmail.thread -p '{"thread_id": "abc123"}'All methods return JSON:
{
"emails": [
{
"id": "18abc123",
"thread_id": "18abc123",
"from": "sender@example.com",
"subject": "Meeting tomorrow",
"date": "Mon, 13 Jan 2026 10:00:00 -0800",
"snippet": "Just a reminder about our meeting..."
}
],
"count": 10
}| Metric | fgp-gmail | Traditional MCP |
|---|---|---|
| Cold start | ~50ms | ~300-500ms |
| Warm call | ~10-30ms | N/A (always cold) |
| Batch support | Yes | No |
┌─────────────────────────────────────┐
│ fgp-gmail (Rust daemon) │
│ • UNIX socket server │
│ • NDJSON protocol │
│ • Method routing │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ gmail-cli.py (Python) │
│ • Gmail API calls │
│ • OAuth2 token management │
│ • JSON response formatting │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ Gmail API (Google) │
└─────────────────────────────────────┘
cargo build --releasecargo testcargo run --releaseSymptom: Browser opens but authorization fails or redirects to error page.
Solutions:
- Ensure your Google Cloud project has Gmail API enabled
- Check that OAuth credentials are "Desktop application" type
- Verify
credentials.jsonis in~/.fgp/auth/google/ - Try deleting
~/.fgp/auth/google/gmail_token.pickleand re-authorizing
Symptom: Requests fail with "invalid_grant" or "Token has been expired or revoked"
Solution:
rm ~/.fgp/auth/google/gmail_token.pickle
fgp restart gmail
# Re-authorize when browser opensSymptom: fgp start gmail fails or daemon exits immediately
Check:
- Socket permissions:
ls -la ~/.fgp/services/gmail/ - Python available:
which python3 - Logs:
cat ~/.fgp/logs/gmail.log
Symptom: Requests fail with "Quota exceeded" or 429 status
Solutions:
- Gmail API has daily limits (~1B quota units/day for free)
- Reduce request frequency
- Use batch operations where possible
- Check quota at Google Cloud Console
Symptom: Queries return empty results when emails exist
Check:
- Search syntax is correct (Gmail search operators)
- Account has the expected emails
- Try simpler query first:
fgp call gmail.inbox
Symptom: "Connection refused" when calling daemon
Solution:
# Check if daemon is running
pgrep -f fgp-gmail
# Restart daemon
fgp stop gmail
fgp start gmail
# Check socket exists
ls ~/.fgp/services/gmail/daemon.sockMIT License - see LICENSE for details.