Gmail MCP Server

by Quantum-369
Apache 2.0
8
  • Apple
  • Linux

Integrations

  • Allows reading, sending, and managing emails from multiple Gmail accounts, including searching emails, downloading attachments, and handling email conversations and threads.

  • Requires a Google Cloud Project with Gmail API enabled and OAuth 2.0 credentials for authentication and authorization.

Gmail MCP サーバー

MCP(Message Control Protocol)フレームワークを使用して構築された、強力で柔軟なGmail統合サーバーです。このサーバーは、Gmail APIと連携するための堅牢なインターフェースを提供し、プログラムによるメールの読み取り、送信、管理機能を提供します。

特徴

  • 複数のGmailアカウントからメールを読む
  • 添付ファイル付きのメールを送信する
  • 高度なクエリオプションでメールを検索する
  • メールの添付ファイルをダウンロードする
  • メールの会話やスレッドを処理する
  • リアルタイムのメール監視
  • 複数のGmailアカウントのサポート

前提条件

Gmail MCP サーバーを実行する前に、次のものを用意してください。

  1. Python 3.12以上
  2. Gmail API が有効になっている Google Cloud プロジェクト
  3. OAuth 2.0 クライアントID認証情報
  4. 必要な Python パッケージ (pyproject.toml で指定)

インストール

Smithery経由でインストール

Smithery経由で Claude Desktop 用の Gmail 統合サーバーを自動的にインストールするには:

npx -y @smithery/cli install @Quantum-369/Gmail-mcp-server --client claude
  1. リポジトリをクローンします。
git clone <your-repository-url> cd gmail-mcp-server
  1. 仮想環境を作成してアクティブ化します。
python -m venv venv # On Windows venv\Scripts\activate # On Unix/MacOS source venv/bin/activate
  1. 依存関係をインストールします:
pip install .

Google Cloud プロジェクトの設定

  1. Google Cloud Consoleにアクセスします
  2. 新しいプロジェクトを作成するか、既存のプロジェクトを選択してください
  3. プロジェクトで Gmail API を有効にする
  4. OAuth 2.0 認証情報を作成します。
    • 「APIとサービス」>「認証情報」に移動します
    • 「認証情報を作成」>「OAuthクライアントID」をクリックします
    • アプリケーションの種類として「デスクトップアプリ」を選択します
    • クライアント構成ファイルをダウンロードする
  5. ダウンロードしたファイルの名前をclient_secret.jsonに変更し、プロジェクトのルートディレクトリに配置します。

構成

  1. gmail_token_creator.pyでメール識別子を設定します。
email_identifier = 'your.email@gmail.com' # Change this for each account
  1. トークン クリエーターを実行して Gmail アカウントを認証します。
python gmail_token_creator.py
  1. 統合したいGmailアカウントごとにこのプロセスを繰り返します

サーバー構造

  • gmail_server.py : メイン MCP サーバーの実装
  • gmail_api.py : Gmail API のインタラクション関数
  • google_apis.py : Google API 認証ユーティリティ
  • サポートファイル:
    • read_emails.py : メール読み取り機能
    • search_emails.py : メール検索機能
    • send_emails.py : メール送信機能

使用法

サーバーの起動

python gmail_server.py

利用可能なツール

  1. メールを送信:
await send_gmail( email_identifier="your.email@gmail.com", to="recipient@example.com", subject="Test Subject", body="Email body content", attachment_paths=["path/to/attachment"] )
  1. メールを検索:
await search_email_tool( email_identifier="your.email@gmail.com", query="from:someone@example.com", max_results=30, include_conversations=True )
  1. 最新のメールを読む:
await read_latest_emails( email_identifier="your.email@gmail.com", max_results=5, download_attachments=False )
  1. 添付ファイルをダウンロード:
await download_email_attachments( email_identifier="your.email@gmail.com", msg_id="message_id", download_all_in_thread=False )

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

  • client_secret.jsonを安全に保存し、バージョン管理にコミットしないでください。
  • トークンファイルを安全に保ち、 .gitignoreに追加します。
  • 機密情報には環境変数を使用する
  • OAuth認証情報を定期的にローテーションする
  • APIの使用状況を監視し、適切な割り当てを設定する

エラー処理

サーバーには包括的なエラー処理とログ記録が含まれています。

  • ログはgmail_mcp.logに書き込まれます
  • ファイルとコンソールの両方のログが有効になっています
  • デバッグのための詳細なエラーメッセージ

貢献

  1. リポジトリをフォークする
  2. 機能ブランチを作成する
  3. 変更をコミットする
  4. ブランチにプッシュする
  5. プルリクエストを作成する

ライセンス

Apacheライセンス2.0

サポート

問題や機能のリクエストについては、GitHub の問題追跡ツールを使用してください。

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

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Gmail APIを介してGmailと連携し、メールの閲覧、送信、管理が可能です。複数のGmailアカウントをサポートし、リアルタイム監視機能、メール検索機能、添付ファイル処理機能などの高度な機能も備えています。

  1. 特徴
    1. 前提条件
      1. インストール
        1. Smithery経由でインストール
      2. Google Cloud プロジェクトの設定
        1. 構成
          1. サーバー構造
            1. 使用法
              1. サーバーの起動
              2. 利用可能なツール
            2. セキュリティに関する考慮事項
              1. エラー処理
                1. 貢献
                  1. ライセンス
                    1. サポート

                      Related MCP Servers

                      • -
                        security
                        F
                        license
                        -
                        quality
                        Enables users to manage Gmail accounts using AI agent-assisted operations via an MCP protocol, supporting email search, reading, deletion, and sending with a voice-powered interface.
                        Last updated -
                        2
                        5
                        TypeScript
                      • -
                        security
                        A
                        license
                        -
                        quality
                        Integrates with Gmail to enable sending, reading, drafting, and managing emails via the Model Context Protocol (MCP), allowing users to interact with email tasks through automated client prompts.
                        Last updated -
                        Python
                        GPL 3.0
                      • -
                        security
                        A
                        license
                        -
                        quality
                        An MCP server that enables Gmail integration, allowing users to manage emails (send, receive, read, trash, mark as read) directly through MCP clients like Claude Desktop.
                        Last updated -
                        Python
                        MIT License
                      • -
                        security
                        F
                        license
                        -
                        quality
                        Enables AI assistants to interact with Gmail accounts via IMAP, allowing them to list, search, read, and send emails, manage labels and folders, and access attachments through the Model Context Protocol.
                        Last updated -
                        Python
                        • Linux
                        • Apple

                      View all related MCP servers

                      ID: mkugelscaj