Skip to main content
Glama

gdrive-mcp

Google Drive フォルダを Streamable HTTP で公開するMCP(Model Context Protocol)サーバーです。Vercel 上で実行し、GitHub でホストすることを想定しています。

次の 2 つのツールを提供します:

ツール

説明

list_files

設定された Drive フォルダ内のファイル/フォルダを一覧表示します(検索可能)

read_file

テキストコンテンツを読み取ります。Google Docs/Sheets/Slides は自動エクスポートします

アーキテクチャ

  • server.ts — Node.js HTTP サーバーのエントリポイント(Streamable HTTP のMCPエンドポイント)。

  • src/mcp.ts — MCP サーバーの定義とツール。

  • src/drive.ts — サービス アカウントを使用する Google Drive クライアント。

認証は、Google のサービス アカウントによる読み取り専用(drive.readonly)です。


Related MCP server: gdrive-mcp-server

1. Google Cloud のセットアップ(サービス アカウント)

  1. Google Cloud Console にアクセスして、プロジェクトを作成します。

  2. Google Drive API を有効にします: APIs & Services → Library で "Google Drive API" を検索して [Enable] をクリックします。

  3. サービス アカウントを作成します: IAM & Admin → Service Accounts → Create Service Account。

  4. そのアカウントの JSON キーを作成します: サービス アカウントを開く → Keys → Add Key → Create New Key → JSON。ファイルをダウンロードします。

  5. サービス アカウントのメールアドレスを確認します(name@project.iam.gserviceaccount.com のような形式です)。

  6. Drive フォルダをそのメールアドレスと共有します:

    • Google Drive でフォルダを開く → 右クリック → Share。

    • サービス アカウントのメールアドレスを貼り付け、閲覧者アクセス権を付与します。

  7. フォルダ ID(URL 内の /folders/ の後ろの部分)をコピーします。


2. ローカル環境のセットアップ

git clone <your-repo-url>
cd gdrive-mcp
npm install

.env ファイルを作成します(.env.example をコピー):

DRIVE_FOLDER_ID=1XM-0CtgvW3PGDekC8qLa2ghxRyvTfjwD
GOOGLE_SERVICE_ACCOUNT_KEY=<base64 of service-account.json>

サービス アカウント キーを base64 にエンコードします:

  • Linux/macOS: base64 -w0 service-account.json

  • PowerShell: [Convert]::ToBase64String([IO.File]::ReadAllBytes("service-account.json"))


3. Vercel へのデプロイ

オプション A — Vercel + GitHub(推奨)

  1. このリポジトリを GitHub にプッシュします。

  2. Vercel で Add New → Project から GitHub リポジトリをインポートします。

  3. 環境変数(DRIVE_FOLDER_ID、GOOGLE_SERVICE_ACCOUNT_KEY)を追加します。

  4. デプロイします。MCP エンドポイントは次のようになります:

    https://<your-project>.vercel.app

オプション B — Vercel CLI

npm i -g vercel
vercel login
vercel env add DRIVE_FOLDER_ID
vercel env add GOOGLE_SERVICE_ACCOUNT_KEY
vercel --prod

4. GitHub へのプッシュ(初回のみ)

git init
git add .
git commit -m "Add gdrive-mcp server"
git branch -M main
git remote add origin https://github.com/<you>/gdrive-mcp.git
git push -u origin main

5. MCP クライアントを接続する

クライアントを、Streamable HTTP トランスポートでデプロイされた URL に接続します。claude_desktop_config.json の例:

{
  "mcpServers": {
    "gdrive": {
      "type": "http",
      "url": "https://<your-project>.vercel.app"
    }
  }
}

汎用のMCP設定形式を使用するクライアントの場合:

{
  "mcpServers": {
    "gdrive": {
      "url": "https://<your-project>.vercel.app"
    }
  }
}

このエンドポイントはステートレスなので、リクエストごとに新しいトランスポートが作成されます。サーバーレスに最適です。 アクセス制御は、サービス アカウントに対する Google Drive の共有設定によって行われます。

環境変数

変数

必須

説明

DRIVE_FOLDER_ID

はい

Google Drive のフォルダ ID

GOOGLE_SERVICE_ACCOUNT_KEY

はい

Base64 エンコードされたサービス アカウントの JSON キー

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    C
    maintenance
    A read-only Google Drive MCP server that allows searching files, reading file content (with auto-export for Google Docs, Sheets, Slides), and retrieving file metadata via OAuth authentication.
    13 npm
    2
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables MCP-compatible AI assistants to interact with a user's Google Drive, including listing, searching, reading, creating, updating, and deleting files, with authentication via Google OAuth.
    -
  • F
    license
    Not graded
    quality
    B
    maintenance
    A read-only MCP server that exposes a configured Google Drive folder to MCP clients, enabling them to list, search, and extract content from various file formats like Excel, CSV, PDF, DOCX, and images.
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables interacting with Google Drive folders through an MCP server, allowing listing, searching, and reading files using tools like list_files, search_files, get_file, and read_file.
    -