-
Notifications
You must be signed in to change notification settings - Fork 240
feat(drive): Add update_drive_file function with OAuth fixes and comprehensive file management #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Added comprehensive update_drive_file function to modify Google Drive file metadata - Fixed OAuth scope issue by using 'drive_file' instead of non-existent 'drive_write' - Supports moving files, renaming, updating descriptions, managing sharing permissions - Includes support for custom properties and file status (starred/trashed) - Updated README.md and tool_tiers.yaml documentation - Successfully tested with all parameters Fixes taylorwilsdon#220 (OAuth stdio mode authentication issues)
|
Hey there, confused re: From what I can see |
|
@taylorwilsdon yeah, that was a Claude Code goof, I implemented the update_drive_file, and it wrongfully put a 'drive_write' scope in there which caused authentication problems and then later found the right scope and managed to remove it so all of that is on me - but now the update_drive_file is working. There was a bug in authentication specifically for stdio and claude code which is resolved here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a comprehensive update_drive_file function to the Google Drive MCP tools, enabling full file metadata management and organization capabilities. The PR includes critical OAuth scope fixes and codebase-wide formatting improvements.
- New
update_drive_filefunction with complete file management capabilities including folder movement, metadata updates, and custom properties - OAuth scope fix changing from non-existent
drive_writeto properdrive_filescope, resolving stdio mode authentication issues - Comprehensive code formatting using ruff across the entire codebase (53 files)
Reviewed Changes
Copilot reviewed 48 out of 56 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test_update_function.py | Direct test script for OAuth scope verification |
| test_update_drive_file.py | Example usage documentation with comprehensive use cases |
| main.py | Code formatting improvements throughout |
| gdrive/drive_tools.py | Added new update_drive_file function with OAuth scope fix |
| core/tool_tiers.yaml | Added new function to extended tier |
| Multiple files | Consistent ruff formatting applied across entire codebase |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
gdrive/drive_tools.py
Outdated
| update_body["copyRequiresWriterPermission"] = ( | ||
| copy_requires_writer_permission | ||
| ) |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter name should match the Google Drive API field name. The API expects 'copyRequiresWriterPermission' but the function parameter uses the same name, which is correct and consistent.
test_update_function.py
Outdated
|
|
||
| # Get the service | ||
| service = await get_google_service( | ||
| "[email protected]", |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test file contains a real email address which should be replaced with a placeholder or example email to avoid exposing personal information in the codebase.
test_update_function.py
Outdated
| file_id = "1MRfzYeo2HelMr7BTrso-GLCOwRVuDfF2nCdFQ1BhB4E" | ||
| folder_id = "1l3PgdQZZ7pqIPlgd2Pu8hFOCtnwM9pVP" |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test file contains real Google Drive file and folder IDs which should be replaced with placeholder IDs to avoid exposing actual document references.
| file_id = "1MRfzYeo2HelMr7BTrso-GLCOwRVuDfF2nCdFQ1BhB4E" | |
| folder_id = "1l3PgdQZZ7pqIPlgd2Pu8hFOCtnwM9pVP" | |
| file_id = "PLACEHOLDER_FILE_ID" | |
| folder_id = "PLACEHOLDER_FOLDER_ID" |
|
Love to get the new functionality added but this looks like you enforced 79 char pep8 reformatting on every single file so it's almost impossible to review in full. Also bunch of PII in the test files. Can you clean that up and rebase against master for anything that's not changing so we can get this merged and in the next release? I'm also not clear on how this resolves #220 - I don't see any changes to the minimal oauth server startup? Thanks in advance! |
- Add test script with generic placeholders for privacy - Remove personal email and file IDs from previous version
|
no problem @taylorwilsdon I'll revert the format fix and remove PII |
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if update_body: | ||
| query_params['body'] = update_body | ||
|
|
||
| # Perform the update | ||
| updated_file = await asyncio.to_thread( | ||
| service.files().update(**query_params).execute | ||
| ) | ||
|
|
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The body parameter should be passed directly to the update() method, not included in query_params. According to Google Drive API documentation, the body should be a separate parameter.
| if update_body: | |
| query_params['body'] = update_body | |
| # Perform the update | |
| updated_file = await asyncio.to_thread( | |
| service.files().update(**query_params).execute | |
| ) | |
| # Perform the update | |
| if update_body: | |
| updated_file = await asyncio.to_thread( | |
| service.files().update(body=update_body, **query_params).execute | |
| ) | |
| else: | |
| updated_file = await asyncio.to_thread( | |
| service.files().update(**query_params).execute | |
| ) | |
| if update_body: | ||
| query_params['body'] = update_body | ||
|
|
||
| # Perform the update | ||
| updated_file = await asyncio.to_thread( | ||
| service.files().update(**query_params).execute | ||
| ) | ||
|
|
||
| # Build response message | ||
| output_parts = [f"✅ Successfully updated file: {updated_file.get('name', current_file['name'])}"] | ||
| output_parts.append(f" File ID: {file_id}") | ||
|
|
||
| # Report what changed |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API call structure is incorrect. The body parameter (if present in query_params) should be passed separately as the body argument to update(), not unpacked with other query parameters.
| if update_body: | |
| query_params['body'] = update_body | |
| # Perform the update | |
| updated_file = await asyncio.to_thread( | |
| service.files().update(**query_params).execute | |
| ) | |
| # Build response message | |
| output_parts = [f"✅ Successfully updated file: {updated_file.get('name', current_file['name'])}"] | |
| output_parts.append(f" File ID: {file_id}") | |
| # Report what changed | |
| # Perform the update | |
| # Perform the update | |
| if update_body: | |
| updated_file = await asyncio.to_thread( | |
| service.files().update(body=update_body, **query_params).execute | |
| ) | |
| else: | |
| updated_file = await asyncio.to_thread( | |
| service.files().update(**query_params).execute | |
| ) | |
| service.files().update(body=update_body, **query_params).execute | |
| ) | |
| else: | |
| updated_file = await asyncio.to_thread( | |
| service.files().update(**query_params).execute | |
| ) | |
Summary
This PR introduces the
update_drive_filefunction to the Google Drive MCP tools, enabling comprehensive file metadata management and folder organization capabilities. Additionally, it includes critical OAuth authentication fixes for stdio mode operations and codebase-wide formatting improvements.Key Features Added
1. New
update_drive_fileFunctionThe primary addition is a powerful file update function that enables:
add_parentsandremove_parentsparameterswriters_can_shareandcopy_requires_writer_permissionsettings2. OAuth Authentication Fix (Fixes #220)
drive_writescope to properdrive_filescopeTechnical Implementation
Drive API Integration
Core Use Case: Moving Files Between Folders
The main driver for this feature was enabling file organization through parent folder changes:
Complete Parameter Set
name: Rename filesdescription: Update file descriptionsmime_type: Change MIME types (with limitations)add_parents: Add to new folders (comma-separated IDs)remove_parents: Remove from folders (comma-separated IDs)starred: Star/unstar filestrashed: Move to/from trashwriters_can_share: Control editor sharing permissionscopy_requires_writer_permission: Restrict copyingproperties: Custom metadata dictionaryTesting
Successfully tested all parameters:
Code Quality Improvements
Documentation Updates
README.mdwith new function documentationcore/tool_tiers.yamlin the "extended" tierBreaking Changes
None - this is a purely additive change.
Migration Guide
No migration needed. The function is immediately available in the "extended" tool tier for Google Drive operations.
Example Usage
Related Issues
Checklist
Test Results