Gmail MCP Server

Gmail MCP Server

Enables AI assistants to read unread Gmail messages and compose draft replies while maintaining thread continuity. It includes optional Notion integration to fetch and apply specific style guides for consistent professional communication.

Category
访问服务器

README

Gmail MCP Server

An MCP (Model Context Protocol) server that allows AI assistants to read unread emails from a Gmail account.

Features

  • OAuth 2.0 Authentication: Secure access to Gmail with user consent
  • Read Unread Emails: Fetch unread emails with sender, subject, snippet, and thread information
  • Create Draft Replies: Compose draft responses to emails while maintaining thread continuity
  • Style Guide Integration: Pull email writing guidelines from Notion to ensure consistent, professional communication

Quick Start

# 1. Install dependencies
pnpm install

# 2. Build the server
pnpm build

# 3. Set up OAuth - follow the prompts (once)
pnpm setup:gmail

# 4. Get your MCP configuration (once)
./get-config.sh

# 5. (Optional) Set up Notion integration for style guides
# Add to .env.local:
# NOTION_API_KEY=your_notion_api_key
# NOTION_STYLE_GUIDE_PAGE_ID=your_page_id

# 6. Run the MCP server
pnpm start

Then add the configuration to Claude Desktop and restart the app!

MCP Configuration

Run ./get-config.sh to get your configuration, then add it to your Claude Desktop config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Configuration format:

{
  "mcpServers": {
    "gmail": {
      "command": "node",
      "args": [
        "/absolute/path/to/foundation-project-mcp/dist/emailServer.js"
      ]
    }
  }
}

Available Tools

get_unread_emails

Retrieves unread emails from the Gmail inbox.

Parameters:

  • maxResults (optional): Maximum number of emails to retrieve (default: 10, max: 50)

Example prompts: "Show me my unread emails" • "What unread emails do I have?" • "Get my recent unread messages"

create_draft_reply

Creates a draft reply to an email in a thread.

Parameters:

  • messageId (required): The messageId of the original email
  • threadId (required): The threadId of the original email
  • sender (required): The sender of the original email
  • subject (required): The subject of the original email
  • replyBody (required): The draft reply content

get_style_guide

Retrieves the email writing style guide from Notion (if configured).

Parameters: None

Returns: Email writing guidelines and best practices from your Notion page

Example prompts

  • "Show me my unread emails"
  • "What unread emails do I have?"
  • "Get my recent unread messages"
  • "Get the email style guide and then draft a response to my latest unread email"
  • "Create a draft reply to this email saying..."
  • "Draft a response to the email from [sender]"
  • "Draft a response to important unread emails following our style guide"

Scroll down for screenshots of some of these prompts in action.

Notion Setup (Optional)

To enable the style guide feature:

  1. Create a Notion Integration:

    • Go to https://www.notion.so/my-integrations
    • Click "New integration"
    • Give it a name (e.g., "Gmail MCP Server")
    • Copy the "Internal Integration Token"
  2. Create a Style Guide Page:

    • Create a new page in Notion with your email writing guidelines
    • Click "Share" and invite your integration
    • Copy the page ID from the URL (the part after the page name and before the ?)
      • Example: https://notion.so/Email-Style-Guide-abc123def456 → Page ID is abc123def456
  3. Update .env.local:

    NOTION_API_KEY=secret_abc123...
    NOTION_STYLE_GUIDE_PAGE_ID=abc123def456
    
  4. Rebuild and restart:

    pnpm build
    # Restart Claude Desktop
    

Security Notes

  • Never commit .env.local (contains sensitive credentials)
  • Uses gmail.readonly and gmail.compose OAuth scopes
  • Access tokens auto-refresh when expired
  • Email headers are sanitised to prevent injection attacks
  • Notion integration token should be kept secure and never shared

Troubleshooting

  • Invalid credentials / Token errors: Re-run pnpm setup:gmail
  • No emails returned: Check you have unread emails and Gmail API is enabled in Google Cloud Console

Demo

<details> <summary>"Show me my unread emails"</summary>

<img width="791" height="630" alt="Screenshot 2025-12-07 at 16 19 49" src="https://github.com/user-attachments/assets/f8d507f8-6582-41ab-8881-44e1cfcfa161" /> <img width="759" height="662" alt="Screenshot 2025-12-07 at 16 23 11" src="https://github.com/user-attachments/assets/c21d9e6b-9984-44c0-8575-16aec1fbff01" /> <img width="762" height="409" alt="Screenshot 2025-12-07 at 16 23 23" src="https://github.com/user-attachments/assets/138ede87-5358-4303-89e8-3e5325679771" />

</details>

<details> <summary>"Draft replies to my unread emails"</summary>

<img width="763" height="620" alt="Screenshot 2025-12-07 at 16 34 49" src="https://github.com/user-attachments/assets/b8803487-de21-42c8-b89a-49167d50e0fc" /> <img width="765" height="570" alt="Screenshot 2025-12-07 at 16 35 03" src="https://github.com/user-attachments/assets/050c3bf7-a298-45f1-9978-94499c13a1e1" /> <img width="749" height="204" alt="Screenshot 2025-12-07 at 16 35 12" src="https://github.com/user-attachments/assets/19f2b496-99d3-413d-bec1-ea3068a961e9" />

</details>

<details> <summary>"Did i receive any good newsletters today?"</summary>

<img width="775" height="764" alt="Screenshot 2025-12-07 at 16 38 46" src="https://github.com/user-attachments/assets/6e09662d-fd13-46a6-a380-acade13e5af3" />

</details>

<details> <summary>Gmail and Notion screenshots</summary>

<img width="963" height="307" alt="Screenshot 2025-12-07 at 16 51 41" src="https://github.com/user-attachments/assets/3e9942a3-b8c8-4042-aff1-14688524bbe5" /> <img width="674" height="271" alt="Screenshot 2025-12-07 at 16 51 52" src="https://github.com/user-attachments/assets/8d25943f-ce1d-44d2-94de-810b17c51e80" /> <img width="927" height="461" alt="Screenshot 2025-12-07 at 16 52 20" src="https://github.com/user-attachments/assets/07309756-e950-4166-b0d1-26a6759b5754" />

</details>

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选