
gmail-mcp-server
io.github.neutral-Stage/gmail-mcp-server
Local Gmail MCP server with 22 tools to search, read, draft, send, label, and organize Gmail.
Documentation
๐ง Gmail MCP Server
Open-source, 100% local Gmail MCP server (22 tools) for AI agents โ search, read, draft, send, label, and organize Gmail via Claude Desktop, Claude Code, Cursor, Codex CLI, Windsurf, VS Code Copilot, and Gemini CLI.
Quick Start ยท Agent Skills ยท 22 Tools ยท 8 AI Clients ยท FAQ ยท Docs Site ยท llms.txt
โญ If you find this project useful, please star the repo on GitHub so other developers and AI builders can discover it! โญ
๐ฏ Companion AI Agent Skills (Free via skills.sh + Full Suite on Agensi.io)
Gmail MCP Server gives your AI agent 22 low-level Gmail tools for free.
Pair it with our open-standard SKILL.md skills for turnkey, guardrailed workflows across Claude Code, Cursor, Codex CLI, Windsurf, Copilot, and Gemini CLI:
# Install the FREE Gmail Privacy Shield & MCP Setup Doctor skill in 1 command (skills.sh)
npx skills add neutral-Stage/gmail-mcp-server
| Skill | Pricing | Install / Source | What It Adds |
|---|---|---|---|
| Gmail Privacy Shield & MCP Setup Doctor | Free ($0) | npx skills add neutral-Stage/gmail-mcp-server or Agensi.io | Read-only offline metadata PII & prompt-injection scanner (0โ100 risk score, blocks OTPs/bank/medical alerts) + 3-minute guided local gmail-mcp-server setup & OAuth diagnostics. Zero paid tool calls. |
| Gmail Command Center (5-Skill Pack) | Paid one-time | Agensi.io | 5 specialized skills (gmail-inbox-triage, gmail-sender-intel, gmail-verified-outreach, gmail-reply-copilot, gmail-setup-doctor) + 3 offline Python guardrail scripts + 9 live Agensi data tools (work-email waterfall, SMTP & catch-all verification, 80+ company datapoints, Apollo profiles, Google Maps & Trustpilot reviews โ zero extra API keys). |
| Email Guardrail MCP Actor | Pay-per-event ($0.01โ$0.02/call) | Apify Store (https://sar333--email-guardrail-mcp-actor.apify.actor/mcp) | Hosted zero-OAuth MCP server & Actor for Claude, Cursor, n8n, Make & Zapier: prompt-injection/PII screening, cold-email deliverability gating, CRM contact scoring, and combined inbound+reply workflow audits. |
Package the free Privacy Shield ZIP & sync
.well-known/skills/index.jsonlocally:npm run package:skillvalidates frontmatter, security hygiene, and Python unit tests, outputtingdist-skill/gmail-privacy-shield-free.zip.
โก Quick Start
# One-command interactive setup โ detects OS, configures your AI client, runs local OAuth
npx @sar333/gmail-mcp-server setup
The wizard will:
- Verify your Google Cloud Desktop OAuth
credentials.json - Configure Claude Desktop, Claude Code, Cursor, Windsurf, or print JSON for any MCP client
- Run the local OAuth2 consent flow (
~/.gmail-mcp/token.json) - Validate setup health via
npx @sar333/gmail-mcp-server doctor
โจ Why Choose gmail-mcp-server?
| Capability | Cloud Email Proxy SaaS | Generic Gmail Connectors | gmail-mcp-server |
|---|---|---|---|
| Privacy & OAuth storage | Third-party cloud server | Varies | 100% local (~/.gmail-mcp/token.json) |
| OAuth safety scope | Often full mailbox/admin | Read-only or broad | gmail.modify only (no permanent delete) |
| Agent-ready bulk actions | Manual rules | Single-message only | Dry-run advanced_filter + 1,000-msg batch_modify_emails |
| CRM & contact extraction | Paid add-on | Not included | Built-in extract_addresses & get_frequent_contacts |
| Client setup | Manual JSON paths | Manual | One-command npx @sar333/gmail-mcp-server setup + doctor |
| Live enrichment & verification | Separate API keys | None | Native pairing with Agensi.io Gmail Command Center |
๐ง Tools (22 Tools)
| Category | Tool | Description |
|---|---|---|
| Search (1) | search_emails | Search with full Gmail query syntax (from:, is:unread, subject:, newer_than:) + pagination |
| Read (2) | get_email | Full email content โ headers, plain-text/HTML body, attachment metadata |
get_thread | All messages in a conversation thread in chronological order | |
| Attachments (1) | get_attachment | Download base64-encoded attachment payload by message & attachment ID |
| Compose (4) | create_draft | Save a draft (optionally attached to a threadId as a draft reply) |
send_email | Compose and send a new plain-text or HTML email | |
reply_email | Reply or reply-all keeping In-Reply-To, References, and thread ID | |
forward_email | Forward an existing message with an optional prepended note | |
| Organize (7) | modify_email | Add/remove system or custom label IDs, mark read/unread, archive |
batch_modify_emails | Bulk modify up to 1,000 emails in a single API call | |
advanced_filter | Search + bulk action (markRead, archive, applyLabel, trash, etc.) with dryRun: true default | |
trash_email | Move an email to Trash (30-day recoverable) | |
untrash_email | Restore an email from Trash | |
batch_trash_emails | Move up to 1,000 emails to Trash | |
mark_spam | Mark one or more emails as spam | |
| Labels (3) | list_labels | List all system and user labels with IDs and unread counts |
create_label | Create new labels (supports / nesting like Triage/Urgent) | |
delete_label | Delete a user-created label | |
| Extract (2) | extract_addresses | Extract deduplicated email addresses & counts from search results |
format_emails | Filter, sort, and reformat fetched email objects into json, table, or summary | |
| Profile (2) | get_profile | Authenticated Gmail address, total messages, threads, and history ID |
get_frequent_contacts | Top 50 most-contacted addresses ranked from recent sent mail |
๐ Step-by-Step Google Cloud OAuth Setup (< 5 Minutes)
- Open Google Cloud Console โ Create a project (e.g.,
Gmail MCP). - Enable Gmail API (APIs & Services โ Library โ Gmail API โ Enable).
- Configure OAuth consent screen (External for personal Gmail, Internal for Google Workspace).
- Add Test Users (important): Under Test users (or Audience) โ + ADD USERS โ add your Gmail address โ Save.
- Go to Credentials โ + CREATE CREDENTIALS โ OAuth client ID โ Application type: Desktop app.
- Download the JSON file and store it privately at
~/.gmail-mcp/credentials.json(never inside a Git repo). - Run
GMAIL_CREDENTIALS_PATH="$HOME/.gmail-mcp/credentials.json" npx -y @sar333/gmail-mcp-server setup.
๐ฅ๏ธ Client Configuration (8 AI Clients)
Universal JSON Block (Claude Desktop, Cursor, Windsurf, Cline, VS Code MCP)
{
"mcpServers": {
"gmail": {
"command": "npx",
"args": ["-y", "@sar333/gmail-mcp-server"],
"env": {
"GMAIL_CREDENTIALS_PATH": "/ABSOLUTE/PATH/TO/credentials.json"
}
}
}
}
| AI Client | Config Path or CLI Command |
|---|---|
| Claude Desktop (macOS) | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Claude Desktop (Windows) | %APPDATA%\Claude\claude_desktop_config.json |
| Claude Desktop (Linux) | ~/.config/claude/claude_desktop_config.json |
| Claude Code (CLI) | claude mcp add gmail -e GMAIL_CREDENTIALS_PATH="$HOME/.gmail-mcp/credentials.json" -- npx -y @sar333/gmail-mcp-server |
| OpenAI Codex CLI | codex mcp add gmail --env GMAIL_CREDENTIALS_PATH="$HOME/.gmail-mcp/credentials.json" -- npx -y @sar333/gmail-mcp-server |
| Cursor | .cursor/mcp.json |
| Windsurf | ~/.codeium/windsurf/mcp_config.json |
| VS Code (GitHub Copilot) | .vscode/mcp.json (use "servers" key with "type": "stdio") |
| Gemini CLI | ~/.gemini/settings.json (mcpServers.gmail) |
| Cline / Zed | Client MCP settings JSON (mcpServers.gmail) |
๐ ๏ธ CLI Commands & Troubleshooting
npx @sar333/gmail-mcp-server setup # Interactive setup wizard
npx @sar333/gmail-mcp-server auth # Run local OAuth2 consent flow
npx @sar333/gmail-mcp-server serve # Start MCP server over stdio (default)
npx @sar333/gmail-mcp-server doctor # Diagnose Node, credentials, token, and SDK health
npx @sar333/gmail-mcp-server --help # Show CLI help
npx @sar333/gmail-mcp-server --version # Print version
- Run
npx @sar333/gmail-mcp-server doctorfirst for instant diagnostics. - Error 403
access_denied: Add your Gmail address under Test users in Google Cloud Console โ OAuth consent screen. - Missing
credentials.json: Always pass an absolute path viaenv.GMAIL_CREDENTIALS_PATH. invalid_grant/ expired token: Re-runnpx @sar333/gmail-mcp-server authto refresh~/.gmail-mcp/token.json.- Port 3000 busy: Temporarily stop any local app bound to port
3000while runningauth.
โ Frequently Asked Questions
How do I connect Gmail to Claude Desktop, Claude Code, Cursor, or Codex CLI?
Install Node.js 18+, download a Desktop OAuth credentials.json from Google Cloud Console with the Gmail API enabled (adding yourself as a Test User), and run npx @sar333/gmail-mcp-server setup.
Is gmail-mcp-server safe and private?
Yes. It executes 100% locally with zero third-party proxy servers or telemetry, stores auto-refreshing tokens in ~/.gmail-mcp/token.json, and restricts OAuth to gmail.modify (permanent deletion and admin APIs are never requested). See SECURITY.md.
What is the difference between gmail-mcp-server and the Agensi.io skills?
gmail-mcp-server is the free, MIT-licensed MCP server exposing 22 local Gmail API tools. Gmail Privacy Shield (Free) adds offline PII/prompt-injection screening + setup diagnostics at $0, while Gmail Command Center adds 5 full workflows (triage, Inbox-to-CRM, verified cold outreach, thread replies, setup doctor) with Agensi's live email finding, SMTP/catch-all verification, 80+ company datapoints, and Google/Trustpilot review tools โ zero extra API keys required. For hosted, zero-OAuth email security and deliverability guardrails over HTTP MCP or n8n/Make/Zapier, use our Email Guardrail MCP Actor on Apify Store.
๐ค Machine-Readable Discovery & Registry Files (For Bots, Agents & Directories)
This repository publishes standard discovery manifests so MCP registries, coding agents, and LLM search engines can index and configure gmail-mcp-server automatically:
server.jsonโ Official MCP Registry manifest (2025-12-11schema,io.github.neutral-Stage/gmail-mcp-server)smithery.yamlโ Smithery.ai stdio installation manifestglama.jsonโ Glama.ai MCP directory ownership manifestllms.txt&llms-full.txtโ Concise and complete LLM-readable documentation indexesdocs/.well-known/mcp.jsonโ Machine-readable 22-tool server discovery carddocs/.well-known/skills/index.jsonโ RFC 8615 Agent Skills discovery indexCITATION.cffโ Structured software citation metadataSECURITY.mdยทCHANGELOG.mdยทCONTRIBUTING.mdยทCODE_OF_CONDUCT.md
Glama MCP Server Listing
Visit the Glama.ai MCP Server listing for neutral-Stage/gmail-mcp-server to:
- browse all 22 Gmail tools and check the live server quality & security score
- test the server online before installing using MCP Inspector
๐ค Contributing & Development
git clone https://github.com/neutral-Stage/gmail-mcp-server.git
cd gmail-mcp-server
npm install
npm run build
npm run validate:discovery
npm run package:skill
๐ License
MIT โ use it however you want.
@sar333/gmail-mcp-servernpm install @sar333/gmail-mcp-server