Gmail MCP Local Server

Gmail MCP Local Server

Provides Claude with Gmail capabilities including sending emails, managing drafts, and searching messages.

Category
访问服务器

README

Gmail MCP Local Server

A local MCP (Model Context Protocol) server that gives Claude the ability to send emails, manage drafts, and search Gmail — capabilities missing from Anthropic's built-in Gmail connector.


What is MCP and how does this work?

MCP is a protocol that lets Claude call real-world tools. When you register an MCP server, Claude Desktop launches it as a background subprocess and routes tool calls to it over stdin/stdout.

You talk to Claude
       │
       ▼
Claude decides which tool to use
       │
       ▼
MCP server executes the action
(send email, search messages, etc.)
       │
       ▼
Real world effect happens

You never run this script manually. Claude Desktop starts and stops it automatically.


Tools

Tool Description
gmail_send_email Compose and immediately send an email
gmail_send_draft Send an existing draft by its draft ID
gmail_create_draft Save a composed email as a draft without sending
gmail_list_drafts List saved drafts with subject and recipient info
gmail_search_messages Search messages using Gmail query syntax
gmail_read_message Read the full decoded body of a message

Setup

1. Install dependencies

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

2. Google Cloud setup

You need a credentials.json from Google Cloud Console. This is your app's identity card with Google.

  1. Go to console.cloud.google.com
  2. Create a project
  3. Go to APIs & Services → Library → enable Gmail API
  4. Go to APIs & Services → OAuth consent screen
    • Choose External → fill in app name and your email
    • Under Test users, add your Gmail address
  5. Go to APIs & Services → Credentials → Create Credentials → OAuth 2.0 Client ID
    • Application type: Desktop app
    • Download the JSON and save it as credentials.json in this folder

Copy .env.example to .env and fill in your values (these match what's inside credentials.json):

cp .env.example .env

3. Register with Claude Desktop

Open ~/Library/Application Support/Claude/claude_desktop_config.json and add:

{
  "mcpServers": {
    "gmail": {
      "command": "/FULL/PATH/TO/gmail_mcp/venv/bin/python3",
      "args": ["/FULL/PATH/TO/gmail_mcp/gmail_mcp.py"]
    }
  }
}

Restart Claude Desktop.


First-run OAuth (one time only)

The first time Claude uses a Gmail tool, a browser window will open asking you to sign in with Google and grant access. After you approve:

  • A token.json file is saved in this folder
  • All future runs reuse this token silently
  • The token auto-refreshes when it expires — no action needed

Why the test user step matters: Google blocks OAuth for apps in "Testing" mode unless your email is explicitly listed as a test user. That's the 403: access_denied error if skipped.


How Claude Desktop manages the server

Claude Desktop starts
       │
       │  spawns subprocess automatically
       ▼
gmail_mcp.py runs in background
       │
       │  reads token.json for auth
       ▼
Gmail API (Google's servers)
  • No manual start needed — Claude Desktop handles it
  • The server only runs while Claude Desktop is open
  • If you use a scheduler, it only fires while Claude Desktop is running on your machine

Security

  • token.json contains a live OAuth refresh token — full Gmail access. Keep it private.
  • credentials.json contains your app's client secret. Keep it private.
  • Neither file is committed to git (covered by .gitignore)
  • If your token is compromised, revoke it at myaccount.google.com/permissions and delete token.json to force re-auth

What else can you build with MCP?

MCP works with any API. Some ideas:

  • Google Calendar — create and read events
  • Notion — read/write pages and databases
  • Slack — send messages, read channels
  • GitHub — open issues, create PRs
  • Google Sheets — read/write spreadsheet data
  • SMS / WhatsApp — send messages via Twilio
  • Local filesystem — read/write files in specific folders
  • Databases — query SQLite or Postgres

The pattern is always the same: write a Python file with @mcp.tool() functions, register it in claude_desktop_config.json, and Claude can act in the real world through it.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选