mcpField
G
Google Drive MCP Server

Google Drive MCP Server

本地服务
github.com/felores文件与存储7251 周前更新

关于 Google Drive MCP Server

Google Drive MCP 服务让 AI 模型搜索、列出并读取 Google Drive 中的文件。它面向需要将云端文档接入模型上下文的用户。服务器会把 Google Workspace 文件转换为常见格式,并以只读方式访问 Drive。

主要功能

  1. 01按关键词搜索 Google Drive 文件
  2. 02通过文件 ID 读取文件内容
  3. 03Google Docs 转换为 Markdown,Sheets 转换为 CSV
  4. 04其他文件以 Base64 编码返回

适用场景

  1. 01让模型检索并引用云端的报告或文档
  2. 02将表格内容导入模型进行分析
  3. 03在 Agent 工作流中读取 Drive 中的参考资料

MCP 相关

该项目是 MCP 服务,向 MCP 客户端暴露 gdrive_search 与 gdrive_read_file 两个工具。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

Google Drive MCP Server

功能强大的模型上下文协议(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 详细设置
  1. 创建 Google Cloud 项目

    • 访问 Google Cloud Console
    • 点击“New Project”
    • 输入项目名称(例如“MCP GDrive Server”)
    • 点击“Create”
    • 等待项目创建完成并选择该项目
  2. 启用 Google Drive API

    • 前往 API Library
    • 搜索“Google Drive API”
    • 点击“Google Drive API”
    • 点击“Enable”
    • 等待 API 启用
  3. 配置 OAuth 同意屏幕

    • 前往 OAuth 同意屏幕
    • 选择用户类型:
      • 如果使用 Google Workspace,请选择“Internal”
      • 如果使用个人 Google 账号,请选择“External”
    • 点击“Create”
    • 填写必填字段:
      • 应用名称:“MCP GDrive Server”
      • 用户支持邮箱:你的邮箱
      • 开发者联系邮箱:你的邮箱
    • 点击“Save and Continue”
    • 在“Scopes”页面:
      • 点击“Add or Remove Scopes”
      • 添加 https://www.googleapis.com/auth/drive.readonly
      • 点击“Update”
    • 点击“Save and Continue”
    • 查看摘要并点击“Back to Dashboard”
  4. 创建 OAuth 客户端 ID

    • 前往 Credentials
    • 点击顶部的“Create Credentials”
    • 选择“OAuth client ID”
    • 选择应用类型:“Desktop app”
    • 名称:“MCP GDrive Server Desktop Client”
    • 点击“Create”
    • 在弹出窗口中:
      • 点击“Download JSON”
      • 保存文件
      • 点击“OK”
  5. 在项目中设置凭据

    # Create credentials directory
    mkdir credentials
    
    # Move and rename the downloaded JSON file
    mv path/to/downloaded/client_secret_*.json credentials/gcp-oauth.keys.json
    
安装
# Clone the repository
git clone https://github.com/felores/gdrive-mcp-server.git
cd gdrive-mcp-server

# Install dependencies
npm install

# Build the project
npm run build
身份验证
  1. 创建凭据目录并放入 OAuth 密钥:

    mkdir credentials
    # Move your downloaded OAuth JSON file to the credentials directory as gcp-oauth.keys.json
    
  2. 运行身份验证命令:

    node dist/index.js auth
    
  3. 在浏览器中完成 OAuth 流程

  4. 凭据将保存到 credentials/.gdrive-server-credentials.json

🔧 用法

作为命令行工具
# Start the server
node dist/index.js
与桌面应用集成

将此配置添加到应用的服务设置中:

{
  "mcpServers": {
    "gdrive": {
      "command": "node",
      "args": ["path/to/gdrive-mcp-server/dist/index.js"],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "path/to/gdrive-mcp-server/credentials/gcp-oauth.keys.json",
        "MCP_GDRIVE_CREDENTIALS": "path/to/gdrive-mcp-server/credentials/.gdrive-server-credentials.json"
      }
    }
  }
}

将 path/to/gdrive-mcp-server 替换为安装目录的实际路径。

用法示例
  1. 搜索文件:

    // Search for documents containing "quarterly report"
    const result = await gdrive_search({ query: "quarterly report" });
    
  2. 读取文件内容:

    // 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 Request。

📝 许可证

此 MCP 服务采用 MIT 许可证。详情请参阅 LICENSE 文件。

🔍 故障排除

如果遇到问题:

  1. 确认已正确设置 Google Cloud 项目
  2. 确保已启用所有必需的 OAuth 作用域
  3. 检查凭据是否已正确放置在 credentials 目录中
  4. 检查 Google Drive 中的文件权限和访问权限

📚 更多资源

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。