google-drive-automation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGoogle Drive Automation via Rube MCP
通过Rube MCP实现Google Drive自动化
Automate Google Drive workflows including file upload/download, search, folder management, sharing/permissions, and organization through Composio's Google Drive toolkit.
通过Composio的Google Drive工具包,自动化Google Drive工作流,包括文件上传/下载、搜索、文件夹管理、分享/权限设置以及文件整理。
Prerequisites
前提条件
- Rube MCP must be connected (RUBE_SEARCH_TOOLS available)
- Active Google Drive connection via with toolkit
RUBE_MANAGE_CONNECTIONSgoogledrive - Always call first to get current tool schemas
RUBE_SEARCH_TOOLS
- 必须已连接Rube MCP(可使用RUBE_SEARCH_TOOLS)
- 通过工具包
RUBE_MANAGE_CONNECTIONS建立有效的Google Drive连接googledrive - 请始终先调用以获取当前工具架构
RUBE_SEARCH_TOOLS
Setup
设置步骤
Get Rube MCP: Add as an MCP server in your client configuration. No API keys needed — just add the endpoint and it works.
https://rube.app/mcp- Verify Rube MCP is available by confirming responds
RUBE_SEARCH_TOOLS - Call with toolkit
RUBE_MANAGE_CONNECTIONSgoogledrive - If connection is not ACTIVE, follow the returned auth link to complete Google OAuth
- Confirm connection status shows ACTIVE before running any workflows
获取Rube MCP:在客户端配置中添加作为MCP服务器。无需API密钥,只需添加端点即可使用。
https://rube.app/mcp- 确认可正常响应,以此验证Rube MCP是否可用
RUBE_SEARCH_TOOLS - 调用并指定工具包
RUBE_MANAGE_CONNECTIONSgoogledrive - 如果连接状态未显示为ACTIVE,请按照返回的授权链接完成Google OAuth认证
- 在运行任何工作流之前,确认连接状态显示为ACTIVE
Core Workflows
核心工作流
1. Upload and Download Files
1. 文件上传与下载
When to use: User wants to upload files to or download files from Google Drive
Tool sequence:
- - Locate target folder for upload [Prerequisite]
GOOGLEDRIVE_FIND_FILE - - Upload a file (max 5MB) [Required]
GOOGLEDRIVE_UPLOAD_FILE - - Upload large files [Fallback]
GOOGLEDRIVE_RESUMABLE_UPLOAD - - Download a file by ID [Required]
GOOGLEDRIVE_DOWNLOAD_FILE - - Track long-running downloads [Fallback]
GOOGLEDRIVE_DOWNLOAD_FILE_OPERATION - - Verify file after upload/download [Optional]
GOOGLEDRIVE_GET_FILE_METADATA
Key parameters:
- : Object with
file_to_upload,name, andmimetype(file must be in internal storage)s3key - : Target folder ID (optional; uploads to root if omitted)
folder_to_upload_to - : ID of file to download
file_id - : Export format for Google Workspace files only (omit for native files)
mime_type
Pitfalls:
- requires
GOOGLEDRIVE_UPLOAD_FILE; files must already be in internal storagefile_to_upload.s3key - For non-Google formats (Excel, PDF), do NOT set ; it causes errors for native files
mime_type - Download responses provide a temporary URL at , not inline bytes
data.downloaded_file_content.s3url - Use for files >5MB or when basic uploads fail
GOOGLEDRIVE_RESUMABLE_UPLOAD
适用场景:用户需要上传文件至Google Drive或从Google Drive下载文件
工具执行顺序:
- - 定位用于上传的目标文件夹 [前置步骤]
GOOGLEDRIVE_FIND_FILE - - 上传文件(最大5MB) [必需步骤]
GOOGLEDRIVE_UPLOAD_FILE - - 上传大文件 [备选方案]
GOOGLEDRIVE_RESUMABLE_UPLOAD - - 通过文件ID下载文件 [必需步骤]
GOOGLEDRIVE_DOWNLOAD_FILE - - 跟踪长时间运行的下载任务 [备选方案]
GOOGLEDRIVE_DOWNLOAD_FILE_OPERATION - - 上传/下载后验证文件 [可选步骤]
GOOGLEDRIVE_GET_FILE_METADATA
关键参数:
- : 包含
file_to_upload、name和mimetype的对象(文件必须已存储在内部存储中)s3key - : 目标文件夹ID(可选;若省略则上传至根目录)
folder_to_upload_to - : 待下载文件的ID
file_id - : 仅针对Google Workspace文件的导出格式(原生文件请省略)
mime_type
注意事项:
- 需要
GOOGLEDRIVE_UPLOAD_FILE;文件必须已存在于内部存储中file_to_upload.s3key - 对于非Google格式(如Excel、PDF),请勿设置;这会导致原生文件出现错误
mime_type - 下载响应会在提供临时URL,而非内联字节数据
data.downloaded_file_content.s3url - 对于大于5MB的文件或基础上传失败时,请使用
GOOGLEDRIVE_RESUMABLE_UPLOAD
2. Search and List Files
2. 文件搜索与列出
When to use: User wants to find specific files or browse Drive contents
Tool sequence:
- - Search by name, content, type, date, or folder [Required]
GOOGLEDRIVE_FIND_FILE - - Browse files with folder scoping [Alternative]
GOOGLEDRIVE_LIST_FILES - - Enumerate shared drives [Optional]
GOOGLEDRIVE_LIST_SHARED_DRIVES - - Get detailed file info [Optional]
GOOGLEDRIVE_GET_FILE_METADATA - - Check storage quota and supported formats [Optional]
GOOGLEDRIVE_GET_ABOUT
Key parameters:
- : Drive query string (e.g., "name contains 'report'", "mimeType = 'application/pdf'")
q - : Search scope ('user', 'domain', 'drive', 'allDrives')
corpora - : Response fields to include (e.g., 'files(id,name,mimeType)')
fields - : Sort key ('modifiedTime desc', 'name', 'quotaBytesUsed desc')
orderBy - : Results per page (max 1000)
pageSize - : Pagination cursor from
pageTokennextPageToken - : Scope search to a specific folder
folder_id
Pitfalls:
- 403 PERMISSION_DENIED if OAuth scopes insufficient for shared drives
- Pagination required; files are in ; follow
response.data.filesuntil exhaustednextPageToken - may trigger 400; try
corpora="domain"with"allDrives"includeItemsFromAllDrives=true - Query complexity limits: >5-10 OR clauses may error "The query is too complex"
- Wildcards (*) NOT supported in ; use
namefor partial matchingcontains - 'My Drive' is NOT searchable by name; use for root folder
folder_id='root' - User email searches: use (NOT
'user@example.com' in owners)owner:user@example.com
适用场景:用户需要查找特定文件或浏览Drive内容
工具执行顺序:
- - 按名称、内容、类型、日期或文件夹搜索 [必需步骤]
GOOGLEDRIVE_FIND_FILE - - 按文件夹范围浏览文件 [备选方案]
GOOGLEDRIVE_LIST_FILES - - 枚举共享驱动器 [可选步骤]
GOOGLEDRIVE_LIST_SHARED_DRIVES - - 获取文件详细信息 [可选步骤]
GOOGLEDRIVE_GET_FILE_METADATA - - 查看存储配额和支持的格式 [可选步骤]
GOOGLEDRIVE_GET_ABOUT
关键参数:
- : Drive查询字符串(例如:"name contains 'report'"、"mimeType = 'application/pdf'")
q - : 搜索范围('user'、'domain'、'drive'、'allDrives')
corpora - : 响应中包含的字段(例如:'files(id,name,mimeType)')
fields - : 排序键('modifiedTime desc'、'name'、'quotaBytesUsed desc')
orderBy - : 每页结果数量(最大1000)
pageSize - : 来自
pageToken的分页游标nextPageToken - : 将搜索范围限定到特定文件夹
folder_id
注意事项:
- 如果OAuth权限不足,访问共享驱动器会返回403 PERMISSION_DENIED错误
- 需要分页处理;文件位于中;需跟随
response.data.files直到无更多结果nextPageToken - 使用可能触发400错误;尝试使用
corpora="domain"并设置"allDrives"includeItemsFromAllDrives=true - 查询复杂度限制:超过5-10个OR子句可能会报错“查询过于复杂”
- 名称搜索不支持通配符(*);请使用进行部分匹配
contains - 无法通过名称搜索“我的云端硬盘”;请使用指定根文件夹
folder_id='root' - 用户邮箱搜索:使用(而非
'user@example.com' in owners)owner:user@example.com
3. Share Files and Manage Permissions
3. 文件分享与权限管理
When to use: User wants to share files or manage access permissions
Tool sequence:
- - Locate the file to share [Prerequisite]
GOOGLEDRIVE_FIND_FILE - - Set sharing permission [Required]
GOOGLEDRIVE_ADD_FILE_SHARING_PREFERENCE - - View current permissions [Optional]
GOOGLEDRIVE_LIST_PERMISSIONS - - Inspect a specific permission [Optional]
GOOGLEDRIVE_GET_PERMISSION - - Modify existing permission [Optional]
GOOGLEDRIVE_UPDATE_PERMISSION - - Revoke access [Optional]
GOOGLEDRIVE_DELETE_PERMISSION
Key parameters:
- : ID of file to share
file_id - : 'user', 'group', 'domain', or 'anyone'
type - : 'owner', 'organizer', 'fileOrganizer', 'writer', 'commenter', 'reader'
role - : Required for type='user' or 'group'
email_address - : Required for type='domain'
domain - : Required when role='owner'
transfer_ownership
Pitfalls:
- Invalid type/email combinations trigger 4xx errors
- Using or powerful roles is risky; get explicit user confirmation
type='anyone' - Org policies may block certain sharing types, causing 403
- Permission changes may take time to propagate
- Use to resolve contact names to emails before sharing
GMAIL_SEARCH_PEOPLE
适用场景:用户需要分享文件或管理访问权限
工具执行顺序:
- - 定位待分享的文件 [前置步骤]
GOOGLEDRIVE_FIND_FILE - - 设置分享权限 [必需步骤]
GOOGLEDRIVE_ADD_FILE_SHARING_PREFERENCE - - 查看当前权限 [可选步骤]
GOOGLEDRIVE_LIST_PERMISSIONS - - 检查特定权限详情 [可选步骤]
GOOGLEDRIVE_GET_PERMISSION - - 修改现有权限 [可选步骤]
GOOGLEDRIVE_UPDATE_PERMISSION - - 撤销访问权限 [可选步骤]
GOOGLEDRIVE_DELETE_PERMISSION
关键参数:
- : 待分享文件的ID
file_id - : 'user'、'group'、'domain'或'anyone'
type - : 'owner'、'organizer'、'fileOrganizer'、'writer'、'commenter'、'reader'
role - : 当type='user'或'group'时为必填项
email_address - : 当type='domain'时为必填项
domain - : 当role='owner'时为必填项
transfer_ownership
注意事项:
- 无效的type/email组合会触发4xx错误
- 使用或高权限角色存在风险;请获取用户明确确认
type='anyone' - 组织策略可能会阻止某些分享类型,导致403错误
- 权限变更可能需要时间才能生效
- 分享前请使用将联系人姓名解析为邮箱
GMAIL_SEARCH_PEOPLE
4. Create and Organize Folders
4. 文件夹创建与整理
When to use: User wants to create folder structures or move files between folders
Tool sequence:
- - Check if folder already exists [Prerequisite]
GOOGLEDRIVE_FIND_FILE - - Create a new folder [Required]
GOOGLEDRIVE_CREATE_FOLDER - - Verify created folder [Optional]
GOOGLEDRIVE_GET_FILE_METADATA - - Move files between folders [Optional]
GOOGLEDRIVE_MOVE_FILE - - Update file metadata/parents [Alternative]
GOOGLEDRIVE_UPDATE_FILE_PUT
Key parameters:
- : Folder name
name - : Parent folder ID (NOT name); omit for root
parent_id - : File to move
file_id - : Destination folder ID for move
add_parents - : Source folder ID to remove from
remove_parents
Pitfalls:
- requires
GOOGLEDRIVE_CREATE_FOLDERas an ID, not a folder nameparent_id - Using creates at top level; for nested paths, chain folder IDs
parent_id="root" - returns ~100 items/page; follow
GOOGLEDRIVE_FIND_FILEfor large drivesnextPageToken - Move operations can leave items with multiple parents; use for true moves
remove_parents - Always verify parent folder exists before creating children
适用场景:用户需要创建文件夹结构或在文件夹之间移动文件
工具执行顺序:
- - 检查文件夹是否已存在 [前置步骤]
GOOGLEDRIVE_FIND_FILE - - 创建新文件夹 [必需步骤]
GOOGLEDRIVE_CREATE_FOLDER - - 验证已创建的文件夹 [可选步骤]
GOOGLEDRIVE_GET_FILE_METADATA - - 在文件夹之间移动文件 [可选步骤]
GOOGLEDRIVE_MOVE_FILE - - 更新文件元数据/父文件夹 [备选方案]
GOOGLEDRIVE_UPDATE_FILE_PUT
关键参数:
- : 文件夹名称
name - : 父文件夹ID(而非名称);若省略则创建在根目录
parent_id - : 待移动的文件
file_id - : 移动目标文件夹的ID
add_parents - : 要移除的源文件夹ID
remove_parents
注意事项:
- 要求
GOOGLEDRIVE_CREATE_FOLDER为ID,而非文件夹名称parent_id - 使用会在顶层创建文件夹;对于嵌套路径,请链式传递文件夹ID
parent_id="root" - 每页返回约100条结果;对于大型驱动器,请跟随
GOOGLEDRIVE_FIND_FILE获取全部结果nextPageToken - 移动操作可能会让文件保留多个父文件夹;请使用实现真正的移动
remove_parents - 创建子文件夹前,请始终验证父文件夹是否存在
Common Patterns
通用模式
ID Resolution
ID解析
- File/folder name -> ID: with
GOOGLEDRIVE_FIND_FILEparameterq - Root folder: Use or
folder_id='root''root' in parents - Shared drive -> driveId:
GOOGLEDRIVE_LIST_SHARED_DRIVES - Contact name -> email: (for sharing)
GMAIL_SEARCH_PEOPLE
- 文件/文件夹名称 -> ID:使用带参数的
qGOOGLEDRIVE_FIND_FILE - 根文件夹:使用或
folder_id='root''root' in parents - 共享驱动器 -> driveId:使用
GOOGLEDRIVE_LIST_SHARED_DRIVES - 联系人姓名 -> 邮箱:使用(用于分享场景)
GMAIL_SEARCH_PEOPLE
Query Syntax
查询语法
Google Drive uses a specific query language:
- Name search: or
"name contains 'report'""name = 'exact.pdf'" - Type filter: or
"mimeType = 'application/pdf'""mimeType = 'application/vnd.google-apps.folder'" - Folder scoping:
"'FOLDER_ID' in parents" - Date filter:
"modifiedTime > '2024-01-01T00:00:00'" - Combine with /
and/or:not"name contains 'report' and trashed = false" - Boolean filters: ,
"sharedWithMe = true","starred = true""trashed = false"
Google Drive使用特定的查询语言:
- 名称搜索:或
"name contains 'report'""name = 'exact.pdf'" - 类型筛选:或
"mimeType = 'application/pdf'""mimeType = 'application/vnd.google-apps.folder'" - 文件夹范围:
"'FOLDER_ID' in parents" - 日期筛选:
"modifiedTime > '2024-01-01T00:00:00'" - 使用/
and/or组合:not"name contains 'report' and trashed = false" - 布尔筛选:、
"sharedWithMe = true"、"starred = true""trashed = false"
Pagination
分页处理
- Follow until absent for complete results
nextPageToken - Set explicitly (default 100, max 1000)
pageSize - De-duplicate results if running multiple searches
- 跟随直到不存在,以获取完整结果
nextPageToken - 显式设置(默认100,最大1000)
pageSize - 若执行多次搜索,请对结果进行去重
Export Formats
导出格式
For Google Workspace files, set to export:
mime_type- Docs: ,
application/pdf,text/plain,text/htmlapplication/vnd.openxmlformats-officedocument.wordprocessingml.document - Sheets: ,
text/csvapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet - Slides: ,
application/pdfapplication/vnd.openxmlformats-officedocument.presentationml.presentation
对于Google Workspace文件,请设置以指定导出格式:
mime_type- 文档:、
application/pdf、text/plain、text/htmlapplication/vnd.openxmlformats-officedocument.wordprocessingml.document - 表格:、
text/csvapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet - 幻灯片:、
application/pdfapplication/vnd.openxmlformats-officedocument.presentationml.presentation
Known Pitfalls
已知注意事项
- Internal storage required: Upload requires files in internal S3 storage (s3key)
- Export vs download: Set ONLY for Google Workspace files; omit for native files
mime_type - Temporary URLs: Downloaded content via is temporary; fetch promptly
s3url - Query complexity: >5-10 OR clauses may error; split complex searches into multiple queries
- Shared drive scoping: Missing drive permissions yield empty results; verify access first
- No wildcards: Use operator instead of
containsfor partial name matching* - Folder creation chains: Always pass folder IDs (not names) as
parent_id - Multiple parents: Move operations may leave items with multiple parents; use
remove_parents - Rate limits: Heavy searches/exports can trigger 403/429; implement backoff
- 需要内部存储:上传要求文件已存储在内部S3存储中(需提供s3key)
- 导出与下载的区别:仅对Google Workspace文件设置;原生文件请省略
mime_type - 临时URL:通过获取的下载内容是临时的;请及时获取
s3url - 查询复杂度:超过5-10个OR子句可能会报错;请将复杂查询拆分为多个查询
- 共享驱动器范围:缺少驱动器权限会返回空结果;请先验证访问权限
- 无通配符:请使用运算符代替
contains进行名称部分匹配* - 文件夹创建链式操作:请始终传递文件夹ID(而非名称)作为
parent_id - 多父文件夹:移动操作可能会让文件保留多个父文件夹;请使用
remove_parents - 速率限制:频繁的搜索/导出操作可能会触发403/429错误;请实现退避机制
Quick Reference
快速参考
| Task | Tool Slug | Key Params |
|---|---|---|
| Search files | | |
| List files | | |
| Upload file | | |
| Resumable upload | | file data |
| Download file | | |
| File metadata | | |
| Create folder | | |
| Move file | | |
| Share file | | |
| List permissions | | |
| Update permission | | file_id, permission_id |
| Delete permission | | file_id, permission_id |
| List shared drives | | |
| Drive info | | (none) |
| Create shortcut | | target file_id |
| 任务 | 工具标识 | 关键参数 |
|---|---|---|
| 搜索文件 | | |
| 列出文件 | | |
| 上传文件 | | |
| 可恢复上传 | | 文件数据 |
| 下载文件 | | |
| 文件元数据 | | |
| 创建文件夹 | | |
| 移动文件 | | |
| 分享文件 | | |
| 列出权限 | | |
| 更新权限 | | file_id, permission_id |
| 删除权限 | | file_id, permission_id |
| 列出共享驱动器 | | |
| 驱动器信息 | | 无 |
| 创建快捷方式 | | target file_id |