CA

coreyepstein/advanced-gmail-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

7 stars 7 forks 质量 64 趋势 15MIT

Gmail MCP server for Claude Code — multi-account email management

概览

A Gmail MCP server for Claude Code that provides full email management across multiple Gmail accounts. - : list, search, read, thread, labels, send, draft, reply, archive, label, trash, batch modify - support with simple aliases - authentication with interactive CLI flow - — re-authenticates transparently - with exponential backoff - included (/email and /checkemail) for structured inbox triage 1. Go to Google Cloud Console 2. Create a new project (or select an existing one) 3. Enable the : - APIs & Services → Enable APIs → search "Gmail API" → Enable 4. Configure the : - 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 : - APIs & Services → Credentials → Create Credentials → OAuth client ID - Application type: - Download the JSON file 6. Save the downloaded file as credentials.

README

以下为原文 README 节选,完整内容请查看原文。

Gmail MCP Server

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": "[email protected]", "alias": "personal" },
    { "email": "[email protected]", "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 |

在 GitHub 查看完整 README

安装

npx tsx /absolute/path/to/gmail-mcp/src/server.ts
新手?先看 mcpskill.org 教程 →

配置

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