Google Drive MCP Server

Google Drive MCP Server

site icon
2025.04.19 2
PythonGoogle Drive 接口文件管理服务文件管理
gdrive-mcp-server 是一个提供 MCP(Machine Control Protocol)接口的服务,用于与 Google Drive 的文件和文件夹进行交互。它支持文件搜索、获取文件内容和元数据,并通过 OAuth 认证进行安全访问。该服务支持 HTTP 和 stdio 两种传输模式,适用于需要自动化管理 Google Drive 内容的场景。
View on GitHub

Overview

基本能力

产品定位

gdrive-mcp-server 是一个中间件服务,旨在通过标准化的 MCP 协议为 Google Drive 提供程序化访问接口。

核心功能

  • Google Drive 文件搜索
  • 文件内容和元数据获取
  • 支持 OAuth 认证并持久化令牌
  • 提供 HTTP 和 stdio 两种传输模式

适用场景

  • 自动化处理 Google Drive 文件
  • 集成 Google Drive 功能到其他应用程序
  • 批量管理云端文件
  • 开发需要访问 Google Drive 的桌面应用

工具列表

  • gdrive-mcp:主服务程序,提供两种运行模式
  • auth_setup:认证设置工具,用于初始化 OAuth 流程

常见问题

  1. 认证失败:确保 credentials.json 文件正确配置
  2. 权限问题:检查 Google Drive API 是否已启用
  3. 版本兼容:需要 Python 3.12 或更高版本

使用教程

使用依赖

  • Python 3.12+
  • Google Drive API 凭证

安装教程

  1. 创建虚拟环境:
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
  1. 安装包:
pip install -e .
  1. 设置 Google Drive API 凭证:
  2. 访问 Google Cloud Console
  3. 创建/选择项目并启用 Google Drive API
  4. 创建 OAuth 客户端 ID(选择"桌面应用"类型)
  5. 下载凭证文件保存为 credentials.json

  6. 设置认证:

python -m gdrive_mcp_server.auth_setup --credentials /path/to/credentials.json --token /path/to/tokens.json

调试方式

运行服务:

# 标准模式
gdrive-mcp

# HTTP 模式
gdrive-mcp --http

检查日志输出确认服务正常运行,使用 --verbose 参数获取详细日志(如果支持)。

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。