mcpField
G
google-drive

google-drive

github.com/sanjay3290生产力447857 次安装7 周前更新
代码仓库

关于 google-drive

google-drive 是通过独立 OAuth 认证操作 Google Drive 文件的 Skill,无需 MCP 服务。它面向 Google Workspace 账号,支持搜索、下载普通文件和上传文件。

主要功能

  1. 01独立 OAuth 登录与令牌刷新
  2. 02全文及标题文件搜索
  3. 03按 URL、文件夹 ID 或原生查询搜索
  4. 04向 Drive 文件夹上传文件
  5. 05使用系统密钥环安全保存令牌

适用场景

  1. 01按名称或内容查找文件
  2. 02将报告上传到 Drive
  3. 03查看文件夹中的文件
  4. 04通过脚本访问 Drive 文件

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/sanjay3290/ai-skills --skill google-drive

安装后在 Claude Code 中输入/google-drive确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

README.md
requirements.txt
scripts/
auth.py
drive.py
requirements.txt

详细介绍

Google Drive

轻量级 Google Drive 集成,支持独立 OAuth 身份验证。无需 MCP 服务。拥有完整的读写权限。

需要 Google Workspace 账号。 不支持个人 Gmail 账号。

首次设置

使用 Google 进行身份验证(打开浏览器):

python scripts/auth.py login

检查身份验证状态:

python scripts/auth.py status

需要时退出登录:

python scripts/auth.py logout

读取命令

所有操作都通过 scripts/drive.py 执行。如果尚未登录,首次使用时会自动进行身份验证。

# Search for files (full-text search)
python scripts/drive.py search "quarterly report"

# Search by title only
python scripts/drive.py search "title:budget"

# Search using Google Drive URL (extracts ID automatically)
python scripts/drive.py search "https://drive.google.com/drive/folders/1ABC123..."

# Search files shared with you
python scripts/drive.py search --shared-with-me

# Search with pagination
python scripts/drive.py search "report" --limit 5 --page-token "..."

# Find a folder by exact name
python scripts/drive.py find-folder "Project Documents"

# List files in root Drive
python scripts/drive.py list

# List files in a specific folder
python scripts/drive.py list 1ABC123xyz --limit 20

# Download a file
python scripts/drive.py download 1ABC123xyz ./downloads/report.pdf

写入命令

# Upload a file to Drive root
python scripts/drive.py upload ~/Documents/report.pdf

# Upload to a specific folder
python scripts/drive.py upload ~/Documents/report.pdf --folder 1ABC123xyz

# Upload with a custom name
python scripts/drive.py upload ~/Documents/report.pdf --name "Q4 Report.pdf"

# Create a new folder
python scripts/drive.py create-folder "Project Documents"

# Create a folder inside another folder
python scripts/drive.py create-folder "Attachments" --parent 1ABC123xyz

# Move a file to a different folder
python scripts/drive.py move FILE_ID DESTINATION_FOLDER_ID

# Copy a file
python scripts/drive.py copy FILE_ID
python scripts/drive.py copy FILE_ID --name "Report Copy" --folder 1ABC123xyz

# Rename a file or folder
python scripts/drive.py rename FILE_ID "New Name.pdf"

# Move a file to trash
python scripts/drive.py trash FILE_ID

搜索查询格式

搜索命令支持多种查询格式:

格式示例说明
全文"quarterly report"搜索文件内容和名称
标题"title:budget"仅搜索文件名称
URLhttps://drive.google.com/...提取并使用文件/文件夹 ID
文件夹 ID1ABC123...列出文件夹内容(长度为 25 位以上的 ID)
原生查询mimeType='application/pdf'直接传递 Drive 查询语法

文件 ID 格式

Google Drive 使用较长的 ID,例如 1ABC123xyz_-abc123。可从以下位置获取 ID:

  • search 结果
  • find-folder 结果
  • list 结果
  • Google Drive URL

下载限制

  • 常规文件(PDF、图片等)可直接下载
  • 无法通过此工具下载 Google Docs/Sheets/Slides
  • 对于 Google Workspace 文件,请使用导出功能或专用工具

令牌管理

令牌使用系统密钥环安全存储:

  • macOS:Keychain
  • Windows:Windows Credential Locker
  • Linux:Secret Service API(GNOME Keyring、KDE Wallet 等)

服务名称:google-drive-skill-oauth

使用 Google 的云函数自动刷新过期令牌。

评论

支持 Markdown