advanced-gmail-mcp

advanced-gmail-mcp

A Gmail MCP server for Claude Code that enables full email management across multiple Gmail accounts, including tools for listing, searching, reading, sending, and organizing emails with OAuth2 authentication.

Category
Visit Server

README

Gmail MCP Server

Advanced Gmail MCP

A Gmail MCP server for Claude Code that provides full email management across multiple Gmail accounts.

Features

  • 12 tools: list, search, read, thread, labels, send, draft, reply, archive, label, trash, batch modify
  • Multi-account support with simple aliases
  • OAuth2 authentication with interactive CLI flow
  • Token auto-refresh — re-authenticates transparently
  • Rate limit retry with exponential backoff
  • Claude Code commands included (/email and /checkemail) for structured inbox triage

Quick Start

1. Clone & Install

git clone https://github.com/coreyepstein/advanced-gmail-mcp.git
cd advanced-gmail-mcp
npm install

2. Google Cloud Setup

  1. Go to Google Cloud Console
  2. Create a new project (or select an existing one)
  3. Enable the Gmail API:
    • APIs & Services → Enable APIs → search "Gmail API" → Enable
  4. Configure the OAuth consent screen:
    • APIs & Services → OAuth consent screen
    • User type: External (or Internal if using Google Workspace)
    • Add your email address(es) as test users
    • Add scopes: gmail.readonly, gmail.modify, gmail.send, gmail.compose
  5. Create OAuth credentials:
    • APIs & Services → Credentials → Create Credentials → OAuth client ID
    • Application type: Desktop app
    • Download the JSON file
  6. Save the downloaded file as credentials.json in the project root

3. Configure Accounts

cp accounts.example.json accounts.json

Edit accounts.json with your Gmail accounts:

{
  "accounts": [
    { "email": "you@gmail.com", "alias": "personal" },
    { "email": "you@company.com", "alias": "work" }
  ],
  "default": "personal"
}

You can add as many accounts as you want. Each needs a unique alias.

4. Authenticate

# Authenticate all accounts (opens browser for each)
npm run auth

# Or authenticate a single account
npm run auth -- work

# Check auth status
npm run auth:check

The auth flow opens a browser window for each account. Tokens are saved to ./tokens/.

5. Add to Claude Code

Add to your MCP config (project .mcp.json or ~/.claude.json):

{
  "mcpServers": {
    "gmail": {
      "type": "stdio",
      "command": "npx",
      "args": ["tsx", "/absolute/path/to/gmail-mcp/src/server.ts"]
    }
  }
}

Important: Use the absolute path to src/server.ts.

6. (Optional) Add Commands

Copy the included Claude Code commands for structured email workflows:

# From your project root (where .claude/ lives)
mkdir -p .claude/commands
cp /path/to/gmail-mcp/.claude/commands/email.md .claude/commands/
cp /path/to/gmail-mcp/.claude/commands/checkemail.md .claude/commands/

Then use /email or /checkemail in Claude Code.

Tools

Tool Description
list_emails List inbox or label emails
search_emails Search with Gmail query syntax
read_email Read full email by ID
get_thread Get full thread with all messages
get_labels List all labels
send_email Send a new email
draft_email Create a draft
reply_email Reply with proper threading
archive_email Archive (remove INBOX label)
label_email Add/remove labels
trash_email Move to trash
batch_modify Batch archive/trash/label

All tools accept an optional account parameter (alias or email). Defaults to the account set in accounts.json.

Commands

/email [action] [account]

Full email management command with actions:

  • triage — Summarize inbox, batch archive/trash
  • cleanup — 4-phase daily email workflow
  • search {query} — Cross-account search
  • send / draft / reply — Compose with confirmation

/checkemail [account]

Quick 3-phase inbox sweep:

  1. Fetch & classify all inbox emails (auto-archive junk)
  2. Batch archive on approval
  3. Walk through remaining emails one at a time

Troubleshooting

Error Fix
accounts.json not found Copy accounts.example.json to accounts.json
credentials.json not found Download OAuth credentials from GCP Console
No token for... Run npm run auth -- <alias>
Token refresh failed Re-authenticate: npm run auth -- <alias>
403 Forbidden Add your email as test user in GCP OAuth consent screen
403 insufficient scopes Re-authenticate to get updated scopes

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured