Google Drive MCP Server

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Enables searching, listing, and reading files stored in Google Drive, with automatic export of Google Workspace files to formats like Markdown and CSV.

  • Provides tools for reading data from Google Spreadsheets with flexible range options, and updating cell values with specified content.

Google Drive 服务器

该 MCP 服务器与 Google Drive 集成,允许列出、读取和搜索文件,以及读取和写入 Google Sheets 的能力。

该项目包含最初由 Anthropic、PBC 开发的代码,根据此 repo的 MIT 许可证获得许可。

成分

工具

  • gdrive_search
    • 描述:在 Google Drive 中搜索文件。
    • 输入
      • query (字符串):搜索查询。
      • pageToken (字符串,可选):下一页结果的令牌。
      • pageSize (数字,可选):每页的结果数(最多 100)。
    • 输出:返回匹配文件的文件名和 MIME 类型。
  • gdrive_read_file
    • 描述:从 Google Drive 读取文件内容。
    • 输入
      • fileId (字符串):要读取的文件的 ID。
    • 输出:返回指定文件的内容。
  • gsheets_read
    • 描述:从 Google 电子表格中读取数据,并提供灵活的范围和格式选项。
    • 输入
      • spreadsheetId (字符串):要读取的电子表格的 ID。
      • ranges (字符串数组,可选):可选的 A1 符号范围数组(例如, ['Sheet1!A1:B10'] )。如果未提供,则读取整个工作表。
      • sheetId (数字,可选):需要读取的具体工作表 ID。如果未指定范围,则读取第一个工作表。
    • 输出:从电子表格返回指定的数据。
  • gsheets_update_cell
    • 描述:更新 Google 电子表格中的单元格值。
    • 输入
      • fileId (字符串):电子表格的 ID。
      • range (字符串):A1 格式的单元格范围(例如, 'Sheet1!A1' )。
      • value (字符串):新的单元格值。
    • 输出:确认指定单元格中的更新值。

资源

该服务器提供对 Google Drive 文件的访问:

  • 文件gdrive:///<file_id>
    • 支持所有文件类型
    • Google Workspace 文件会自动导出:
      • 文档 → Markdown
      • 表格 → CSV
      • 演示文稿 → 纯文本
      • 图纸 → PNG
    • 其他文件以其原始格式提供

入门

  1. 创建新的 Google Cloud 项目
  2. 启用 Google Drive API
  3. 配置 OAuth 同意屏幕(“内部”适合测试)
  4. 添加 OAuth 范围https://www.googleapis.com/auth/drive.readonlyhttps://www.googleapis.com/auth/spreadsheets
  5. 为应用程序类型“桌面应用程序”创建 OAuth 客户端 ID
  6. 下载客户端 OAuth 密钥的 JSON 文件
  7. 将密钥文件重命名为gcp-oauth.keys.json并将其放入使用GDRIVE_CREDS_DIR指定的路径(即/Users/username/.config/mcp-gdrive
  8. 记下您的 OAuth 客户端 ID 和客户端密钥。它们必须与您的配置目录一起作为环境变量提供。

确保使用npm run buildnpm run watch构建服务器。

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 drive-mcp:

npx -y @smithery/cli install @rishipradeep-think41/drive-mcp --client claude

验证

在向 Google API 发出请求之前,系统会提示您使用浏览器进行身份验证。您必须使用与您的 Google Cloud 项目位于同一组织的帐号进行身份验证。

您的 OAuth 令牌保存在GDRIVE_CREDS_DIR环境变量指定的目录中。

与桌面应用程序一起使用

要将此服务器与桌面应用程序集成,请将以下内容添加到应用程序的服务器配置中:

{ "mcpServers": { "gdrive": { "command": "npx", "args": [ "-y", "@isaacphi/mcp-gdrive" ], "env": { "CLIENT_ID": "<CLIENT_ID>", "CLIENT_SECRET": "<CLIENT_SECRET>", "GDRIVE_CREDS_DIR": "/path/to/config/directory" } } } }

执照

此 MCP 服务器采用 MIT 许可证。这意味着您可以自由使用、修改和分发该软件,但须遵守 MIT 许可证的条款和条件。更多详情,请参阅项目仓库中的 LICENSE 文件。

-
security - not tested
A
license - permissive license
-
quality - not tested

该 MCP 服务器与 Google Drive 集成,允许列出、读取和搜索文件,以及读取和写入 Google Sheets 的能力。

  1. Components
    1. Tools
    2. Resources
  2. Getting started
    1. Installing via Smithery
    2. Authentication
    3. Usage with Desktop App
  3. License
    ID: rk0rlndzto