Gmail MCP Safe Bridge
Provides an MCP bridge to Google's hosted Gmail MCP server, enabling agents to search and read Gmail threads and messages, manage labels and filters, and create or update drafts. Safe mode blocks outbound and destructive tools such as send, reply, forward, trash, spam marking, and sensitive-label actions; full mode exposes all 30 official Gmail MCP tools.
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.
gmail-mcp-safe-bridge
Zero-dependency Node.js stdio bridge to Google's official hosted Gmail MCP server (https://gmailmcp.googleapis.com/mcp/v1, MCP 2025-03-26), with PKCE OAuth2 and a default --mode=safe guardrail.
Why This Exists
Google's hosted Gmail MCP server speaks Streamable HTTP and requires OAuth2 bearer tokens. Most local coding agents (Claude Code, Codex CLI, Gemini / Antigravity) prefer local stdio MCP servers, and giving an agent direct access to send_message, reply, forward, or trash_thread is risky.
This single-file Node.js bridge:
Uses zero npm dependencies (Node.js 18+ built-ins only).
Handles PKCE (
S256) OAuth2 login via an ephemeral127.0.0.1loopback callback and automatic token refresh.Locks credentials to the current user (
0700/0600on POSIX; user-onlyicaclson Windows).Runs in
--mode=safeby default, enforcing safety at both the OAuth scope layer and the MCP tool layer.
Related MCP server: mcp-gmail-oauth
Safety Modes
Mode | OAuth Scopes | Exposed Tools | Blocked Tools |
|
| 19 read, search, label, filter, and draft tools ( | 11 outbound/destructive tools ( |
|
| All 30 official Google Gmail MCP tools | None |
In --mode=safe, blocked tools are stripped from tools/list and hard-blocked in tools/call before any network request is sent. Agents can still draft replies with create_draft / update_draft for you to review and send manually.
Quick Start (~2 Minutes)
1. Create a Google Cloud OAuth Desktop Client
Create or select a Google Cloud project: https://console.cloud.google.com/projectcreate
Enable both APIs on that project:
Gmail API (
gmail.googleapis.com): https://console.cloud.google.com/apis/library/gmail.googleapis.comGmail MCP API (
gmailmcp.googleapis.com): https://console.cloud.google.com/apis/library/gmailmcp.googleapis.com
Configure the OAuth Consent Screen: https://console.cloud.google.com/auth/overview
Audience: External (Testing mode) and add your Gmail address under Test users.
Create an OAuth Client ID: https://console.cloud.google.com/auth/clients/create
Application type: Desktop app
Check "Use this client for an AI-powered agent" (required by
gmailmcp.googleapis.com).Download the JSON file and save it as
~/.gmail-mcp/gcp-oauth.keys.json.
2. Authorize Once
node gmail-mcp-bridge.mjs auth
# Or for full mode:
# node gmail-mcp-bridge.mjs auth --mode=fullVerify config, token state, and upstream reachability:
node gmail-mcp-bridge.mjs statusNote: Personal
@gmail.comOAuth apps in Google Cloud "Testing" mode expire refresh tokens after 7 days. If you seeinvalid_grant, re-runnode gmail-mcp-bridge.mjs auth.
3. Wire Your MCP Clients
Use wire_clients.py (Python 3.11+, stdlib only) to atomically add the bridge to standard client configs with backups and key-preservation checks:
# Preview changes without modifying any files
python wire_clients.py --dry-run
# Wire ~/.gemini/config/mcp_config.json, ~/.claude.json, and ~/.codex/config.toml in --mode=safe
python wire_clients.py --mode=safe
# Wire additional custom JSON or TOML config files
python wire_clients.py --mode=safe --extra-json /path/to/mcp_config.json --extra-toml /path/to/config.tomlOr configure manually in any stdio MCP client:
{
"mcpServers": {
"gmail": {
"command": "node",
"args": ["/absolute/path/to/gmail-mcp-bridge.mjs", "--mode=safe"]
}
}
}Environment Variables
Variable | Default | Description |
|
| Default mode when |
|
| Directory for |
|
| Override path to Google Cloud OAuth client JSON. |
|
| Override path to stored OAuth tokens JSON. |
|
| Override |
|
| Override upstream Streamable HTTP MCP endpoint. |
Tests
# Hermetic E2E stdio suite (mock Streamable HTTP server: JSON + SSE, Mcp-Session-Id, all 11 safe-mode blocks)
npm test
# Also verify unauthenticated initialize + tools/list against live Google Gmail MCP
npm run test:liveSee FAILURE_MODES.md for the security and reliability design rationale.
License
MIT - see LICENSE.
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
Drive Google Antigravity from the Gemini app: remote MCP with OAuth 2.1 + PKCE.
Give AI agents their own email inboxes: list, read and send mail via scoped, revocable OAuth grants.
Your Gmail, Calendar, Drive, GitHub, Oura, wallet and confirmed profile facts in any MCP client.
Hosted email MCP for your own Gmail, Outlook.com, Microsoft 365, iCloud or IMAP inbox: read, search, draft, reply in thread, forward and file mail. It moves or flags up to 500 messages in one call, and a send leaves exactly one copy in Sent. A calendar is a separate connection, and connecting one adds diary and scheduling tools.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceLocal stdio MCP server that mirrors the public Gmail MCP server tool surface while calling the Gmail REST API directly, enabling email management tasks like creating drafts, searching threads, and managing labels.MIT
- AlicenseNot gradedqualityDmaintenanceA self-hostable Gmail MCP server that enables Gmail search/read, sending, replies, drafts, labels, and attachment downloads via MCP tools with OAuth authorization. Supports stdio and streamable HTTP transports.MIT
- AlicenseNot gradedqualityCmaintenanceEnables an MCP client to search, read, label, draft, and send Gmail messages for a single Google account over stdio using your own OAuth client.MIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients to search, read, send, reply, forward and draft mail, download and extract attachments, and manage labels, stars, archive and trash. It runs over stdio and talks straight to the Gmail API with the user's own OAuth credentials, so no third-party server sits in between.39 PyPI1MIT