Google Drive MCP Server

Google Drive 服务器

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

成分

工具

  • 搜索
    • 在 Google Drive 中搜索文件
    • 输入: query (字符串):搜索查询
    • 返回匹配文件的文件名和 MIME 类型

资源

该服务器提供对 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.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" ] } } }

执照

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

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

与 Google Drive 集成,可列出、阅读和搜索文件,并自动将 Google Workspace 文档导出为适当的格式。

  1. Components
    1. Tools
    2. Resources
  2. Getting started
    1. Authentication
    2. Usage with Desktop App
  3. License
    ID: rg5fk690ll