Skip to main content
Glama

Gmail MCP サーバー

鍛冶屋のバッジ

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

特徴

  • 複数のGmailアカウントからメールを読む

  • 添付ファイル付きのメールを送信する

  • 高度なクエリオプションでメールを検索する

  • メールの添付ファイルをダウンロードする

  • メールの会話やスレッドを処理する

  • リアルタイムのメール監視

  • 複数のGmailアカウントのサポート

Related MCP server: Systemprompt MCP Gmail Server

前提条件

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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Quantum-369/Gmail-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server