gmail-mcp
Enables AI assistants to send, read, list, and reply to emails via the Gmail API.
README
gmail-mcp
A Model Context Protocol (MCP) server that exposes Gmail actions as tools, allowing AI assistants like Claude to send, read, list, and reply to emails on your behalf.
Tools
| Tool | Description |
|---|---|
send_email |
Send an email to a recipient |
list_emails |
List emails matching a Gmail search query |
read_email |
Read a specific email by message ID |
read_emails_from_sender |
Fetch recent emails from a specific sender |
reply_email |
Reply to an email, preserving thread headers |
forward_recent_replies_to_webhook |
Forward recent Gmail replies to a signed LeadBorg email webhook |
Requirements
- Python 3.13+
- A Google Cloud project with the Gmail API enabled
- OAuth 2.0 credentials (
google_creds.json)
Setup
1. Get Google OAuth credentials
- Go to the Google Cloud Console.
- Create a project (or select an existing one).
- Enable the Gmail API.
- Under APIs & Services > Credentials, create an OAuth 2.0 Client ID (Application type: Desktop app).
- Download the JSON file and save it as
google_creds.jsonin the project root.
2. Install dependencies
# Using uv (recommended)
uv sync
# Or pip
pip install -e .
3. Authenticate
Run the server once manually to trigger the OAuth browser flow:
python gmail_mcp.py
This creates a token.json file at ~/.config/gmail-mcp/token.json. Subsequent runs reuse and auto-refresh this token.
Running the server
The transport is controlled by the MCP_TRANSPORT environment variable (default: stdio).
stdio (default — for Claude Desktop / MCP clients)
python gmail_mcp.py
Streamable HTTP
MCP_TRANSPORT=streamable-http MCP_PORT=8001 python gmail_mcp.py
# or alias:
MCP_TRANSPORT=http python gmail_mcp.py
SSE
MCP_TRANSPORT=sse python gmail_mcp.py
Environment variables
| Variable | Default | Description |
|---|---|---|
MCP_TRANSPORT |
stdio |
Transport mode: stdio, sse, streamable-http (alias: http) |
MCP_HOST |
127.0.0.1 |
Host for HTTP/SSE transports |
MCP_PORT |
8001 |
Port for HTTP/SSE transports |
GOOGLE_CREDS_PATH |
~/.config/gmail-mcp/google_creds.json |
Path to OAuth client credentials file |
GOOGLE_TOKEN_PATH |
~/.config/gmail-mcp/token.json |
Path to cached OAuth token file |
Claude Desktop configuration
Add the following to your claude_desktop_config.json:
{
"mcpServers": {
"gmail": {
"command": "python",
"args": ["/absolute/path/to/gmail_mcp.py"]
}
}
}
Running tests
python -m pytest tests/
# or
python -m unittest discover tests/
Project structure
gmail-mcp/
├── gmail_mcp.py # MCP server and tool definitions
├── main.py # Alternate entry point (HTTP transport)
├── pyproject.toml
└── tests/
└── test_gmail_mcp.py
~/.config/gmail-mcp/
├── google_creds.json # OAuth client credentials (not committed)
└── token.json # Cached OAuth token (generated at runtime)
Permissions
The server requests two OAuth scopes:
https://www.googleapis.com/auth/gmail.readonly— read access to emailshttps://www.googleapis.com/auth/gmail.send— permission to send email
This does not grant access to delete messages permanently.
LeadBorg integration notes
When using this server from LeadBorg, configure the email MCP endpoint as:
http://localhost:8001/mcp/
Set the provider to gmail-mcp. LeadBorg will pass a signed reply_to alias to
send_email; Gmail-MCP writes it as the Reply-To header so inbound replies can
be correlated back to the lead.
For local reply ingestion, run the forward_recent_replies_to_webhook tool with
the LeadBorg webhook URL (/api/webhooks/email/mcp) and the same signing secret
configured as EMAIL_WEBHOOK_SIGNING_SECRET.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。