Google Drive MCP 服务器
强大的模型上下文协议 (MCP) 服务器,可与 Google Drive 无缝集成,让 AI 模型能够从 Google Drive 搜索、列出和读取文件。
🚀 功能
工具
1. gdrive_search
使用强大的全文搜索功能在您的 Google Drive 中搜索文件。
输入:
{ "query": "string (your search query)" }输出:文件列表,内容如下:
文件名
MIME 类型
文件 ID
上次修改时间
文件大小
2. gdrive_read_file
使用 Google Drive 文件 ID 直接读取文件内容。
输入:
{ "file_id": "string (Google Drive file ID)" }输出:经过适当格式转换的文件内容
自动文件格式处理
服务器智能地处理不同的 Google Workspace 文件类型:
📝 Google 文档 → Markdown
📊 Google 表格 → CSV
📊 Google 演示文稿 → 纯文本
🎨 Google 绘图 → PNG
📄 文本/JSON 文件 → UTF-8 文本
📦 其他文件 → Base64 编码
🛠️ 入门
先决条件
Node.js(v16 或更高版本)
npm 或 yarn
Google Cloud 项目
Google Workspace 或个人 Google 帐号
详细的 Google Cloud 设置
创建 Google Cloud 项目
点击“新建项目”
输入项目名称(例如“MCP GDrive Server”)
点击“创建”
等待项目创建并选择它
启用 Google Drive API
前往API 库
搜索“Google Drive API”
点击“Google Drive API”
点击“启用”
等待 API 启用
配置 OAuth 同意屏幕
导航至OAuth 同意屏幕
选择用户类型:
如果您使用的是 Google Workspace,则为“内部”
个人 Google 帐户的“外部”
点击“创建”
填写必填字段:
应用程序名称:“MCP GDrive 服务器”
用户支持电子邮件:您的电子邮件
开发者联系邮箱:您的邮箱
点击“保存并继续”
在“范围”页面上:
点击“添加或删除范围”
添加
https://www.googleapis.com/auth/drive.readonly
点击“更新”
点击“保存并继续”
查看摘要并点击“返回仪表板”
创建 OAuth 客户端 ID
前往凭证
点击顶部的“创建凭证”
选择“OAuth 客户端 ID”
选择应用程序类型:“桌面应用程序”
名称:“MCP GDrive 服务器桌面客户端”
点击“创建”
在弹出窗口中:
点击“下载 JSON”
保存文件
点击“确定”
在项目中设置凭据
# Create credentials directory mkdir credentials # Move and rename the downloaded JSON file mv path/to/downloaded/client_secret_*.json credentials/gcp-oauth.keys.json
安装
验证
创建凭证目录并放置您的 OAuth 密钥:
mkdir credentials # Move your downloaded OAuth JSON file to the credentials directory as gcp-oauth.keys.json运行身份验证命令:
node dist/index.js auth在浏览器中完成 OAuth 流程
凭证将保存在
credentials/.gdrive-server-credentials.json
🔧 使用方法
作为命令行工具
与桌面应用程序集成
将此配置添加到您的应用程序的服务器设置中:
将path/to/gdrive-mcp-server
替换为安装目录的实际路径。
示例用法
搜索文件:
// Search for documents containing "quarterly report" const result = await gdrive_search({ query: "quarterly report" });读取文件内容:
// Read a specific file using its ID const contents = await gdrive_read_file({ file_id: "your-file-id" });
🔒 安全
所有敏感凭证都存储在
credentials
目录中OAuth 凭据和令牌被排除在版本控制之外
对 Google Drive 的只读访问权限
安全 OAuth 2.0 身份验证流程
🤝 贡献
欢迎贡献代码!欢迎提交 Pull 请求。
📝 许可证
此 MCP 服务器采用 MIT 许可证。详情请参阅许可证文件。
🔍 故障排除
如果您遇到问题:
验证您的 Google Cloud 项目设置
确保所有必需的 OAuth 范围都已启用
检查凭证是否正确放置在
credentials
目录中验证 Google Drive 中的文件权限和访问权限
📚 其他资源
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
支持与 Google Drive 集成以列出、读取和搜索文件,支持各种文件类型并自动导出 Google Workspace 文件。
Related Resources
Related MCP Servers
- -securityAlicense-qualityThis MCP server integrates with Google Drive to allow listing, reading, and searching over files.Last updated -63470,373MIT License
- -securityAlicense-qualityIntegrates with Google Tasks to allow listing, reading, searching, creating, updating, and deleting tasks.Last updated -87MIT License
- -securityAlicense-qualityIntegrates with Google Drive to enable listing, searching, and reading files, plus reading and writing to Google Sheets.Last updated -130210MIT License
- -securityFlicense-qualityIntegrates with Google Drive to enable listing, reading, and searching over files, with automatic export of Google Workspace documents to appropriate formats.Last updated -634