v-odoo-testing/gdrive-mcp-server
If you are the rightful owner of gdrive-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This document provides a structured summary of the Google Drive MCP Server - Enhanced Authentication & Download Edition, highlighting its key features, tools, and usage instructions.
download_folder_recursive
Download entire folders with automatic conversion.
download_file
Download individual files with proper handling.
export_google_file
Convert Google files to Office formats.
get_folder_structure
Analyze folder contents before downloading.
check_auth_status
Check authentication status and diagnose issues.
Google Drive MCP Server - Enhanced Authentication & Download Edition
Overview
This is an enhanced version of the Google Drive MCP server with robust authentication management and powerful download capabilities. The server now features:
ā
Automatic token refresh - Seamless authentication handling
ā
Enhanced error reporting - Clear, actionable error messages
ā
Modular architecture - Clean, maintainable codebase
ā
Bulk download operations - Recursive downloads with smart features ā NEW!
ā
File conversion - Google Docs/Sheets/Slides to Office formats ā NEW!
ā
Shared Drive support - Full team drive compatibility
ā
Smart retry logic - Handles rate limits and network issues
ā
Version deduplication - Automatic duplicate removal ā NEW!
š New Features
š„ Download & Export Tools ā NEW!
download_folder_recursive
- Download entire folders with automatic conversiondownload_file
- Download individual files with proper handlingexport_google_file
- Convert Google files to Office formatsget_folder_structure
- Analyze folder contents before downloading- Smart conversion - Google Docs ā Word, Sheets ā Excel, Slides ā PowerPoint
- Version deduplication - Keeps latest versions, removes duplicates
- Progress tracking - Real-time download progress and statistics
š Enhanced Authentication System
- Automatic token refresh - No more mid-operation failures
- Proactive token management - Checks expiry before operations
- Graceful degradation - Clear error messages when re-auth needed
- Authentication status tool - Debug auth issues easily
- Hybrid error handling - Combines auto-retry with user guidance
šļø Modular Architecture
- Clean separation - 400-line main file vs previous 1500+ lines
- Organized structure - Tool handlers, utilities, and auth management
- Maintainable code - Easy to extend and debug
- Type safety - Full TypeScript support with proper error handling
Quick Start
1. Build the server
npm install
npm run build
2. Authenticate (first time only)
node dist/index.js auth
3. Run the server
node dist/index.js
Project Structure
š¦ gdrive-custom/
āāā š index.ts # Main server (416 lines - clean!)
āāā š src/
ā āāā š auth-manager.ts # Authentication management
ā āāā š tool-handlers/
ā ā āāā š basic-operations.ts # Search, copy, move, create, list
ā ā āāā š shared-drive-operations.ts # Team drive operations
ā āāā š utils/
ā āāā š error-handling.ts # Enhanced error context & messages
ā āāā š file-utils.ts # File operations & retry logic
āāā š dist/ # Compiled output
āāā š README.md # This file
š§ Available Tools
Basic Operations
Tool | Description | Enhanced Features |
---|---|---|
search | Search files in Drive | ā Auto-retry, validation |
copy_file | Copy files/folders | ā ID validation, clear feedback |
move_file | Move files between folders | ā Parent validation, error context |
create_folder | Create new folders | ā Name validation, duplicate handling |
list_files | List folder contents | ā MIME filtering, pagination |
Shared Drive Operations
Tool | Description | Enhanced Features |
---|---|---|
list_shared_drives | List accessible team drives | ā Permission-aware listing |
search_shared_drive | Search in team drives | ā Cross-drive search capability |
list_shared_drive_files | List team drive files | ā Folder-specific listing |
enhanced_search | Search across all drives | ā Combined personal + team results |
identify_folder_type | Identify drive location | ā Detailed metadata analysis |
Download & Export Operations ā NEW!
Tool | Description | Enhanced Features |
---|---|---|
download_folder_recursive | Download entire folders | ā NEW! Bulk download with conversion |
download_file | Download individual files | ā NEW! Smart format handling |
export_google_file | Convert Google files | ā NEW! Office format conversion |
get_folder_structure | Analyze folder structure | ā NEW! Pre-download analysis |
System & Debugging
Tool | Description | Enhanced Features |
---|---|---|
check_auth_status | Check authentication | ā NEW! Detailed token analysis |
š Authentication Features
Automatic Token Management
- Smart refresh - Automatically refreshes tokens when they're about to expire
- Background monitoring - Continuous token health checking
- Transparent operation - Users don't see authentication interruptions
Enhanced Error Handling
The system now provides context-aware error messages with specific recovery instructions:
Token Expired
ā Your Google Drive access token has expired.
š§ Recovery Instructions:
1. The system will attempt to refresh your token automatically.
2. If this fails repeatedly, please re-authenticate:
3. Run: node dist/index.js auth
4. Follow the browser authentication flow
5. Restart the MCP server
Permission Denied
ā Permission denied for this Google Drive operation.
š§ Recovery Instructions:
1. This could be due to:
2. Insufficient Google Drive permissions
3. File/folder access restrictions
4. Organization policy limitations
5. Try re-authenticating with full permissions
Debugging Tools
Use the new check_auth_status
tool to diagnose authentication issues:
{
"name": "check_auth_status",
"arguments": {}
}
Sample Output:
š Authentication Status: ā
Authenticated (expires in 42 minutes)
š Token Details:
{
"isValid": true,
"expiresAt": 1751780116482,
"needsRefresh": false,
"timeUntilExpiry": 2537266
}
š” Usage Examples
Basic File Operations
// Search for files
{
"name": "search",
"arguments": {
"query": "project documents"
}
}
// Copy with validation
{
"name": "copy_file",
"arguments": {
"fileId": "1ABC123...",
"name": "Project Copy",
"parentId": "1XYZ789..."
}
}
Enhanced Search
// Search across all drives with limits
{
"name": "enhanced_search",
"arguments": {
"query": "quarterly reports",
"searchSharedDrives": true,
"searchPersonalDrive": true,
"maxResults": 50
}
}
Download Operations ā NEW!
// Download entire folder recursively
{
"name": "download_folder_recursive",
"arguments": {
"folderId": "1ABC123...",
"driveId": "0XYZ789...",
"localPath": "/path/to/download/",
"deduplicateVersions": true,
"dryRun": false
}
}
// Download individual file
{
"name": "download_file",
"arguments": {
"fileId": "1ABC123...",
"outputPath": "/path/to/file.pdf",
"driveId": "0XYZ789..."
}
}
// Export Google file to Office format
{
"name": "export_google_file",
"arguments": {
"fileId": "1ABC123...",
"mimeType": "application/vnd.google-apps.document",
"outputPath": "/path/to/document.docx",
"format": "auto"
}
}
// Analyze folder structure first
{
"name": "get_folder_structure",
"arguments": {
"folderId": "1ABC123...",
"driveId": "0XYZ789...",
"maxDepth": 10
}
}
Authentication Debugging
// Check current auth status
{
"name": "check_auth_status",
"arguments": {}
}
š ļø Advanced Configuration
Environment Variables
# Optional: Custom credential paths
GDRIVE_CREDENTIALS_PATH="/path/to/saved/credentials.json"
GDRIVE_OAUTH_PATH="/path/to/oauth/credentials.json"
Authentication Setup
- Create credentials at Google Cloud Console
- Enable Google Drive API
- Download OAuth2 credentials JSON
- Place credentials at
~/.google_sheet_secrets/credentials.json
- Run
node dist/index.js auth
to authenticate
š§° Development & Maintenance
Building
npm run build # Compile TypeScript
npm run watch # Watch mode for development
Testing Authentication
# Quick auth test
echo '{"method": "tools/call", "params": {"name": "check_auth_status", "arguments": {}}}' | node dist/index.js
File Structure Benefits
- Maintainable: Each component has a single responsibility
- Testable: Utilities and handlers can be tested independently
- Extensible: New tools can be added without touching core logic
- Debuggable: Clear separation makes issues easier to isolate
š Migration from Previous Version
If upgrading from the monolithic version:
- Build the new version:
npm run build
- Test authentication: Use
check_auth_status
tool - Verify operations: Test basic operations first
- Full compatibility: All existing tool names remain the same
ā ļø Note: Some bulk operations are currently being refactored for the new architecture. Basic operations and shared drive features are fully functional.
š Troubleshooting
Authentication Issues
- Use
check_auth_status
tool for diagnosis - Check credentials file permissions
- Verify Google Drive API is enabled
- Re-run authentication:
node dist/index.js auth
API Errors
- Rate limits: Automatically handled with exponential backoff
- Network issues: Automatic retry with progressive delays
- Permission errors: Clear instructions provided in error messages
Development Issues
- Build errors: Check TypeScript compilation with
npm run build
- Import errors: Verify file structure matches expected paths
- Runtime errors: Check authentication status first
š Performance & Reliability
Enhanced Reliability
- Automatic retries for transient failures
- Smart backoff for rate limit handling
- Connection resilience for network issues
- Token proactive management prevents mid-operation failures
Performance Optimizations
- Modular loading - Only load needed components
- Efficient compilation - TypeScript with optimized output
- Memory management - Better resource utilization
- Reduced overhead - Cleaner architecture with less bloat
šÆ Architecture Achievement Summary
ā
Reduced complexity: 1543 lines ā 416 lines main file
ā
Enhanced authentication: Automatic token refresh + clear error handling
ā
Improved maintainability: Modular structure with separation of concerns
ā
Better user experience: Context-aware error messages + debugging tools
ā
Bulk download operations: Complete recursive download with smart conversion ā NEW!
ā
File format conversion: Google files ā Office formats automatically ā NEW!
ā
Version deduplication: Intelligent duplicate removal ā NEW!
ā
Production-ready: Handles large-scale folder downloads (750+ files) ā NEW!
Latest Achievement: Implemented complete download functionality with enterprise-grade features for automated Google Drive backups.