
用于从 Google Drive 读取和编辑 Google 表格的模型上下文协议(MCP)服务器
概览
该MCP服务器与Google Drive集成,支持列表、阅读和搜索文件,并支持读写Google Sheets。 该项目包含由Anthropic PBC最初开发的代码,依据本仓库的MIT许可证授权。 - : 在 Google 云端硬盘中搜索文件。- : - 查询(字符串):搜索查询。- pageToken(字符串,可选):下一页结果的令牌。- pageSize(数字,可选):每页结果数(最多 100 个)。- : 返回匹配文件的文件名和 MIME 类型。 - : 从 Google Drive 读取文件内容。- : - fileId(字符串):要读取文件的 ID。- : 返回指定文件的内容。 - :从Google电子表格中读取数据,提供灵活的范围和格式选项。- : - SpreadsheetId(字符串):待阅读电子表格的ID。- ranges(字符串数组,可选):可选的A1符号范围数组(例如,['Sheet1!“A1:B10'])。如果未提供,则读取整个表格。
概述(AI 翻译)
该MCP服务器与Google Drive集成,支持列表、阅读和搜索文件,并支持读写Google Sheets。
该项目包含由Anthropic PBC最初开发的代码,依据本仓库的MIT许可证授权。
组成部分
工具
-
gdrive_search
-
描述:在Google Drive中搜索文件。
-
输入:
-
query(字符串):搜索查询。 -
pageToken(字符串,可选):下一页结果的标记。 -
pageSize(编号,可选):每页结果数(最多100页)。 -
输出:返回匹配文件的文件名和MIME类型。
-
gdrive_read_file
-
描述:从Google Drive读取文件内容。
-
输入:
-
fileId(字符串):要读取的文件ID。 -
输出:返回指定文件的内容。
-
gsheets_read
-
描述:从谷歌电子表格中读取数据,提供灵活的范围和格式选项。
-
输入:
-
spreadsheetId(字符串):要读取的电子表格ID。 -
ranges(字符串数组,可选):可选的A1符号范围数组(例如,['Sheet1!A1:B10'])。如果未提供,则读取整张图。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Google Drive server
This MCP server integrates with Google Drive to allow listing, reading, and searching files, as well as the ability to read and write to Google Sheets.
This project includes code originally developed by Anthropic, PBC, licensed under the MIT License from this repo.
Components
Tools
-
gdrive_search
- Description: Search for files in Google Drive.
- Input:
query(string): Search query.pageToken(string, optional): Token for the next page of results.pageSize(number, optional): Number of results per page (max 100).
- Output: Returns file names and MIME types of matching files.
-
gdrive_read_file
- Description: Read contents of a file from Google Drive.
- Input:
fileId(string): ID of the file to read.
- Output: Returns the contents of the specified file.
-
gsheets_read
- Description: Read data from a Google Spreadsheet with flexible options for ranges and formatting.
- Input:
spreadsheetId(string): The ID of the spreadsheet to read.ranges(array of strings, optional): Optional array of A1 notation ranges (e.g.,['Sheet1!A1:B10']). If not provided, reads the entire sheet.sheetId(number, optional): Specific sheet ID to read. If not provided with ranges, reads the first sheet.
- Output: Returns the specified data from the spreadsheet.
-
gsheets_update_cell
- Description: Update a cell value in a Google Spreadsheet.
- Input:
fileId(string): ID of the spreadsheet.range(string): Cell range in A1 notation (e.g.,'Sheet1!A1').value(string): New cell value.
- Output: Confirms the updated value in the specified cell.
Resources
The server provides access to Google Drive files:
- Files (
gdrive:///)- Supports all file types
- Google Workspace files are automatically exported:
- Docs → Markdown
- Sheets → CSV
- Presentations → Plain text
- Drawings → PNG
- Other files are provided in their native format
Getting started
- Create a new Google Cloud project
- Enable the Google Drive API
- Configure an OAuth consent screen (“internal” is fine for testing)
- Add OAuth scopes
https://www.googleapis.com/auth/drive.readonly,https://www.googleapis.com/auth/spreadsheets - In order to allow interaction with sheets and docs you will also need to enable the Google Sheets API and Google Docs API in your workspaces Enabled API and Services section.
安装
npx -y @isaacphi/mcp-gdrive配置
{
"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"
}
}
}
}