Skip to main content
Glama

Gmail second account MCP server

Version Python Node OAuth

Claude.ai と Claude Code から 1つ の Gmail メールボックスを読み書きします。Claude.ai 標準の Gmail コネクタは単一アカウントしか扱えないため、これは2つ目のアカウントのために存在します。メールボックスごとにインスタンスを実行すると、各コネクタは指定されたアドレスだけにアクセスします。

インスタンスごとに1つのメールボックス

インスタンスが扱うアカウントは GMAIL_CREDENTIALS_DIR から決まり、そのプロセスからはそれ以外のものには一切アクセスできません。この分離は制限ではなく、むしろ要点です。サーバーが常に1組の認証情報しか保持しないため、下書きが誤ったメールボックスに保存されることはありません。

Related MCP server: Gmail MCP Local Server

ツール

読み取り

ツール

取得内容

gmail_profile

このインスタンスが扱うメールボックスとその件数

gmail_search

Gmail 独自のクエリ構文で検索

gmail_get_message

本文を含む1件のメッセージ

gmail_get_thread

会話全体を古い順に取得

gmail_list_attachments

メッセージに添付されたファイル名、種類、サイズ

gmail_list_labels

すべてのラベルとそのID

gmail_list_drafts / gmail_get_draft

メールボックス内の下書き

書き込み

ツール

機能

gmail_create_draft

下書きを作成(返信としてスレッド化することも可能)

gmail_update_draft

下書きの内容を置き換え

gmail_delete_draft

下書きを破棄

gmail_modify_labels

メッセージのラベルを追加または削除

gmail_archive

メッセージを受信トレイから取り出す

gmail_mark_read

既読または未読にする

gmail_trash / gmail_untrash

ゴミ箱へ移動、および元に戻す

gmail_create_label / gmail_delete_label

ラベルを管理

gmail_send_draft

既存の下書きを送信

gmail_send_message

作成と送信を一度に行う

2つの送信ツールは破壊的とマークされ、その説明にもそう記載されています。これらは他の人に届き、取り消すことができません。安全な流れは、gmail_create_draft で下書きを作成し、内容を確認した上で、承認を得てから gmail_send_draft で送信することです。

検索

gmail_search は Gmail の検索ボックスと同じ演算子を使用します:

is:unread from:client.com
subject:invoice has:attachment newer_than:7d
label:important -in:trash

本文ではなく、メッセージごとのヘッダーとスニペットを返すため、広範囲の検索でも結果は小さく保たれます。続けて gmail_get_message または gmail_get_thread を使用してください。

全体の構成

Claude.ai / Claude Code
        |  HTTPS
   Cloudflare Tunnel, or any proxy that gives you HTTPS
        |
   nginx  127.0.0.1:8461
        |
   auth-server.js  :8462    handles the login and the tokens
        |
   gmail-mcp  :8460         the server itself, local only
        |
   gmail.googleapis.com

MCP 自体にはログイン機能がなく、ローカルマシン以外からの接続を拒否するため、このサーバーに到達するすべてのリクエストは、すでにログインを通過しています。

セットアップ

Gmail API を有効にした Google Cloud の OAuth クライアントと、メールボックス用のリフレッシュトークンが必要です。認証情報ディレクトリには2つのファイルが置かれます:

credentials.json        {"refresh_token": "..."}
gcp-oauth.keys.json     the downloaded OAuth client

付与するスコープは gmail.modify です。読み取り、ラベル付け、下書き作成、送信をカバーします。認証情報自体に送信権限を持たせたくない場合は、gmail.readonlygmail.compose に絞ってください。

git clone https://github.com/rollecode/gmail-second-account-mcp.git
cd gmail-second-account-mcp
uv venv && uv pip install -e .
npm install --omit=dev

CONFIG_DIR=~/.config/gmail-mcp node set-password.js 'your-password-here'
openssl rand -hex 32 > ~/.config/gmail-mcp/token
chmod 600 ~/.config/gmail-mcp/token

systemd/*.servicenginx/gmail-mcp.confYOUR_USER、ホスト名、認証情報ディレクトリを入力し、次に:

sudo cp systemd/*.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now gmail-mcp gmail-mcp-auth

sudo cp nginx/gmail-mcp.conf /etc/nginx/sites-enabled/gmail-mcp
sudo nginx -t && sudo systemctl reload nginx

トンネルまたは HTTPS プロキシを 127.0.0.1:8461 に向けます。OAuth には HTTPS が必要です。

外部から確認します: ディスカバリはメタデータを返し、トークンなしの /mcp401 を返す必要があります。

curl https://your-host/.well-known/oauth-authorization-server
curl -o /dev/null -w '%{http_code}\n' -X POST https://your-host/mcp

接続

Claude.ai: 設定、コネクタ、カスタムコネクタの追加、https://your-host/mcp、クライアントIDとシークレットは空欄。

Claude Code:

claude mcp add --transport http gmail https://your-host/mcp \
  --header "Authorization: Bearer $(cat ~/.config/gmail-mcp/token)" --scope user

サーバーを一切使わず、stdio 経由でローカルに接続:

GMAIL_CREDENTIALS_DIR=/path/to/creds claude mcp add gmail -- /path/to/.venv/bin/gmail-mcp

設定

変数

説明

GMAIL_CREDENTIALS_DIR

credentials.jsongcp-oauth.keys.json を保持するディレクトリ

GMAIL_ACCOUNT_LABEL

メールボックスの名前。サーバーの指示に表示されます

MCP_PUBLIC_URL

公開アドレス。アイコンの告知に使用

ISSUER

ログインサーバーの公開オリジン

PORT

ログインサーバーのポート。デフォルトは8462

UPSTREAM

MCP サーバーの URL。デフォルトは http://127.0.0.1:8460

CONFIG_DIR

パスワード、トークン、OAuth データベースが置かれる場所

アクセストークンは期限切れになるとメモリ内で更新されます。ディスクから読み取られるのはリフレッシュトークンだけです。

クレジット

ログイン層は rollecode/obsidian-remote-mcp に由来します。

A
license - permissive license
A
quality
A
maintenance

Maintenance

Maintainers
Response time
0dRelease cycle
2Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    F
    maintenance
    Enables reading, sending, searching, and managing Gmail through Claude using the official Google Gmail API.
    165
    3
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables Claude to read, search, send, and manage Gmail messages and threads through natural language.
    205
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables Gmail integration with Claude Code for reading, sending, searching emails, and managing labels through natural language.
    205
    MIT

View all related MCP servers

Related MCP Connectors

  • Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflow…

  • Manage Gmail messages, threads, labels, drafts, and settings from your workflows. Send and organiz…

  • Read, search, send, organize, draft and schedule email across your inboxes from any MCP client.

View all MCP Connectors

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/rollecode/gmail-second-account-mcp'

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