Skip to main content
LibreChat is joining ClickHouse to power the open-source Agentic Data Stack 🎉 Learn more
LibreChat

Google Workspace MCP

LibreChatでGmail、Drive、Calendar、People、Chat用のGoogleリモートWorkspace MCPサーバーを設定します。

Googleは、Google Workspace製品向けにリモートのModel Context Protocol (MCP) サーバーを提供しています。LibreChatでは、各Google Workspace製品はそれぞれ独自のOAuth対応リモートMCPサーバーとして設定されます。

開発者プレビュー

Googleは、Workspace MCPサーバーをGoogle Workspace Developer Preview Programの一部として位置づけています。 利用可能な製品、スコープ、および検証要件が変更される可能性があるため、これを広範囲に展開する前にGoogleの最新のドキュメントを確認してください。

設定するもの

Google Workspace MCPは、単一の統合サーバーではありません。ユーザーに公開したい製品のみを設定してください:

製品MCPサーバー URL
Gmailhttps://gmailmcp.googleapis.com/mcp/v1
Google Drivehttps://drivemcp.googleapis.com/mcp/v1
Google Calendarhttps://calendarmcp.googleapis.com/mcp/v1
People APIhttps://people.googleapis.com/mcp/v1
Google Chathttps://chatmcp.googleapis.com/mcp/v1

各ユーザーはLibreChat UIから各サーバーに接続します。LibreChatはユーザーごとにOAuthトークンを保存するため、Gmail、Drive、Calendar、People、およびChatへのアクセスは、接続を承認したGoogleアカウントに従います。

前提条件

  • Google Cloud プロジェクト。
  • そのプロジェクトでAPIを有効化し、OAuthクライアントを作成する権限。
  • gcloud がインストールされ認証済みであること、または Google Cloud コンソールへのアクセス権があること。
  • librechat.yaml がマウントされているか、あるいは読み込まれている実行中の LibreChat インスタンス。
  • ユーザーがLibreChatを開くために使用するパブリックベースURL。例えば、ローカル開発環境の場合は http://localhost:3080、本番環境の場合は https://chat.example.com となります。

OAuth コールバックパス

LibreChatのMCP OAuthコールバックパスは BASE_URL/api/mcp/SERVER_NAME/oauth/callback です。 SERVER_NAMElibrechat.yaml 内の mcpServers にあるキー(gmaildrive など)です。

セットアップ

Google Workspace API を有効にする

PROJECT_ID をご自身の Google Cloud プロジェクト ID に置き換えてください:

gcloud services enable gmail.googleapis.com \
  drive.googleapis.com \
  calendar-json.googleapis.com \
  chat.googleapis.com \
  people.googleapis.com \
  --project=PROJECT_ID

Google Workspace MCP サービスを有効にする

設定を予定している製品に対して、MCPサービスを有効にします:

gcloud services enable gmailmcp.googleapis.com \
  drivemcp.googleapis.com \
  calendarmcp.googleapis.com \
  chatmcp.googleapis.com \
  people.googleapis.com \
  --project=PROJECT_ID

必要に応じて Google Chat を設定する

Google Chat MCPサーバーには、同じGoogle Cloudプロジェクト内のChatアプリが必要です。

Google Cloud コンソールで、Google Chat API > 管理 > 構成 を開き、Chat アプリを作成します:

  • アプリ名: Chat MCP
  • Avatar URL: https://developers.google.com/chat/images/quickstart-app-avatar.png
  • 説明: Chat MCP server
  • 機能: Enable interactive features をオフにする
  • ログ: Log errors to Logging を選択します

Save をクリックします。

チャットにはWorkspaceアカウントが必要です

Google Chat アプリの設定は、個人用の Google アカウントでは利用できない場合があります。コンソールに Google Chat API は Google Workspace ユーザーのみが利用可能であると表示される場合は、chat MCP サーバーを省略するか、Workspace に紐付いたプロジェクトまたはアカウントを使用してください。

Google Auth Platform を設定する

Google Cloud コンソールで、Google Auth Platform に移動します。

Google Auth Platformがまだ設定されていない場合は、Get Startedをクリックして以下を入力してください:

  • App name: 明確な名前を使用してください(例: LibreChat Google Workspace MCP)。
  • ユーザーサポートメール: あなたのサポートメールアドレスまたはGoogleグループ。
  • Audience: Google Workspace組織の場合はInternalを、組織外のユーザーや個人のGoogleアカウントを使用している場合はExternalを選択してください。
  • 開発者の連絡先情報: Googleがプロジェクトに関する通知を送るためのメールアドレス。

Externalを選択し、アプリをテストモードのままにする場合は、Audience > Test usersの下に自分自身および許可する他のユーザーを追加してください。

データアクセスのスコープを追加する

Data Access > Add or Remove Scopes を開きます。Manually add scopes の下に、使用したいサーバーのスコープを貼り付けます。

https://www.googleapis.com/auth/gmail.readonly
https://www.googleapis.com/auth/gmail.compose
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/calendar.calendarlist.readonly
https://www.googleapis.com/auth/calendar.events.freebusy
https://www.googleapis.com/auth/calendar.events.readonly
https://www.googleapis.com/auth/directory.readonly
https://www.googleapis.com/auth/userinfo.profile
https://www.googleapis.com/auth/contacts.readonly
https://www.googleapis.com/auth/chat.spaces.readonly
https://www.googleapis.com/auth/chat.memberships.readonly
https://www.googleapis.com/auth/chat.messages.readonly
https://www.googleapis.com/auth/chat.messages.create
https://www.googleapis.com/auth/chat.users.readstate.readonly

Add to TableUpdate をクリックし、Save をクリックします。

機密および制限付きスコープ

Gmail、Drive、Chat、Contacts、およびDirectoryのスコープは、Googleの機密スコープまたは制限付きスコープの審査をトリガーする可能性があります。個人的な使用や限定的な開発目的の場合、ユーザーには未確認アプリの警告が表示され、100ユーザーの上限が適用されることがあります。公開用または組織全体で使用する場合は、GoogleのOAuth確認プロセスおよび必要な制限付きスコープの審査を完了してください。

WebアプリケーションOAuthクライアントを作成する

Google Auth Platform > Clients で、OAuth クライアントを作成します:

  • アプリケーションタイプ: Web application
  • Name: 説明的な名前を使用してください(例: LibreChat Google Workspace MCP

設定するすべてのサーバーに対して、許可されたリダイレクトURIを追加してください。ローカル開発の場合:

http://localhost:3080/api/mcp/gmail/oauth/callback
http://localhost:3080/api/mcp/drive/oauth/callback
http://localhost:3080/api/mcp/calendar/oauth/callback
http://localhost:3080/api/mcp/people/oauth/callback
http://localhost:3080/api/mcp/chat/oauth/callback

本番環境では、http://localhost:3080 をお使いの LibreChat URL に置き換えてください:

https://chat.example.com/api/mcp/gmail/oauth/callback

Createをクリックし、Client IDClient secretをコピーします。

.env に OAuth 認証情報を追加する

LibreChat の .env ファイルに OAuth クライアントの値を追加します:

GOOGLE_WORKSPACE_MCP_CLIENT_ID=your-oauth-client-id
GOOGLE_WORKSPACE_MCP_CLIENT_SECRET=your-oauth-client-secret

librechat.yaml 内の参照も更新すれば、異なる環境変数名を使用することも可能です。

librechat.yaml に MCP サーバーを追加する

mcpServers の下に、追加したいサーバーを記述します。この例では、現在ドキュメント化されているすべての Google Workspace MCP サーバーを使用しています:

mcpServers:
  gmail:
    type: streamable-http
    url: 'https://gmailmcp.googleapis.com/mcp/v1'
    timeout: 60000
    initTimeout: 150000
    requiresOAuth: true
    startup: false
    oauth:
      authorization_url: 'https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&prompt=consent'
      token_url: 'https://oauth2.googleapis.com/token'
      client_id: '${GOOGLE_WORKSPACE_MCP_CLIENT_ID}'
      client_secret: '${GOOGLE_WORKSPACE_MCP_CLIENT_SECRET}'
      scope: 'https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.compose'
      redirect_uri: 'http://localhost:3080/api/mcp/gmail/oauth/callback'
      token_exchange_method: default_post
      token_endpoint_auth_methods_supported: ['client_secret_post']
 
  drive:
    type: streamable-http
    url: 'https://drivemcp.googleapis.com/mcp/v1'
    timeout: 60000
    initTimeout: 150000
    requiresOAuth: true
    startup: false
    oauth:
      authorization_url: 'https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&prompt=consent'
      token_url: 'https://oauth2.googleapis.com/token'
      client_id: '${GOOGLE_WORKSPACE_MCP_CLIENT_ID}'
      client_secret: '${GOOGLE_WORKSPACE_MCP_CLIENT_SECRET}'
      scope: 'https://www.googleapis.com/auth/drive.readonly https://www.googleapis.com/auth/drive.file'
      redirect_uri: 'http://localhost:3080/api/mcp/drive/oauth/callback'
      token_exchange_method: default_post
      token_endpoint_auth_methods_supported: ['client_secret_post']
 
  calendar:
    type: streamable-http
    url: 'https://calendarmcp.googleapis.com/mcp/v1'
    timeout: 60000
    initTimeout: 150000
    requiresOAuth: true
    startup: false
    oauth:
      authorization_url: 'https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&prompt=consent'
      token_url: 'https://oauth2.googleapis.com/token'
      client_id: '${GOOGLE_WORKSPACE_MCP_CLIENT_ID}'
      client_secret: '${GOOGLE_WORKSPACE_MCP_CLIENT_SECRET}'
      scope: 'https://www.googleapis.com/auth/calendar.calendarlist.readonly https://www.googleapis.com/auth/calendar.events.freebusy https://www.googleapis.com/auth/calendar.events.readonly'
      redirect_uri: 'http://localhost:3080/api/mcp/calendar/oauth/callback'
      token_exchange_method: default_post
      token_endpoint_auth_methods_supported: ['client_secret_post']
 
  people:
    type: streamable-http
    url: 'https://people.googleapis.com/mcp/v1'
    timeout: 60000
    initTimeout: 150000
    requiresOAuth: true
    startup: false
    oauth:
      authorization_url: 'https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&prompt=consent'
      token_url: 'https://oauth2.googleapis.com/token'
      client_id: '${GOOGLE_WORKSPACE_MCP_CLIENT_ID}'
      client_secret: '${GOOGLE_WORKSPACE_MCP_CLIENT_SECRET}'
      scope: 'https://www.googleapis.com/auth/directory.readonly https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/contacts.readonly'
      redirect_uri: 'http://localhost:3080/api/mcp/people/oauth/callback'
      token_exchange_method: default_post
      token_endpoint_auth_methods_supported: ['client_secret_post']
 
  chat:
    type: streamable-http
    url: 'https://chatmcp.googleapis.com/mcp/v1'
    timeout: 60000
    initTimeout: 150000
    requiresOAuth: true
    startup: false
    oauth:
      authorization_url: 'https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&prompt=consent'
      token_url: 'https://oauth2.googleapis.com/token'
      client_id: '${GOOGLE_WORKSPACE_MCP_CLIENT_ID}'
      client_secret: '${GOOGLE_WORKSPACE_MCP_CLIENT_SECRET}'
      scope: 'https://www.googleapis.com/auth/chat.spaces.readonly https://www.googleapis.com/auth/chat.memberships.readonly https://www.googleapis.com/auth/chat.messages.readonly https://www.googleapis.com/auth/chat.messages.create https://www.googleapis.com/auth/chat.users.readstate.readonly'
      redirect_uri: 'http://localhost:3080/api/mcp/chat/oauth/callback'
      token_exchange_method: default_post
      token_endpoint_auth_methods_supported: ['client_secret_post']

LibreChatをパブリックURLでデプロイしている場合は、すべての redirect_uri をGoogle Cloudに登録されているリダイレクトURIと完全に一致するように更新してください。

厳格なMCPドメイン許可リスト

librechat.yamlmcpSettings.allowedDomains も設定している場合は、使用する Google MCP ホスト(gmailmcp.googleapis.comdrivemcp.googleapis.comcalendarmcp.googleapis.comchatmcp.googleapis.compeople.googleapis.com など)を追加してください。

LibreChatを再起動する

LibreChatを再起動して、.envlibrechat.yaml を再読み込みしてください。

デプロイコマンド
Dockerdocker compose up -d
ローカルサーバーを停止してから、再度起動します

Dockerで読み込まれたサーバーを確認するには、APIログを確認してください:

docker logs LibreChat --tail 200 | grep MCP

LibreChatの各サーバーを接続する

LibreChatを開き、チャット入力欄にあるMCP SettingsまたはMCP Serversドロップダウンを開きます。

各Google Workspaceサーバーについて:

  1. Connect をクリックします。
  2. ブラウザでGoogle OAuthフローを完了します。
  3. 要求されたスコープを確認してください。
  4. 許可をクリックします。

OAuthが成功すると、サーバーのツールがチャットおよびAgent Builder内で利用可能になります。

テスト

一度に1つのサーバーを対象とするプロンプトを試してください:

ServerPrompt
People"According to my Google profile, what's my name?"
Drive"Find a file named Marketing Plan and summarize it."
Gmail"Find my latest email about the marketing plan."
Gmail"Draft an email to [email protected] saying I approve the marketing plan."
Calendar"When is my next meeting with Ariel?"
Chat"Search recent Google Chat messages about the marketing plan."

トラブルシューティング

症状確認事項
Googleが redirect_uri_mismatch を返すGoogle OAuthクライアントのリダイレクトURIは、プロトコル、ホスト名、ポート、サーバー名、パスを含め、librechat.yaml 内の redirect_uri と完全に一致している必要があります。
LibreChatにサーバーは表示されるがツールが表示されないLibreChat UIからサーバーを接続してください。OAuth対応のリモートサーバーは、ユーザーが認証を完了した後にツールを公開します。
Googleが未確認アプリの警告を表示するこれは、機密または制限付きのスコープを要求する未確認アプリでは想定される動作です。個人利用や限定的な開発用途の場合、プロジェクトがGoogleの未確認ユーザー上限に達するまで、ユーザーは警告を無視して続行できます。
OAuthはテスト環境では動作するが、後で期限切れになるテストモードの外部アプリは、7日後に期限切れとなるリフレッシュトークンを受け取ることがあります。より長期間有効なリフレッシュトークンを取得するにはアプリを本番環境へ公開するか、開発中に再認証を行ってください。
Google Chatの設定が無効になっているGoogle Workspaceで管理されたプロジェクト/アカウントをChatに使用するか、chat サーバーを省略してください。
MCPリクエストがLibreChatのドメインポリシーによってブロックされるmcpSettings.allowedDomains が設定されている場合は、使用しているGoogle MCPサーバーのホスト名を追加してください。

セキュリティに関する注意点

  • 信頼できるLibreChatインスタンスにのみ、Google Workspace MCPサーバーを接続してください。
  • ユーザーが実際に必要とする製品とスコープのみを要求してください。
  • メールの送信、チャットメッセージの投稿、ファイルのアップロード、またはカレンダーイベントの変更を行う前に、アシスタントが提案したアクションを確認します。
  • メールメッセージ、ドキュメント、およびチャットメッセージは信頼できない入力として扱ってください。これらには、アシスタントに影響を与えようとする間接的なプロンプトインジェクションが含まれている可能性があります。
  • 公開または組織全体でのデプロイメントの場合は、Google OAuthの認証を完了し、組織のサードパーティ製アプリのアクセス制御に従ってください。

このガイドはいかがでしたか?