gdrive-mcp
gdrive-mcp
一个通过 Streamable HTTP 公开 Google Drive 文件夹的 MCP(Model Context Protocol)服务器,专为在 Vercel 上运行而构建,并托管在 GitHub 上。
它提供两个工具:
工具 | 描述 |
| 列出已配置的 Drive 文件夹中的文件/文件夹(可选搜索) |
| 读取文本内容,自动导出 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 设置(服务账号)
前往 Google Cloud Console 并创建一个项目。
启用 Google Drive API:
APIs & Services→Library→ 搜索 "Google Drive API" -> 启用。创建服务账号:
IAM & Admin→Service Accounts->Create Service Account。为它创建 JSON 密钥:打开服务账号 ->
Keys->Add Key->Create New Key-> JSON。下载该文件。记下服务账号的 邮箱(格式像
name@project.iam.gserviceaccount.com)。用该邮箱共享 Drive 文件夹:
在 Google Drive 中打开你的文件夹 → 右键 →
Share。粘贴服务账号的邮箱,授予其 查看者 权限。
复制文件夹 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.jsonPowerShell:
[Convert]::ToBase64String([IO.File]::ReadAllBytes("service-account.json"))
3. 部署到 Vercel
选项 A — Vercel + GitHub(推荐)
将此仓库推送到 GitHub。
在 Vercel 中 → Add New → Project → 导入该 GitHub 仓库。
添加环境变量(
DRIVE_FOLDER_ID、GOOGLE_SERVICE_ACCOUNT_KEY)。部署。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 --prod4. 推送到 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 main5. 连接 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"
}
}
}该端点是无状态的,因此每个请求都会创建一个全新的传输——非常适合 serverless 场景。访问权限由 Google Drive 中对该服务账号的共享设置控制。
环境变量
变量 | 必需 | 描述 |
| 是 | Google Drive 文件夹 ID |
| 是 | Base64 编码的服务账号 JSON 密钥 |
This server cannot be deployed
Maintenance
Related MCP Connectors
Streamable HTTP MCP server for Google Calendar and Sheets with OAuth login.
Google Docs MCP Pack — read, create, and edit Google Docs via OAuth.
Give Claude only the Google Drive files you choose. Every action logged.
Notes, files, GitHub, and Drive through one MCP connection.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceA 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 npm2-
- FlicenseNot gradedqualityDmaintenanceEnables 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.-
- FlicenseNot gradedqualityBmaintenanceA 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.-
- FlicenseNot gradedqualityCmaintenanceEnables 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.-