Google Drive MCP Server
An MCP (Model Context Protocol) server that enables searching, retrieving, and managing files in Google Drive. Designed to run as a Google Cloud Function.
Features
- search_files - Search for files using Google Drive query syntax
- get_file_metadata - Get detailed metadata for a specific file
- list_folder - List files in a folder
- move_file - Move a file to a different folder
- create_folder - Create a new folder
Prerequisites
- A Google Cloud project with the Drive API enabled
- A service account with access to the files you want to query
- Google Cloud CLI (
gcloud) installed and configured
Setup
1. Create a Service Account
# Create the service account
gcloud iam service-accounts create drive-mcp \
--display-name="Google Drive MCP Server"
# Create and download the key
gcloud iam service-accounts keys create service-account-key.json \
--iam-account=drive-mcp@YOUR_PROJECT_ID.iam.gserviceaccount.com
2. Share Files/Folders
Share your Google Drive files or folders with the service account email:
drive-mcp@YOUR_PROJECT_ID.iam.gserviceaccount.com
Grant "Editor" permission to allow moving files, or "Viewer" for read-only access.
3. Install Dependencies
npm install
4. Build
npm run build
Deploy to Google Cloud Functions
gcloud functions deploy google-drive-mcp \
--gen2 \
--runtime=nodejs20 \
--region=us-central1 \
--source=. \
--entry-point=googleDriveMcp \
--trigger-http \
--allow-unauthenticated \
--set-secrets="GOOGLE_SERVICE_ACCOUNT_KEY=drive-mcp-credentials:latest"
MCP Client Configuration
{
"mcpServers": {
"google-drive": {
"url": "https://REGION-PROJECT_ID.cloudfunctions.net/google-drive-mcp"
}
}
}
Tool Usage
search_files
Search for files using Google Drive query syntax:
{
"query": "name contains 'report'",
"pageSize": 10
}
Common query examples:
name contains 'budget'- Files with "budget" in the namemimeType = 'application/pdf'- PDF files onlyfullText contains 'quarterly'- Files containing "quarterly" in contentmodifiedTime > '2024-01-01'- Files modified after Jan 1, 2024'folder_id' in parents- Files in a specific folder
get_file_metadata
Get detailed metadata for a file:
{
"fileId": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
}
list_folder
List files in a folder:
{
"folderId": "root",
"pageSize": 20
}
Use "root" for the root folder, or a specific folder ID.
move_file
Move a file to a different folder:
{
"fileId": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
"newParentId": "0B1234567890abcdef"
}
This removes the file from its current parent folder(s) and places it in the specified destination folder.
create_folder
Create a new folder:
{
"name": "My New Folder",
"parentId": "0B1234567890abcdef"
}
The parentId is optional. If not specified, the folder is created in the root of the shared drive or the service account's root.
License
MIT