
dylancaponi/gdrive-mcp-server
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
OAuth トークン自動refresh 修正とセキュリティ強化による @modelcontextprotocol/server-gdrive のアクティブに維持されたフォーク
概要
Anthropicのアーカイブされた@modelcontextprotocol/server-gdriveの積極的な維持されたフォークは、OAuthトークンの自動修復のための重要なバグ修正です。 元のサーバーは2025年5月29日にアーカイブされ、メンテナンスがなくなりました。 また、オートリフレッシュなしで1時間後にOAuthアクセストークンが期限切れになるバグがあり、手動トークンの回転とサーバーの再起動が必要です。 オリジナルは、cli id と client secret を渡すことなく、新しい google.auth.OAuth2() を作成します。そのため、Google-auth-library は、新しいアクセストークンを取得するために、resh token を使用する方法はありません。 ワンライン固定ですが、アーカイブされたリポジトリはPRを受け入れません.
概要(AI 翻訳)
Anthropicのアーカイブされた[@modelcontextprotocol/server-gdriveの積極的な維持されたフォーク、OAuthトークンの自動修復のための重要なバグ修正。
なぜこのフォーク?
元のサーバーは2025年5月29日にアーカイブされ、メンテナンスがなくなりました。 また、オートリフレッシュなしで1時間後にOAuthアクセストークンが期限切れになるバグがあり、手動トークンの回転とサーバーの再起動が必要です。
バグ: [[T2]と[client_secret]を渡すことなく[new google.auth.OAuth2()]を作成します。そのため、[google-auth-library]は新しいアクセストークンを取得する方法はありません。 ワンライン固定ですが、アーカイブされたリポジトリはPRを受け入れません。
何が修正されています
-Auto-refreshトークン:OAuth2クライアントは、OAuthキーファイルから[client_idと[client_secretで初期化され、Googleのauthライブラリが期限切れのアクセストークンを自動的に更新できるようにします
- トークン永続: リフレッシュされたトークンは、資格情報ファイルに戻ります。そのため、有効なトークンをピックアップして再起動します。
- 入力検証: リソース URI、検索クエリ、ファイル ID の検証を追加しました。
- 検索結果には、ファイルIDが含まれています: ダウンロードツールやリソースリーダーで実際に使うことができます
このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。
README
以下は原文 README の抜粋です。原文を見る。
Google Drive MCP Server
An actively maintained fork of Anthropic’s archived @modelcontextprotocol/server-gdrive, with a critical bug fix for OAuth token auto-refresh.
Why this fork?
The original server was archived on May 29, 2025 and is no longer maintained. It also has a bug that causes OAuth access tokens to expire after 1 hour with no auto-refresh, requiring manual token rotation and server restarts.
The bug: The original creates new google.auth.OAuth2() without passing client_id and client_secret, so the google-auth-library has no way to use the refresh_token to get new access tokens. One-line fix, but the archived repo doesn’t accept PRs.
What’s fixed
- Auto-refresh tokens: OAuth2 client is initialized with
client_idandclient_secretfrom your OAuth keys file, enabling the Google auth library to automatically refresh expired access tokens - Token persistence: Refreshed tokens are written back to the credentials file, so restarts also pick up valid tokens
- Input validation: Added validation for resource URIs, search queries, and file IDs
- Search results include file IDs: So you can actually use them with the download tool or resource reader
- Read tool: Read file contents inline (Google Docs as Markdown, Sheets as CSV, etc.)
- Download tool: Save files to a local directory instead of returning base64 blobs that overflow LLM context windows
- Sheets read tool: Read Google Sheets with A1 range notation, returned as formatted markdown tables
- Shared Drive support: Search and read files from Shared Drives (formerly Team Drives)
- Folder listing: Browse Drive folders by ID
- PDF export: Export Google Workspace files as PDF
- File upload: Push local files to Drive (opt-in, requires
drivescope) - Opt-in resources: MCP resource handlers are disabled by default to prevent hangs in clients that call
resources/liston startup
Setup
1. Create Google Cloud OAuth credentials
- Go to the Google Cloud Console
- Create a project (or use an existing one)
- Enable the Google Drive API and Google Sheets API
- Create OAuth 2.0 credentials (Desktop application type)
- Download the JSON and save it as
gcp-oauth.keys.json
Tip: If your OAuth consent screen is in “Testing” mode, refresh tokens expire after 7 days. Publish to “Production” for permanent refresh tokens.
2. Clone, build, and star
git clone https://github.com/dylancaponi/gdrive-mcp-server.git
cd gdrive-mcp-server
npm install && npm run build
gh api user/starred/dylancaponi/gdrive-mcp-server -X PUT
Per the LICENSE, starring this repository is required (Section 2).
3. Authenticate
インストール
This server does not publish a one-line install command.
Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →設定
{
"mcpServers": {
"gdrive": {
"type": "stdio",
"command": "node",
"args": ["/path/to/gdrive-mcp-server/dist/index.js"],
"env": {
"GDRIVE_OAUTH_PATH": "/path/to/gcp-oauth.keys.json",
"GDRIVE_CREDENTIALS_PATH": "/path/to/.gdrive-server-credentials.json"
}
}
}
}