Skip to main content

Google Workspace Drive MCP Server

Create a powerful Model Context Protocol (MCP) server for Google Drive in minutes with our AI Gateway. This guide walks you through setting up seamless Google Drive integration with enterprise-grade security and instant OAuth authentication.

About Google Drive API

Google Drive is the cloud storage service used by over 3 billion users worldwide. The Drive API provides comprehensive access to files, folders, and collaborative features:

  • File Management: Upload, download, update, and organize files
  • Folder Operations: Create hierarchical folder structures and manage permissions
  • Search Capabilities: Advanced search with metadata and content queries
  • Sharing & Permissions: Granular access control and collaboration settings
  • Real-time Collaboration: Comments, suggestions, and activity tracking
  • Version Control: File revision history and recovery
  • Team Drives: Shared drives for organizational content
  • Third-party Integration: Connect with Google Workspace and external apps

Key Features

  • REST API v3: Modern API with resumable uploads
  • Real-time Updates: Push notifications for file changes
  • OCR Support: Extract text from images and PDFs
  • Metadata: Custom file properties and app-specific data
  • Quotas: 10 queries per second per user
  • File Size: Up to 5TB per file
  • Export Formats: Convert Google Docs to various formats
  • Thumbnails: Automatic preview generation

What You Can Do with Google Drive MCP Server

The MCP server transforms Google Drive's API into a natural language interface, enabling AI agents to:

File & Folder Management

  • Smart File Operations

    • "Upload all PDFs from my desktop to the Reports folder"
    • "Find all spreadsheets modified in the last week"
    • "Move old presentations to the Archive folder"
    • "Create a backup of all documents shared with me"
  • Folder Organization

    • "Create a folder structure for the Q1 2025 project"
    • "Organize files by type into appropriate folders"
    • "Clean up duplicate files in my Drive"
    • "Set up team folders with proper permissions"
  • Bulk Operations

    • "Download all files from the Marketing folder"
    • "Convert all Word documents to Google Docs"
    • "Rename files to follow naming convention"
    • "Delete all files in trash older than 30 days"

Search & Discovery

  • Advanced Search

    • "Find all contracts mentioning 'renewal' from 2024"
    • "Show me presentations created by Sarah"
    • "List all files I haven't opened in 6 months"
    • "Find documents with comments from John"
  • Content Intelligence

    • "Search for files containing budget information"
    • "Find all images with product screenshots"
    • "Locate PDFs with signature fields"
    • "Show files with specific metadata tags"
  • Activity Tracking

    • "What files were shared with me today?"
    • "Show recent changes to team documents"
    • "List files accessed by external users"
    • "Track document viewing statistics"

Sharing & Collaboration

  • Permission Management

    • "Share the quarterly report with the board members"
    • "Remove external access from all confidential files"
    • "Grant edit access to the project team"
    • "Create view-only links for client deliverables"
  • Collaboration Features

    • "Add a comment to the proposal about pricing"
    • "Resolve all suggestions in the draft document"
    • "Notify team about document updates"
    • "Create a shared workspace for the project"
  • Access Control

    • "Set expiration dates for shared links"
    • "Restrict downloading for sensitive documents"
    • "Audit who has access to financial files"
    • "Revoke access for former employees"

Document Processing

  • Format Conversion

    • "Convert all Excel files to Google Sheets"
    • "Export Google Docs as PDFs"
    • "Create Word versions of all proposals"
    • "Generate thumbnails for presentations"
  • Content Extraction

    • "Extract text from scanned receipts"
    • "OCR all images in the Archives folder"
    • "Pull data from invoices into spreadsheet"
    • "Create searchable PDFs from scans"
  • Automation Workflows

    • "Auto-organize uploads by file type"
    • "Create monthly backup archives"
    • "Generate reports from folder contents"
    • "Sync specific folders with local storage"

Team Drive Management

  • Shared Drive Operations

    • "Create a shared drive for the Sales team"
    • "Migrate personal files to team drives"
    • "Set up departmental folder structures"
    • "Configure drive-wide permissions"
  • Content Governance

    • "Enforce naming conventions in team drives"
    • "Archive completed project drives"
    • "Monitor storage usage by team"
    • "Implement retention policies"

Analytics & Reporting

  • Usage Analytics

    • "Generate storage usage report by user"
    • "Track file access patterns"
    • "Analyze sharing habits across teams"
    • "Monitor external collaboration"
  • Compliance Monitoring

    • "Find files shared outside organization"
    • "Audit sensitive data exposure"
    • "Track policy violations"
    • "Generate compliance reports"

Prerequisites

  • Access to Cequence AI Gateway
  • Google Cloud Console account
  • Google Drive API enabled in your project
  • Administrative access to create OAuth2 credentials

Step 1: Create Google OAuth2 Credentials

Before setting up the MCP server, you need to create OAuth2 credentials in Google Cloud Console.

1.1 Access Google Cloud Console

  1. Navigate to Google Cloud Console
  2. Select your project or create a new one
  3. Ensure billing is enabled for your project

1.2 Enable Google Drive API

  1. Go to APIs & Services Library
  2. Search for "Google Drive API"
  3. Click on Google Drive API
  4. Click Enable

1.3 Create OAuth2 Credentials

  1. Navigate to APIs & Services Credentials

  2. Click + CREATE CREDENTIALS OAuth client ID

  3. If prompted, configure the OAuth consent screen first:

    • Choose Internal for organization use or External for broader access
    • Fill in the required fields:
      • App name: "AI Gateway Drive Integration"
      • User support email: Your email
      • Developer contact: Your email
    • Add scopes (see Available Scopes section below)
  4. Create the OAuth client:

    • Application type: Web application
    • Name: "AI Gateway Drive MCP"
    • Authorized redirect URIs:
      https://auth.aigateway.cequence.ai/v1/outbound/oauth/callback
  5. Save the credentials:

    • Download the JSON file
    • Note your Client ID and Client Secret

1.4 Configure Domain-Wide Delegation (Optional)

For Google Workspace domains:

  1. Go to APIs & Services Credentials
  2. Click on your OAuth2 client
  3. Enable Domain-wide delegation
  4. Note the Service Account Email
  5. In Google Workspace Admin:
    • Go to Security API controls Domain-wide delegation
    • Add the client with Drive scopes

Step 2: Access AI Gateway Apps

  1. Log in to your Cequence AI Gateway dashboard
  2. Navigate to Apps in the left sidebar
  3. You'll see the list of available third-party applications

Step 3: Find and Select Google Drive API

  1. In the Apps section, browse through the Third-party category
  2. Look for Google Workspace Drive or use the search function
  3. Click on the Drive API card to view details

The Drive API card shows:

  • Number of available endpoints
  • Integration capabilities
  • Quick description of functionality

Step 4: Create MCP Server

  1. Click the Create MCP Server button on the Drive API card
  2. You'll be redirected to the MCP Server creation wizard

Step 5: Configure API Endpoints

In the App Configuration step:

  1. Base URL is pre-filled: https://www.googleapis.com/drive/v3
  2. Select API endpoints to expose to your MCP server based on your needs
  3. Click Next to proceed

Step 6: MCP Server Basic Setup

Configure your MCP server details:

  1. MCP Server Name: Enter a descriptive name

    • Example: "Drive File Management Server"
    • This name will identify your server in the dashboard
  2. Description (Optional): Add details about the server's purpose

    • Example: "Automated file management and document processing"
  3. Production Mode: Toggle based on your needs

    • ON for production environments
    • OFF for development/testing
  4. Click Next to continue

Step 7: Configure Authentication

This is where you'll use your Google OAuth2 credentials:

  1. Authentication Type: Select OAuth 2.0

  2. Fill in the OAuth configuration:

    • Authorization URL:
      https://accounts.google.com/o/oauth2/auth
    • Token URL:
      https://accounts.google.com/o/oauth2/token
    • Client ID: Paste from Google Cloud Console
    • Client Secret: Paste from Google Cloud Console
    • Redirect URI:
      https://auth.aigateway.cequence.ai/v1/outbound/oauth/callback
  3. Scopes: Select from the available Drive scopes (see next section)

Available Google Drive OAuth Scopes

Configure the appropriate scopes based on your application needs:

File Access

  • https://www.googleapis.com/auth/drive

    • Full access to all files in Drive
    • Create, read, update, and delete files
    • Manage permissions and sharing
    • Access to file metadata and content
  • https://www.googleapis.com/auth/drive.file

    • Access to files created or opened by the app
    • More restrictive than full drive access
    • Cannot access files not explicitly opened
    • Suitable for app-specific storage
  • https://www.googleapis.com/auth/drive.readonly

    • Read-only access to all files
    • View file metadata and content
    • List files and folders
    • Cannot modify or delete

Metadata Access

  • https://www.googleapis.com/auth/drive.metadata.readonly
    • Read-only access to file metadata
    • No access to file content
    • Useful for file listings and searches
    • Minimal permission scope

App Data

  • https://www.googleapis.com/auth/drive.appdata
    • Access app-specific folder in Drive
    • Hidden from user's Drive UI
    • Isolated storage for app data
    • Cannot access user's regular files

Photos

  • https://www.googleapis.com/auth/drive.photos.readonly
    • Read-only access to photos
    • Access Google Photos content
    • View photo metadata
    • Cannot modify photos

For File Management:

https://www.googleapis.com/auth/drive

For Read-Only Access:

https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive.metadata.readonly

For App-Specific Storage:

https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.appdata

Step 8: Configure Security

Set up API protection features:

  1. API Protection: Toggle ON to enable

    • Protects against bot attacks, DDoS, and threats
    • Monitors for suspicious activity
    • Rate limiting and anomaly detection
  2. Protection Features (when enabled):

    • Auto-scaling protection
    • Managed infrastructure
    • Built-in monitoring
    • Zero maintenance required
  3. Click Next to continue

Step 9: Choose Deployment Method

Select your deployment preference:

  • Fully managed deployment
  • Automatic scaling and monitoring
  • Built-in high availability
  • Features included:
    • Auto-scaling
    • Managed infrastructure
    • Built-in monitoring
    • Zero maintenance

Option B: Deploy with Helm Chart

  • Self-managed Kubernetes deployment
  • Full control over infrastructure
  • Requires:
    • Kubernetes cluster
    • Helm 3.x installed
    • Container registry access

Click Next after selecting your deployment method.

Step 10: Review and Deploy

Review your MCP server configuration:

  • MCP Server Name: Your chosen name
  • Base URL: https://www.googleapis.com/drive/v3
  • Selected Endpoints: Number of endpoints selected
  • Authentication: OAuth 2.0 (Configured)
  • API Protection: Enabled/Disabled
  • Deployment: Cequence Cloud or Helm

Click Create & Deploy to finalize the setup.

Step 11: Post-Deployment Setup

After successful deployment:

  1. Note the MCP Server URL provided

  2. Test the OAuth flow:

    • Click "Test Connection"
    • You'll be redirected to Google sign-in
    • Authorize the requested permissions
    • Confirm successful connection
  3. Configure AI Agents:

    • The MCP server is now available for AI agent connections
    • Use the provided server URL in your AI agent configuration

Using Your Google Drive MCP Server

With Claude Desktop

  1. Open Claude Desktop settings

  2. Add your MCP server:

    {
    "servers": {
    "drive": {
    "url": "your-mcp-server-url",
    "auth": {
    "type": "oauth2",
    "client_id": "your-client-id"
    }
    }
    }
    }
  3. Start using natural language commands:

    • "Upload the quarterly report to the Finance folder"
    • "Find all PDFs modified this week"
    • "Share the project folder with the team"
    • "Create a backup of all spreadsheets"
    • "Convert all Word docs to Google Docs format"

API Integration Example

// Initialize MCP client
const mcpClient = new MCPClient({
serverUrl: 'your-mcp-server-url',
auth: {
type: 'oauth2',
token: 'user-access-token'
}
});

// List files in a folder
const files = await mcpClient.drive.files.list({
q: "'folder-id' in parents and trashed = false",
fields: 'files(id, name, mimeType, modifiedTime)',
orderBy: 'modifiedTime desc'
});

// Upload a file
const fileMetadata = {
name: 'report.pdf',
parents: ['folder-id']
};
const media = {
mimeType: 'application/pdf',
body: fileStream
};
const file = await mcpClient.drive.files.create({
requestBody: fileMetadata,
media: media,
fields: 'id, webViewLink'
});

// Share a file
await mcpClient.drive.permissions.create({
fileId: 'file-id',
requestBody: {
type: 'user',
role: 'writer',
emailAddress: 'colleague@company.com'
},
sendNotificationEmail: true
});

// Search for files
const searchResults = await mcpClient.drive.files.list({
q: "fullText contains 'quarterly report' and modifiedTime > '2024-01-01'",
fields: 'files(id, name, owners, lastModifyingUser)',
pageSize: 50
});

Common Use Cases

Document Management

  • Automated file organization
  • Document lifecycle management
  • Version control workflows
  • Archive and retention policies

Team Collaboration

  • Shared workspace setup
  • Permission management
  • Collaborative editing workflows
  • Review and approval processes

Data Processing

  • Bulk file operations
  • Format conversions
  • OCR and text extraction
  • Metadata management

Backup & Recovery

  • Automated backups
  • Disaster recovery
  • Data migration
  • Archival systems

Security Best Practices

  1. Scope Management:

    • Use minimum required scopes
    • Prefer read-only scopes when possible
    • Regular scope audits
    • Document scope usage
  2. Access Control:

    • Implement least privilege principle
    • Regular permission reviews
    • Monitor external sharing
    • Use expiring links
  3. Data Protection:

    • Encrypt sensitive files
    • Implement DLP policies
    • Monitor file access logs
    • Regular security audits
  4. API Security:

    • Secure token storage
    • Implement rate limiting
    • Monitor API usage
    • Use service accounts wisely

Troubleshooting

Common Issues

  1. 403 Insufficient Permission

    • Check OAuth scopes granted
    • Verify file ownership
    • Ensure API is enabled
    • Check folder permissions
  2. 404 File Not Found

    • Verify file ID is correct
    • Check file hasn't been deleted
    • Ensure proper access rights
    • Confirm correct API version
  3. 429 Rate Limit Exceeded

    • Default: 10 queries/second/user
    • Implement exponential backoff
    • Use batch requests
    • Cache frequently accessed data
  4. 400 Invalid Request

    • Validate query syntax
    • Check required fields
    • Verify MIME types
    • Review API documentation

Getting Help