gmail-mcp
Gmail second account MCP server
Claude.ai と Claude Code から 1つ の Gmail メールボックスを読み書きします。Claude.ai 標準の Gmail コネクタは単一アカウントしか扱えないため、これは2つ目のアカウントのために存在します。メールボックスごとにインスタンスを実行すると、各コネクタは指定されたアドレスだけにアクセスします。
インスタンスごとに1つのメールボックス
インスタンスが扱うアカウントは GMAIL_CREDENTIALS_DIR から決まり、そのプロセスからはそれ以外のものには一切アクセスできません。この分離は制限ではなく、むしろ要点です。サーバーが常に1組の認証情報しか保持しないため、下書きが誤ったメールボックスに保存されることはありません。
Related MCP server: Gmail MCP Local Server
ツール
読み取り
ツール | 取得内容 |
| このインスタンスが扱うメールボックスとその件数 |
| Gmail 独自のクエリ構文で検索 |
| 本文を含む1件のメッセージ |
| 会話全体を古い順に取得 |
| メッセージに添付されたファイル名、種類、サイズ |
| すべてのラベルとそのID |
| メールボックス内の下書き |
書き込み
ツール | 機能 |
| 下書きを作成(返信としてスレッド化することも可能) |
| 下書きの内容を置き換え |
| 下書きを破棄 |
| メッセージのラベルを追加または削除 |
| メッセージを受信トレイから取り出す |
| 既読または未読にする |
| ゴミ箱へ移動、および元に戻す |
| ラベルを管理 |
| 既存の下書きを送信 |
| 作成と送信を一度に行う |
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.comMCP 自体にはログイン機能がなく、ローカルマシン以外からの接続を拒否するため、このサーバーに到達するすべてのリクエストは、すでにログインを通過しています。
セットアップ
Gmail API を有効にした Google Cloud の OAuth クライアントと、メールボックス用のリフレッシュトークンが必要です。認証情報ディレクトリには2つのファイルが置かれます:
credentials.json {"refresh_token": "..."}
gcp-oauth.keys.json the downloaded OAuth client付与するスコープは gmail.modify です。読み取り、ラベル付け、下書き作成、送信をカバーします。認証情報自体に送信権限を持たせたくない場合は、gmail.readonly と gmail.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/tokensystemd/*.service と nginx/gmail-mcp.conf の YOUR_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 が必要です。
外部から確認します: ディスカバリはメタデータを返し、トークンなしの /mcp は 401 を返す必要があります。
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設定
変数 | 説明 |
|
|
| メールボックスの名前。サーバーの指示に表示されます |
| 公開アドレス。アイコンの告知に使用 |
| ログインサーバーの公開オリジン |
| ログインサーバーのポート。デフォルトは8462 |
| MCP サーバーの URL。デフォルトは |
| パスワード、トークン、OAuth データベースが置かれる場所 |
アクセストークンは期限切れになるとメモリ内で更新されます。ディスクから読み取られるのはリフレッシュトークンだけです。
クレジット
ログイン層は rollecode/obsidian-remote-mcp に由来します。
Maintenance
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
- AlicenseNot gradedqualityFmaintenanceEnables reading, sending, searching, and managing Gmail through Claude using the official Google Gmail API.1653MIT
- FlicenseNot gradedqualityDmaintenanceProvides Claude with Gmail capabilities including sending emails, managing drafts, and searching messages.
- AlicenseNot gradedqualityDmaintenanceEnables Claude to read, search, send, and manage Gmail messages and threads through natural language.205MIT
- AlicenseNot gradedqualityDmaintenanceEnables Gmail integration with Claude Code for reading, sending, searching emails, and managing labels through natural language.205MIT
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.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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