Repository avatar
AI Tools
v2.0.0
active

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 and Gmail Command Center AI Agent Skill Pack

๐Ÿ“ง 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.

npm version CI Status MIT License Node.js >= 18 Official MCP Registry Compatible Gmail Command Center on Agensi.io Install free Gmail Privacy Shield via npx skills add Email Guardrail MCP Actor on Apify Store Glama MCP Server Quality Score

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

Live demo of Gmail Privacy Shield blocking phishing/OTPs and Deliverability Gate scoring outreach drafts

SkillPricingInstall / SourceWhat It Adds
Gmail Privacy Shield & MCP Setup DoctorFree ($0)npx skills add neutral-Stage/gmail-mcp-server or Agensi.ioRead-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-timeAgensi.io5 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 ActorPay-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.json locally: npm run package:skill validates frontmatter, security hygiene, and Python unit tests, outputting dist-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:

  1. Verify your Google Cloud Desktop OAuth credentials.json
  2. Configure Claude Desktop, Claude Code, Cursor, Windsurf, or print JSON for any MCP client
  3. Run the local OAuth2 consent flow (~/.gmail-mcp/token.json)
  4. Validate setup health via npx @sar333/gmail-mcp-server doctor

โœจ Why Choose gmail-mcp-server?

CapabilityCloud Email Proxy SaaSGeneric Gmail Connectorsgmail-mcp-server
Privacy & OAuth storageThird-party cloud serverVaries100% local (~/.gmail-mcp/token.json)
OAuth safety scopeOften full mailbox/adminRead-only or broadgmail.modify only (no permanent delete)
Agent-ready bulk actionsManual rulesSingle-message onlyDry-run advanced_filter + 1,000-msg batch_modify_emails
CRM & contact extractionPaid add-onNot includedBuilt-in extract_addresses & get_frequent_contacts
Client setupManual JSON pathsManualOne-command npx @sar333/gmail-mcp-server setup + doctor
Live enrichment & verificationSeparate API keysNoneNative pairing with Agensi.io Gmail Command Center

๐Ÿ”ง Tools (22 Tools)

CategoryToolDescription
Search (1)search_emailsSearch with full Gmail query syntax (from:, is:unread, subject:, newer_than:) + pagination
Read (2)get_emailFull email content โ€” headers, plain-text/HTML body, attachment metadata
get_threadAll messages in a conversation thread in chronological order
Attachments (1)get_attachmentDownload base64-encoded attachment payload by message & attachment ID
Compose (4)create_draftSave a draft (optionally attached to a threadId as a draft reply)
send_emailCompose and send a new plain-text or HTML email
reply_emailReply or reply-all keeping In-Reply-To, References, and thread ID
forward_emailForward an existing message with an optional prepended note
Organize (7)modify_emailAdd/remove system or custom label IDs, mark read/unread, archive
batch_modify_emailsBulk modify up to 1,000 emails in a single API call
advanced_filterSearch + bulk action (markRead, archive, applyLabel, trash, etc.) with dryRun: true default
trash_emailMove an email to Trash (30-day recoverable)
untrash_emailRestore an email from Trash
batch_trash_emailsMove up to 1,000 emails to Trash
mark_spamMark one or more emails as spam
Labels (3)list_labelsList all system and user labels with IDs and unread counts
create_labelCreate new labels (supports / nesting like Triage/Urgent)
delete_labelDelete a user-created label
Extract (2)extract_addressesExtract deduplicated email addresses & counts from search results
format_emailsFilter, sort, and reformat fetched email objects into json, table, or summary
Profile (2)get_profileAuthenticated Gmail address, total messages, threads, and history ID
get_frequent_contactsTop 50 most-contacted addresses ranked from recent sent mail

๐Ÿš€ Step-by-Step Google Cloud OAuth Setup (< 5 Minutes)

  1. Open Google Cloud Console โ†’ Create a project (e.g., Gmail MCP).
  2. Enable Gmail API (APIs & Services โ†’ Library โ†’ Gmail API โ†’ Enable).
  3. Configure OAuth consent screen (External for personal Gmail, Internal for Google Workspace).
  4. Add Test Users (important): Under Test users (or Audience) โ†’ + ADD USERS โ†’ add your Gmail address โ†’ Save.
  5. Go to Credentials โ†’ + CREATE CREDENTIALS โ†’ OAuth client ID โ†’ Application type: Desktop app.
  6. Download the JSON file and store it privately at ~/.gmail-mcp/credentials.json (never inside a Git repo).
  7. 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 ClientConfig 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 CLIcodex 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 / ZedClient 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 doctor first 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 via env.GMAIL_CREDENTIALS_PATH.
  • invalid_grant / expired token: Re-run npx @sar333/gmail-mcp-server auth to refresh ~/.gmail-mcp/token.json.
  • Port 3000 busy: Temporarily stop any local app bound to port 3000 while running auth.

โ“ 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:

Glama MCP Server Listing

Gmail MCP Server on Glama

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.

NPM
@sar333/gmail-mcp-server
Install Command
npm install @sar333/gmail-mcp-server