Gmail MCP
Enables AI assistants to send, read, search, and manage Gmail emails, drafts, and labels via the Model Context Protocol.
README
Gmail MCP
<p align="center"> <img src="https://github.com/ykuchiki/gmail-mcp/blob/main/assets/gmail-mcp-logo.png" alt="Gmail MCP Logo" width="200"> </p>
<p align="center"> <a href="https://github.com/ykuchiki/gmail-mcp/LICENSE"> <img src="https://img.shields.io/github/license/ykuchiki/gmail-mcp" alt="License"> </a> <img src="https://img.shields.io/badge/python-3.11+-blue.svg" alt="Python Version"> <img src="https://img.shields.io/badge/MCP-compatible-brightgreen.svg" alt="MCP Compatible"> </p>
<p align="center"> <b>Gmail API for AI assistants using Model Context Protocol</b><br> <b><a href="#english">English</a> | <a href="#spanish">Español</a> | <a href="#japanese">日本語</a></b> </p>
<a id="english"></a>
📋 English Documentation
Pull requests to this repository are welcome.
📖 Table of Contents
<a id="overview"></a>
🔍 Overview
Gmail MCP is a server implementation that enables AI assistants to interact with Gmail through the MCP (Model Context Protocol). It provides tools for sending emails, managing drafts, reading emails, searching through your inbox, and managing Gmail labels.
<a id="features"></a>
✨ Features
- ✉️ Send emails and create drafts
- 📬 Read and search emails
- 🗑️ Delete emails
- 🏷️ Manage Gmail labels (create, update, delete)
- 🔐 OAuth2.0 authentication with Gmail API
<a id="Prerequisites"></a>
📋 Prerequisites
- Python 3.11 or higher
- Gmail account
- Google Cloud Platform project with Gmail API enabled
- uv - Python package installer
<a id="Setup"></a>
🚀 Setup
- Clone this repository
git clone https://github.com/ykuchiki/gmail-mcp.git
cd gmail-mcp
- Create and activate a virtual environment
uv init
- Install dependencies
uv pip install -r requirements.txt
-
Set up OAuth credentials
- Create a directory named credentials in the root of the project
- Create a project in Google Cloud Console
- Enable the Gmail API
- Create OAuth credentials
- Add the following URI to the Authorized redirect URIs:
http://localhost:8080/ - Download the credentials JSON file and save it as
credentials/client_secret_gmail_oauth.json
-
Add MCP server Please refer to your MCP client's official documentation for specific instructions. Make sure to adjust the path according to your environment.
{
"mcpServers": {
"gmail-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/to/your/gmail-mcp/src",
"run",
"main.py"
]
}
}
}
- Run the server
uv run main.py
<a id="Usage"></a>
💡 Usage
The server can be used with any MCP-compatible client. On first run, it will prompt you to authenticate with your Gmail account.
<a id="License"></a>
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
<a id="japanese"></a>
📋 日本語ドキュメント
本リポジトリはpullリクエスト大歓迎です。
📖 目次
<a id="概要"></a>
🔍 概要
Gmail MCPは、AIアシスタントがMCP(Model Context Protocol)を通じてGmailを使用できるようにするサーバー実装です。メールの送信、下書きの管理、メールの読み取り、受信トレイの検索、Gmailラベルの管理などのツールを提供します。
<a id="機能"></a>
✨ 機能
- ✉️ メールの送信と下書き作成
- 📬 メールの読み取りと検索
- 🗑️ メールの削除
- 🏷️ Gmailラベルの管理(作成、更新、削除)
- 🔐 Gmail APIとのOAuth2.0認証 - 📎 添付ファイル送信・下書き(複数可, ローカルファイルパス)
<a id="前提条件"></a>
📋 前提条件
- Python 3.11以上
- Gmailアカウント
- Gmail APIが有効化されたGoogle Cloud Platformプロジェクト
- uv - Pythonパッケージインストーラー
<a id="セットアップ"></a>
🚀 セットアップ
- リポジトリをクローン
git clone https://github.com/ykuchiki/gmail-mcp.git
cd gmail-mcp
- 仮想環境の作成と有効化
uv init
- 依存関係のインストール
uv pip install -r requirements.txt
-
OAuth認証情報の設定
- 最初にプロジェクトのルートディレクトリ直下にcredentialsディレクトリを作成
- Google Cloud Consoleでプロジェクトを作成
- Gmail APIを有効化
- OAuth認証情報を作成
- 認証済みのリダイレクトURIに以下を追加:
http://localhost:8080/ - 認証情報JSONファイルをダウンロードし、
credentials/client_secret_gmail_oauth.jsonとして保存
-
MCPサーバーを追加 追加方法はご使用のMCPクライアントの公式ドキュメントをご確認ください。 また、パスは環境に合わせて修正してください。
{
"mcpServers": {
"gmail-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/to/your/gmail-mcp/src",
"run",
"main.py"
]
}
}
}
- サーバーの実行
uv run main.py
<a id="使用方法"></a>
💡 使用方法
このサーバーは、MCP互換のクライアントと共に使用できます。初回実行時には、Gmailアカウントで認証するよう促されます。
添付ファイルを付けて送信 / 下書き作成
attachments 引数でローカルファイルのパスを指定します(複数可・絶対パス推奨)。
例: 送信
{
"to": ["someone@example.com"],
"subject": "レポート送付の件",
"body": "ご確認ください。",
"attachments": [
"/Users/you/Documents/report.pdf",
"/Users/you/Pictures/logo.png"
]
}
例: 下書き作成
{
"to": ["someone@example.com"],
"subject": "資料",
"body": "添付しています。",
"attachments": ["/absolute/path/to/file.txt"]
}
注意事項:
- 合計サイズは約24MBを上限とし、それを超える場合はエラーになります(Gmailの25MB制限に対する安全余裕)。
- MIMEタイプは自動推定します。判別できない場合は
application/octet-streamとして送信します。 - ファイルが存在しない/読み取り不可の場合はエラーになります。
<a id="ライセンス"></a>
📄 ライセンス
このプロジェクトはMITライセンスの下で提供されています - 詳細はLICENSEファイルをご覧ください。
<a id="spanish"></a>
📋 Documentación en Español
Las pull requests a este repositorio son bienvenidas.
📖 Tabla de Contenidos
<a id="Descripción General"></a>
🔍 Descripción General
Gmail MCP es una implementación de servidor que permite a los asistentes de IA interactuar con Gmail a través del MCP (Model Context Protocol). Proporciona herramientas para enviar correos electrónicos, gestionar borradores, leer correos, buscar en tu bandeja de entrada y administrar etiquetas de Gmail.
<a id="Características"></a>
✨ Características
- ✉️ Enviar correos y crear borradores
- 📬 Leer y buscar correos
- 🗑️ Eliminar correos
- 🏷️ Gestionar etiquetas de Gmail (crear, actualizar, eliminar)
- 🔐 Autenticación OAuth2.0 con la API de Gmail
<a id="Requisitos Previos"></a>
📋 Requisitos Previos
- Python 3.11 o superior
- Cuenta de Gmail
- Proyecto en Google Cloud Platform con la API de Gmail habilitada
- uv - Instalador de paquetes Python
<a id="Configuración"></a>
🚀 Configuración
- Clonar este repositorio
git clone https://github.com/ykuchiki/gmail-mcp.git
cd gmail-mcp
- Crear y activar un entorno virtual
uv init
- Instalar dependencias
uv pip install -r requirements.txt
-
Configurar credenciales OAuth
- Crear un directorio llamado credentials en la raíz del proyecto
- Crear un proyecto en Google Cloud Console
- Habilitar la API de Gmail
- Crear credenciales OAuth
- Agregar la siguiente URI a las URIs de redirección autorizadas:
http://localhost:8080/ - Descargar el archivo JSON de credenciales y guardarlo como
credentials/client_secret_gmail_oauth.json
-
Agregar servidor MCP Por favor, consulta la documentación oficial de tu cliente MCP para instrucciones específicas. Asegúrate de ajustar la ruta según tu entorno.
{
"mcpServers": {
"gmail-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/to/your/gmail-mcp/src",
"run",
"main.py"
]
}
}
}
- Ejecutar el servidor
uv run main.py
<a id="Uso"></a>
💡 Uso
El servidor puede ser utilizado con cualquier cliente compatible con MCP. En la primera ejecución, te pedirá que te autentiques con tu cuenta de Gmail.
<a id="Licencia"></a>
📄 Licencia
Este proyecto está licenciado bajo la Licencia MIT - consulta el archivo LICENSE para más detalles.
TODO
- [x] 基本機能実装
- [ ] search_emailsで送信メールIDは除外or違う方法で実装
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。