dennisonbertram/mcp-gdrive
If you are the rightful owner of mcp-gdrive 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.
Google Drive MCP Server provides secure access to Google Drive and Google Sheets functionality, enabling AI assistants to perform various operations.
Google Drive MCP Server
A comprehensive Model Context Protocol (MCP) server that provides secure access to Google Drive and Google Sheets functionality. This server enables AI assistants to perform file operations, manage permissions, and interact with spreadsheets through a well-structured set of tools.
Features
🗂️ File Operations
- List, search, and filter files
- Create, read, update, and delete files
- Upload and download content
- Copy and move files
- Export Google Workspace documents to various formats
📁 Folder Management
- Create and organize folder hierarchies
- Move files between folders
- Get complete folder trees
- Batch folder operations
🔐 Permission Control
- Share files and folders with users or groups
- Create public links with expiration
- Manage access levels (view, comment, edit)
- Batch permission updates
📊 Google Sheets Integration
- Create and manage spreadsheets
- Read and write cell values
- Batch operations for efficiency
- Format cells and ranges
- Append data to sheets
📋 Dynamic Resources
- Recent files list
- Folder structure visualization
- Storage quota information
- Shared files tracking
- Spreadsheet discovery
💬 Interactive Prompts
- Organize files by patterns
- Backup folders
- Share projects with teams
- Clean up duplicates
- Generate reports from spreadsheets
- Archive old files
Installation
Using Claude Desktop App
Add to your Claude desktop configuration:
{
"mcpServers": {
"gdrive": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/gdrive-mcp"],
"env": {
"GDRIVE_CLIENT_ID": "your_client_id",
"GDRIVE_CLIENT_SECRET": "your_client_secret",
"GDRIVE_REDIRECT_URI": "http://localhost:3000/oauth2callback",
"GDRIVE_CREDS_DIR": "~/.config/gdrive-mcp"
}
}
}
}
Using Claude CLI
# Install globally
npm install -g @modelcontextprotocol/gdrive-mcp
# Add to MCP
claude mcp add gdrive \
--env GDRIVE_CLIENT_ID=your_client_id \
--env GDRIVE_CLIENT_SECRET=your_client_secret \
-- npx -y @modelcontextprotocol/gdrive-mcp
Using Cursor
Add to your Cursor settings:
{
"mcp": {
"servers": {
"gdrive": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/gdrive-mcp"],
"env": {
"GDRIVE_CLIENT_ID": "your_client_id",
"GDRIVE_CLIENT_SECRET": "your_client_secret"
}
}
}
}
}
Using Cline
Add to your Cline configuration:
{
"mcp": {
"gdrive": {
"command": "npx",
"args": ["@modelcontextprotocol/gdrive-mcp"],
"env": {
"GDRIVE_CLIENT_ID": "your_client_id",
"GDRIVE_CLIENT_SECRET": "your_client_secret"
}
}
}
}
Configuration
Prerequisites
-
Google Cloud Project
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable Google Drive API and Google Sheets API
-
OAuth2 Credentials
- Go to APIs & Services > Credentials
- Click "Create Credentials" > "OAuth client ID"
- Choose "Desktop app" or "Web application"
- Add
http://localhost:3000/oauth2callback
to redirect URIs - Download the credentials JSON
-
Environment Variables
Create a
.env
file:# OAuth2 Configuration GDRIVE_CLIENT_ID=your_client_id.apps.googleusercontent.com GDRIVE_CLIENT_SECRET=your_client_secret GDRIVE_REDIRECT_URI=http://localhost:3000/oauth2callback GDRIVE_CREDS_DIR=~/.config/gdrive-mcp # Alternative: Service Account # GDRIVE_SERVICE_ACCOUNT_KEY=/path/to/service-account-key.json # Optional Configuration GDRIVE_LOG_LEVEL=info GDRIVE_MAX_RETRIES=3 GDRIVE_DEFAULT_FIELDS=id,name,mimeType,modifiedTime
Authentication Methods
OAuth2 (Recommended for User Access)
The server will open a browser for authentication on first use. Tokens are stored securely and refreshed automatically.
Service Account (For Server-to-Server)
export GDRIVE_AUTH_METHOD=service_account
export GDRIVE_SERVICE_ACCOUNT_KEY=/path/to/key.json
Usage
Basic File Operations
// List files
await use_mcp_tool("gdrive", "gdrive_list_files", {
pageSize: 10,
query: "name contains 'report'"
});
// Create a file
await use_mcp_tool("gdrive", "gdrive_create_file", {
name: "meeting-notes.txt",
content: "Meeting notes from today...",
mimeType: "text/plain"
});
// Download a file
await use_mcp_tool("gdrive", "gdrive_download_file", {
fileId: "abc123",
asBase64: true
});
Folder Management
// Create folder
await use_mcp_tool("gdrive", "gdrive_create_folder", {
name: "Project Files",
color: "blue"
});
// Move files
await use_mcp_tool("gdrive", "gdrive_move_file", {
fileId: "file123",
newParentId: "folder456"
});
Sharing and Permissions
// Share with user
await use_mcp_tool("gdrive", "gdrive_share_file", {
fileId: "doc789",
emailAddress: "colleague@example.com",
role: "writer"
});
// Create public link
await use_mcp_tool("gdrive", "gdrive_create_public_link", {
fileId: "doc789",
linkType: "view",
expirationDays: 7
});
Google Sheets Operations
// Create spreadsheet
await use_mcp_tool("gdrive", "sheets_create_spreadsheet", {
title: "Sales Data",
sheets: [{
title: "Q1 2024",
rowCount: 1000
}]
});
// Write data
await use_mcp_tool("gdrive", "sheets_write_range", {
spreadsheetId: "sheet123",
range: "A1:B2",
values: [
["Product", "Sales"],
["Widget A", 1500]
]
});
Using Resources
// Get recent files
const recent = await use_mcp_resource("gdrive", "gdrive://recent-files");
// Check storage quota
const quota = await use_mcp_resource("gdrive", "gdrive://storage-quota");
// Get file details
const file = await use_mcp_resource("gdrive", "gdrive://file/abc123");
Using Prompts
// Organize files
await use_mcp_prompt("gdrive", "organize_files", {
pattern: "*.pdf",
folderName: "PDF Documents"
});
// Create backup
await use_mcp_prompt("gdrive", "backup_folder", {
folderId: "important-folder",
backupName: "Backup_2024"
});
Available Tools
File Operations
gdrive_list_files
- List files with filteringgdrive_search_files
- Advanced file searchgdrive_get_file
- Get file metadatagdrive_create_file
- Create new filegdrive_update_file
- Update file content/metadatagdrive_delete_file
- Delete or trash filegdrive_copy_file
- Copy filegdrive_download_file
- Download file contentgdrive_export_file
- Export Google Workspace files
Folder Management
gdrive_create_folder
- Create foldergdrive_list_folders
- List foldersgdrive_move_file
- Move files/foldersgdrive_get_folder_tree
- Get folder hierarchy
Permissions
gdrive_share_file
- Share with usersgdrive_list_permissions
- List file permissionsgdrive_update_permission
- Update permissionsgdrive_remove_permission
- Remove permissionsgdrive_create_public_link
- Create public link
Google Sheets
sheets_create_spreadsheet
- Create spreadsheetsheets_read_range
- Read cell valuessheets_write_range
- Write cell valuessheets_append_data
- Append rowssheets_batch_get
- Read multiple rangessheets_batch_update
- Update multiple rangessheets_clear_range
- Clear cellssheets_get_info
- Get spreadsheet infosheets_add_sheet
- Add new sheetsheets_format_cells
- Format cells
Development
Local Development
# Clone repository
git clone https://github.com/your-org/gdrive-mcp.git
cd gdrive-mcp
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm test
# Start development server
npm run dev
Testing
# Run all tests
npm test
# Run specific test suite
npm test -- --grep "File Operations"
# Test with coverage
npm run test:coverage
Docker
# Build image
docker build -t gdrive-mcp .
# Run container
docker run -it \
-e GDRIVE_CLIENT_ID=$GDRIVE_CLIENT_ID \
-e GDRIVE_CLIENT_SECRET=$GDRIVE_CLIENT_SECRET \
-v ~/.config/gdrive-mcp:/root/.config/gdrive-mcp \
gdrive-mcp
Troubleshooting
Authentication Issues
Problem: "Authentication failed"
- Verify CLIENT_ID and CLIENT_SECRET are correct
- Check redirect URI matches configuration
- Ensure APIs are enabled in Google Cloud Console
Problem: "Token expired"
- Delete token file:
rm ~/.config/gdrive-mcp/tokens.json
- Re-authenticate by running the server again
Permission Errors
Problem: "Insufficient permissions"
- Check OAuth scopes include necessary permissions
- Verify file ownership for operations requiring owner access
Rate Limiting
Problem: "Rate limit exceeded"
- Server implements automatic retry with exponential backoff
- Consider batching operations for efficiency
Security
- Credentials are stored securely with 0600 permissions
- Tokens are encrypted at rest (optional)
- No credentials are logged
- Automatic token refresh prevents expiration
- State parameter prevents CSRF attacks
Contributing
We welcome contributions! Please see our for details.
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
License
MIT License - see file for details.
Support
- 📧 Email: support@example.com
- 💬 Discord: Join our server
- 🐛 Issues: GitHub Issues
Acknowledgments
Built with the Model Context Protocol SDK by Anthropic.