Gmail MCP Server

by Samarth2001
MIT License
  • Apple
  • Linux

Integrations

  • Enables complete email management through Gmail, including sending emails with attachments, reading and searching emails, managing labels and organization, handling drafts, and performing batch operations on multiple emails.

  • Integrates with Google Cloud for authentication and API access, allowing the MCP server to securely connect to Gmail services through OAuth 2.0 credentials.

Gmail MCP サーバー

Claude AI が Gmail と直接やり取りできるようにする強力な Model Context Protocol (MCP) サーバー。

📖 目次

📋 概要

Gmail MCPサーバーは、ClaudeのようなAIアシスタントが自然言語でGmailと直接やり取りできるようにする包括的な実装です。メール管理のための豊富なツールセットを公開し、会話型AIと受信トレイのシームレスな統合を実現します。

💡主な機能

  • 完全なメール管理
    • 添付ファイル付きのプレーンテキストおよびHTMLメールを送信する
    • 複雑なメッセージ構造を適切に解析してメールを読む
    • Gmail の強力なクエリ構文で受信トレイを検索
    • 下書きメールの作成と更新
    • ラベル、既読/未読ステータス、ゴミ箱を管理する
    • 複数のメールに対して一括操作を実行する
  • 高度な統合
    • async/await パターンを使用した最新の Python コードベース
    • 包括的なエラー処理と回復
    • 詳細な進捗報告
    • 安全なOAuth認証フロー
    • 複数のトランスポートモード(STDIOおよびSSE)
    • さまざまな展開シナリオのサポート

🚀 クイックスタート

前提条件

  • Python 3.8以上
  • Gmail API が有効になっている Google Cloud プロジェクト
  • Gmail API の OAuth 2.0 認証情報

インストール

  1. リポジトリをクローンする
    git clone https://github.com/yourusername/gmail-mcp-server.git cd gmail-mcp-server
  2. 仮想環境をセットアップする
    python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
  3. 依存関係をインストールする
    pip install -r requirements.txt
  4. Google Cloud と OAuth 認証情報を設定するGoogle Cloud Consoleにアクセスして次の操作を行います。
    • 新しいプロジェクトを作成する
    • Gmail APIを有効にする
    • OAuth同意画面を設定する
    • OAuth クライアント ID 資格情報を作成する (デスクトップ アプリケーション)
    • 資格情報はプロジェクトルートのcredentials.jsonとしてダウンロードします。

初回実行と認証

認証するにはサーバーを 1 回実行します。

python gmail_server.py

ブラウザウィンドウが開き、Googleアカウントでの認証を求められます。認証後、 token.jsonファイルが作成され、今後使用するために保存されます。

Claudeデスクトップの設定

  1. Claude Desktop 構成ファイルを編集します。
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. Gmail MCP サーバーを構成に追加します。
    { "mcpServers": { "gmail": { "command": "python", "args": [ "/absolute/path/to/gmail-mcp-server/gmail_server.py" ] } } }
  3. ファイルを保存し、Claude Desktopを再起動します。

注: "/absolute/path/to/gmail-mcp-server/gmail_server.py"を、クローンしたリポジトリ内のgmail_server.pyファイルへの実際の絶対パスに置き換えます。

🧰 利用可能なツール

Gmail MCP サーバーは、Claude に次のツールを公開します。

メール送信

  • send_email - テキスト/HTMLコンテンツを含む基本的なメールを送信する
  • send_email_with_attachment - ファイルを添付したメールを送信する
  • send_email_with_multiple_attachments - 複数の添付ファイル付きのメールを送信する

メールの読み上げ

  • read_email - IDで特定のメールの内容を読む
  • get_unread_emails - 未読メールのリストを取得する
  • get_important_emails - 重要とマークされたメールを取得する
  • get_emails_with_attachments - 添付ファイルのあるメールを取得する
  • get_recent_emails - 過去X日間のメールを取得する

メールの検索と整理

  • search_emails - Gmail のクエリ構文を使用してメールを検索します
  • get_email_labels - Gmailのすべてのラベル/フォルダを一覧表示する
  • create_email_label - 新しいラベルを作成する
  • delete_email_label - 既存のラベルを削除する
  • label_email - メールにラベルを適用する
  • remove_email_label - メールからラベルを削除する

メールステータス管理

  • mark_as_read - メールを既読にする
  • mark_as_unread - メールを未読としてマークする
  • delete_email - メールをゴミ箱に移動する

ドラフト管理

  • create_email_draft - 新しいメールの下書きを作成する
  • update_email_draft - 既存の下書きを更新する
  • list_email_drafts - 利用可能な下書きを一覧表示する
  • send_draft - 既存の下書きを送信する

バッチ操作

  • batch_apply_label - 複数のメールにラベルを適用する
  • batch_delete_emails - 複数のメールをゴミ箱に移動する

アカウント情報

  • get_email_profile - Gmail プロフィール情報を取得する
  • summarize_recent_emails - 最近のメールの要約を作成する

💬 使用例

以下に、Claude に対するプロンプトの例を示します。

Send an email to john@example.com with the subject "Project Update" and let them know we're still on track for the deadline next week.
Search my inbox for any emails from Bank of America in the last month and summarize them for me.
Find all unread emails from my boss and create a summary of any action items mentioned in them.
Draft an email to the team about the upcoming meeting on Thursday at 2pm. Remind everyone to prepare their weekly updates.

🔧 詳細設定

環境変数

サーバーはカスタマイズのために複数の環境変数をサポートしています。

変数説明
GMAIL_TOKEN_PATHOAuth トークンを保存するためのカスタムパス
GMAIL_CREDENTIALS_PATHOAuth 認証情報へのカスタムパス
GOOGLE_CLIENT_IDOAuth クライアント ID (資格情報ファイルの代替)
GOOGLE_CLIENT_SECRETOAuth クライアント シークレット (資格情報ファイルの代替)
MCP_PORTSSEトランスポートのポート(デフォルト: 3000)
DEBUGデバッグモードを有効にする( trueまたはfalse

SSE サーバーモード

サーバーは、HTTP ベースの統合のために SSE (Server-Sent Events) モードで実行できます。

python gmail_server.py --sse [port]

これにより、指定されたポート (デフォルト: 3000) でサーバーが起動し、HTTP 経由でアクセスできるようになります。

📚 ドキュメント

🔒 セキュリティに関する考慮事項

  • サーバーは安全なGmail API認証にOAuth 2.0を使用します
  • すべてのアクションはローカルマシン上で実行されます。メールはサードパーティのサーバーを通過することはありません。
  • 認証トークンはローカルに保存され、いつでも取り消すことができます。
  • サーバーは添付ファイルの読み取りにのみローカルファイルアクセスを必要とします
  • クロードはメールを送信または削除する前に必ず確認を求めます

🤝 貢献する

貢献を歓迎します!お気軽にプルリクエストを送信してください。

  1. リポジトリをフォークする
  2. 機能ブランチを作成します( git checkout -b feature/amazing-feature
  3. 変更をコミットします ( git commit -m 'Add some amazing feature' )
  4. ブランチにプッシュする ( git push origin feature/amazing-feature )
  5. プルリクエストを開く

📝 ライセンス

このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細についてはLICENSEファイルを参照してください。

🙏 謝辞

  • Gmail API の Google
  • クロードとモデルコンテキストプロトコルの人類学的考察
  • Python Gmail API クライアント ライブラリの貢献者

-
security - not tested
A
license - permissive license
-
quality - not tested

Claude AI が Gmail と対話できるようにし、自然言語コマンドによるメールの送信、読み取り、検索、ラベル付け、下書き管理、バッチ操作をサポートするモデル コンテキスト プロトコル サーバーです。

  1. 📖 目次
    1. 📋 概要
      1. 💡主な機能
    2. 🚀 クイックスタート
      1. 前提条件
      2. インストール
      3. 初回実行と認証
      4. Claudeデスクトップの設定
    3. 🧰 利用可能なツール
      1. メール送信
      2. メールの読み上げ
      3. メールの検索と整理
      4. メールステータス管理
      5. ドラフト管理
      6. バッチ操作
      7. アカウント情報
    4. 💬 使用例
      1. 🔧 詳細設定
        1. 環境変数
        2. SSE サーバーモード
      2. 📚 ドキュメント
        1. 🔒 セキュリティに関する考慮事項
          1. 🤝 貢献する
            1. 📝 ライセンス
              1. 🙏 謝辞

                Related MCP Servers

                • -
                  security
                  F
                  license
                  -
                  quality
                  A Model Context Protocol server that enables AI assistants to interact with Gmail services, supporting email operations, draft management, and calendar functionality through Google API integration.
                  Last updated -
                  TypeScript
                • -
                  security
                  A
                  license
                  -
                  quality
                  A Model Context Protocol server that provides a seamless email management interface through Claude, allowing users to search, read, and send emails directly through natural language conversations.
                  Last updated -
                  40
                  Python
                  MIT License
                  • Apple
                • -
                  security
                  A
                  license
                  -
                  quality
                  A Model Context Protocol server that enables AI assistants like Claude to interact with Gmail through natural language, providing comprehensive email management capabilities including sending, reading, organizing, searching, and managing drafts and labels.
                  Last updated -
                  Python
                  GPL 3.0
                  • Apple
                • -
                  security
                  F
                  license
                  -
                  quality
                  A Model Context Protocol server that enables AI assistants to access and manage email through IMAP, supporting browsing, searching, reading, and organizing emails while learning user preferences over time.
                  Last updated -
                  2
                  Python
                  • Linux
                  • Apple

                View all related MCP servers

                ID: sc123prv7q