Skip to main content
Glama

Google Drive 服务器

该 MCP 服务器与 Google Drive 集成,允许列出、读取和搜索文件。

成分

工具

  • 搜索

    • 在 Google Drive 中搜索文件

    • 输入: query (字符串):搜索查询

    • 返回匹配文件的文件名和 MIME 类型

资源

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

  • 文件gdrive:///<file_id>

    • 支持所有文件类型

    • Google Workspace 文件会自动导出:

      • 文档 → Markdown

      • 表格 → CSV

      • 演示文稿 → 纯文本

      • 图纸 → PNG

    • 其他文件以其原始格式提供

Related MCP server: Google Drive MCP Server

入门

  1. 创建新的 Google Cloud 项目

  2. 启用 Google Drive API

  3. 配置 OAuth 同意屏幕(“内部”适合测试)

  4. 添加 OAuth 范围https://www.googleapis.com/auth/drive.readonly

  5. 为应用程序类型“桌面应用程序”创建 OAuth 客户端 ID

  6. 下载客户端 OAuth 密钥的 JSON 文件

  7. 将密钥文件重命名为gcp-oauth.keys.json并将其放入此 repo 的根目录中(即servers/gcp-oauth.keys.json

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

验证

要验证并保存凭据:

  1. 使用auth参数运行服务器: node ./dist auth

  2. 这将在您的系统浏览器中打开身份验证流程

  3. 完成身份验证过程

  4. 凭证将保存在此 repo 的根目录中(即servers/.gdrive-server-credentials.json

与桌面应用程序一起使用

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

Docker

验证:

假设您已在 Google Cloud 上完成 OAuth 应用程序的设置,您现在可以使用以下命令对服务器进行身份验证,将/path/to/gcp-oauth.keys.json替换为您的 OAuth 密钥文件的路径:

docker run -i --rm --mount type=bind,source=/path/to/gcp-oauth.keys.json,target=/gcp-oauth.keys.json -v mcp-gdrive:/gdrive-server -e GDRIVE_OAUTH_PATH=/gcp-oauth.keys.json -e "GDRIVE_CREDENTIALS_PATH=/gdrive-server/credentials.json" -p 3000:3000 mcp/gdrive auth

该命令将打印出一个 URL,供您在浏览器中打开。在浏览器中打开此 URL 并完成身份验证过程。凭据将保存在mcp-gdrive卷中。

一旦通过身份验证,您就可以在应用程序的服务器配置中使用该服务器:

{ "mcpServers": { "gdrive": { "command": "docker", "args": ["run", "-i", "--rm", "-v", "mcp-gdrive:/gdrive-server", "-e", "GDRIVE_CREDENTIALS_PATH=/gdrive-server/credentials.json", "mcp/gdrive"] } } }

NPX

{ "mcpServers": { "gdrive": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-gdrive" ] } } }

与 VS Code 一起使用

为了快速安装,请使用下面的一键安装按钮之一。

在 VS Code 中使用 NPX 安装 在 VS Code Insiders 中使用 NPX 安装

在 VS Code 中使用 Docker 安装 在 VS Code Insiders 中使用 Docker 安装

如需手动安装,请将以下 JSON 块添加到 VS Code 中的“用户设置 (JSON)”文件中。您可以按下Ctrl + Shift + P并输入Preferences: Open User Settings (JSON)来执行此操作。

或者,您可以将其添加到工作区中名为.vscode/mcp.json的文件中。这样您就可以与其他人共享该配置。

请注意.vscode/mcp.json文件中不需要mcp键。

NPX

{ "mcp": { "servers": { "gdrive": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-gdrive" ], "env": { "GDRIVE_CREDENTIALS_PATH": "/path/to/.gdrive-server-credentials.json" } } } } }

Docker

{ "mcp": { "servers": { "gdrive": { "command": "docker", "args": [ "run", "-i", "--rm", "-v", "mcp-gdrive:/gdrive-server", "-e", "GDRIVE_CREDENTIALS_PATH=/gdrive-server/credentials.json", "mcp/gdrive" ] } } } }

执照

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

-
security - not tested
-
license - not tested
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/modelcontextprotocol/google-drive-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server