# 谷歌云盘表格MCP
## 基本信息
- Slug: `rishipradeep-think41-drive-mcp`
- Source: modelscope
- Publisher: @rishipradeep-think41/drive-mcp
- Categories: cloud-storage / file-systems
- Hosted: No
- License: MIT License
- Source URL: https://www.modelscope.cn/mcp/servers/@rishipradeep-think41/drive-mcp
## 简介
该MCP服务器与Google Drive集成，允许列出、读取和搜索文件，还具有读取和写入Google表格的功能。
## 安装提示

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

## MCP Server 详情

# Google Drive 服务器
[![smithery 徽章](https://smithery.ai/badge/@rishipradeep-think41/drive-mcp)](https://smithery.ai/server/@rishipradeep-think41/drive-mcp)

此 MCP 服务器与 Google Drive 集成，允许列出、读取和搜索文件，并且能够读写 Google Sheets。

该项目包括最初由 Anthropic, PBC 开发的代码，根据 MIT 许可证从 [此仓库](https://github.com/modelcontextprotocol/servers/tree/main/src/gdrive) 获得许可。

## 组件

### 工具

- **gdrive_search**
  - **描述**: 在 Google Drive 中搜索文件。
  - **输入**:
    - `query` (字符串): 搜索查询。
    - `pageToken` (字符串, 可选): 下一页结果的令牌。
    - `pageSize` (数字, 可选): 每页的结果数量（最大 100）。
  - **输出**: 返回匹配文件的文件名和 MIME 类型。

- **gdrive_read_file**
  - **描述**: 从 Google Drive 读取文件内容。
  - **输入**:
    - `fileId` (字符串): 要读取的文件 ID。
  - **输出**: 返回指定文件的内容。

- **gsheets_read**
  - **描述**: 以灵活的范围和格式选项从 Google Spreadsheet 读取数据。
  - **输入**:
    - `spreadsheetId` (字符串): 要读取的电子表格 ID。
    - `ranges` (字符串数组, 可选): A1 格式范围的可选数组（例如，`['Sheet1!A1:B10']`）。如果不提供，则读取整个工作表。
    - `sheetId` (数字, 可选): 要读取的特定工作表 ID。如果未与 ranges 一起提供，则读取第一个工作表。
  - **输出**: 返回电子表格中的指定数据。

- **gsheets_update_cell**
  - **描述**: 更新 Google Spreadsheet 中的单元格值。
  - **输入**:
    - `fileId` (字符串): 电子表格 ID。
    - `range` (字符串): A1 格式的单元格范围（例如，`'Sheet1!A1'`）。
    - `value` (字符串): 新的单元格值。
  - **输出**: 确认已更新指定单元格的值。

### 资源

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

- **文件** (`gdrive:///<file_id>`)
  - 支持所有文件类型
  - Google Workspace 文件会自动导出：
    - 文档 → Markdown
    - 表格 → CSV
    - 演示文稿 → 纯文本
    - 图形 → PNG
  - 其他文件以其原生格式提供

## 开始使用

1. [创建一个新的 Google Cloud 项目](https://console.cloud.google.com/projectcreate)
2. [启用 Google Drive API](https://console.cloud.google.com/workspace-api/products)
3. [配置 OAuth 同意屏幕](https://console.cloud.google.com/apis/credentials/consent)（测试时选择“内部”即可）
4. 添加 OAuth 范围 `https://www.googleapis.com/auth/drive.readonly`, `https://www.googleapis.com/auth/spreadsheets`
5. [为应用程序类型“桌面应用”创建一个 OAuth 客户端 ID](https://console.cloud.google.com/apis/credentials/oauthclient)
6. 下载客户端的 OAuth 密钥 JSON 文件
7. 将密钥文件重命名为 `gcp-oauth.keys.json` 并放置在你通过 `GDRIVE_CREDS_DIR` 指定的路径中（例如 `/Users/username/.config/mcp-gdrive`）
8. 记下你的 OAuth 客户端 ID 和客户端密钥。它们必须与你的配置目录一起作为环境变量提供。

确保使用 `npm run build` 或 `npm run watch` 构建服务器。

### 通过 Smithery 安装

要通过 [Smithery](https://smithery.ai/server/@rishipradeep-think41/drive-mcp) 自动安装 Claude Desktop 的 drive-mcp，请运行：

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


### 身份验证

在向 Google 的 API 发出请求之前，系统会提示你使用浏览器进行身份验证。你必须使用与你的 Google Cloud 项目相同的组织中的账户进行身份验证。

你的 OAuth 令牌将保存在由 `GDRIVE_CREDS_DIR` 环境变量指定的目录中。

### 与桌面应用程序配合使用

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

```json
{
  "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 文件。

