gdrive-mcp
Provides tools to read, create, update, and search Google Docs, with features like tab detection, heading extraction, and content retrieval under specific headings.
Enables listing Google Docs in Drive, searching documents by content or title, and retrieving document metadata.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@gdrive-mcplist my recent Google Docs"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GDrive MCP by Peter Garety
A Model Context Protocol (MCP) server that provides AI assistants with secure access to your Google Docs. Run it locally for personal use or deploy it to Cloudflare Workers for global scale.
Project status and remaining work: Roadmap. Guides: Preview and apply a section edit, Rich formatting, and Export and save files.
✨ Key Features
📖 Read Google Docs content and metadata
✏️ Create and Update documents
Rich formatting — character/paragraph styles, lists, tables, and inline images (local source; not deployed)
Export files — Markdown, text, PDF, and DOCX as MCP embedded resources with an offline saving helper (local source; not deployed)
🔍 Search through your documents
📑 Tab Detection - identify tabs in multi-tab documents
📋 Heading Extraction - extract document structure (H1-H6)
📄 Content Retrieval - get content under specific headings
🔐 Dual Authentication - Service Account (local) + OAuth (cloud)
☁️ Cloudflare Workers deployment ready
🖥️ Local stdio transport for Cursor and Claude Desktop
🚀 Fast and Scalable serverless architecture
🛡️ Type-safe TypeScript implementation
Related MCP server: MCP Google Workspace Server
🛠️ Available Tools
Tool | Description |
| List Google Docs in your Drive |
| Get full document content with formatting |
| Get plain text content of a document |
| Create a new Google Doc |
| Update text, character/paragraph styles, lists, tables, and inline images (expanded contract integrated locally; see status below) |
| Search documents by content or title |
| Get document metadata |
| List tabs in a document |
| Extract headings (H1-H6) from a document |
| Get content under a specific heading |
| Preview or apply a revision-checked, tab-scoped plain-text section replacement |
| Export Markdown/text/PDF/DOCX as file metadata plus an embedded resource; see the saving guide (local source; not deployed) |
replace_section was deployed from commit bd49a12 on September 5, 2026. It defaults to preview; applying requires dryRun: false and a recent requiredRevisionId. Replacement includes subheadings and does not preserve formatting. Read the section editing guide before use. Public deployment checks passed, but authenticated Google document validation remains outstanding.
The expanded update_document formatting contract is integrated and locally tested in the September 8, 2026 formatting/export source segment; see Git history for its exact commit. It is not pushed, deployed, or live-validated. Before this segment, Git inspection found formatting still uncommitted on top of bd49a12; the earlier claim of a completed separate formatting commit was incorrect. It writes immediately and rejects dryRun; supply the revision from your read and select a tab for multi-tab documents. The rich formatting guide covers operation examples, UTF-16 indices, limits, and the remaining live-validation checklist.
export_document is integrated locally as tool 12. It returns versioned JSON file metadata and one embedded text/blob resource with a SHA-256 checksum, not a browser URL. The export guide documents the complete contract and beast-scripts/save-export.mjs for validated, non-overwriting file saves. The default export limit is 2 MiB; there is no per-tab selection or verified all-tabs guarantee. Export integration is included in this local source segment, but remains unpushed, undeployed, and not live-validated. Production remains the recorded 11-tool section release; committing or testing local source does not deploy it.
🚀 Quick Start
Choose your deployment method - these are two completely separate approaches:
🖥️ Local MCP Server (Personal Google Workspace)
Use this if: You're a Google Workspace admin and want local stdio transport. Prerequisites: Google Workspace admin access for domain-wide delegation.
Clone and Install
git clone https://github.com/petergarety/gdrive-mcp.git cd gdrive-mcp npm installSetup Google Workspace Service Account
Create a service account in Google Cloud Console
Download the service account JSON key
Configure domain-wide delegation in Google Admin Console
See detailed setup steps below
Setup Environment
cp env.example .env # Edit .env and add: # GOOGLE_SERVICE_ACCOUNT_PATH=/absolute/path/to/service-account.json # GOOGLE_USER_EMAIL=your-email@yourdomain.comBuild and Run
npm run build:mcp npm run start:mcpConfigure Cursor Desktop Add to your
~/.cursor/mcp.json:{ "mcpServers": { "gdrive": { "command": "node", "args": ["/absolute/path/to/gdrive-mcp/dist/mcp-server.js"], "cwd": "/absolute/path/to/gdrive-mcp" } } }
☁️ Cloudflare Workers (Web-based OAuth)
Use this if: You want web-based authentication that works with any Google account. Benefits: No Workspace admin required, works with personal Gmail, scalable.
Setup Cloudflare
npm install -g wrangler wrangler loginCreate KV Namespaces
npx wrangler kv namespace create "TOKEN_STORE" npx wrangler kv namespace create "CACHE" # Update wrangler.toml with the returned namespace IDsConfigure wrangler.toml
cp wrangler.toml.example wrangler.toml # Edit wrangler.toml and update: # - Replace "your-gdrive-mcp-server" with your desired worker name # - Update GOOGLE_REDIRECT_URI placeholder # - Add the KV namespace IDs from step 2Generate TypeScript Types
npx wrangler typesThis creates
worker-configuration.d.tswith proper TypeScript types for your Cloudflare environment.Initial Deploy (to get worker URL)
npm run build npx wrangler deployNote the worker URL (e.g.,
https://gdrive-mcp-server.your-subdomain.workers.dev)Update Configuration
Update
GOOGLE_REDIRECT_URIinwrangler.tomlwith your actual worker URLConfigure Google OAuth in Cloud Console with the real callback URL (see OAuth setup instructions)
Set OAuth Secrets
npx wrangler secret put GOOGLE_CLIENT_ID npx wrangler secret put GOOGLE_CLIENT_SECRETFinal Deploy
npm run build npx wrangler deployGet Your API Key Visit
https://your-worker-url/to authenticate and get your API key for MCP clients.Add to MCP Client Configuration Add the following to your
~/.cursor/mcp.jsonfile:
{
"mcpServers": {
"gdriveCF": {
"url": "https://your-worker-url/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY_FROM_STEP_9"
}
}
}
}Replace:
your-worker-urlwith your actual worker URLYOUR_API_KEY_FROM_STEP_9with the API key from the previous step.
Restart Cursor and you can now use @gdriveCF commands!
🔧 Google Workspace Setup
For Local MCP (Service Account with Domain-wide Delegation)
Prerequisites: You must be a Google Workspace admin for your domain.
1. Create Project and Enable APIs
Go to Google Cloud Console
Create a new project or select existing one
Enable these APIs:
2. Create Service Account
Go to IAM & Admin > Service Accounts
Click Create Service Account
Fill in details:
Name:
gdrive-mcp-serverDescription:
Service account for Google Docs MCP server
Click Create and Continue
Skip role assignment (not needed for domain-wide delegation)
Click Done
3. Generate Service Account Key
Click on your newly created service account
Go to Keys tab
Click Add Key > Create new key
Choose JSON format
Download the JSON file and save it securely (e.g.,
service-account.json)
4. Configure Domain-wide Delegation
Step A: Note the Client ID (Google Cloud Console)
In your service account details, copy the Client ID
Step B: Authorize Service Account (Google Admin Console)
Important: You must be a Google Workspace admin for this step.
Go to Google Admin Console
Click Add new
Enter the Client ID from Step A
In OAuth scopes, enter exactly:
https://www.googleapis.com/auth/documents,https://www.googleapis.com/auth/drive⚠️ Critical: No spaces after the comma, exact URLs as shown
Click Authorize
Wait 5-10 minutes for changes to propagate
For Cloudflare Workers (OAuth 2.0)
1. Configure OAuth Consent Screen
Go to APIs & Services > OAuth consent screen
Choose External user type
Fill required fields:
App name: "GDrive MCP Server"
User support email: your email
Developer contact: your email
Add scopes:
https://www.googleapis.com/auth/documentshttps://www.googleapis.com/auth/drive.readonlyopenid,profile,email
These are the scopes requested by the Worker code. Local service-account authorization above separately requests documents + drive. Export integration makes no OAuth scope change or token migration; existing granted scopes and file permissions still require validation.
2. Create OAuth Credentials
Go to APIs & Services > Credentials
Click Create Credentials > OAuth 2.0 Client IDs
Application type: Web application
Name: "GDrive MCP Server"
Authorized redirect URIs:
https://your-worker.workers.dev/callback(replace with your actual worker URL)
🔐 Authentication Flow
Local MCP Server
Service Account: Uses JSON key file for authentication
Domain-wide Delegation: Impersonates your Google Workspace user
Direct API Access: No OAuth needed, direct API calls
Stdio Transport: Communicates with Cursor or Claude via stdin/stdout
Cloudflare Workers
Web OAuth: User authenticates via
/authendpoint onceToken Storage: Access/refresh tokens stored in Cloudflare KV
API Key: Long-lived API key for MCP client authentication
Auto Refresh: Worker automatically refreshes Google tokens
HTTPS Transport: MCP client connects via HTTPS with API key
🐛 Troubleshooting
Common Issues
"OAuth Error: redirect_uri_mismatch"
Ensure redirect URI in Google Console exactly matches your worker URL
Example:
https://gdrive-mcp-server.your-subdomain.workers.dev/callback
"Tools not found" in Cursor
Verify your
~/.cursor/mcp.jsonfile is correctCheck that absolute paths are used in the configuration
Restart Cursor after making configuration changes
Test the MCP server manually:
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | npm run start:mcp
Build errors
Use
npm run build:mcpfor local development (notnpm run build)
"Unauthorized_client" error with service account
Verify domain-wide delegation is configured in Google Admin Console
Check that OAuth scopes are exactly:
https://www.googleapis.com/auth/documents,https://www.googleapis.com/auth/driveEnsure
GOOGLE_USER_EMAILmatches your Google Workspace domainWait 5-10 minutes after configuring domain-wide delegation
"Service account authentication failed"
Check that
GOOGLE_SERVICE_ACCOUNT_PATHpoints to the correct JSON fileVerify the service account JSON file is valid
Ensure you're a Google Workspace admin (domain-wide delegation requires admin access)
🔒 Security Features
Service Account Authentication: Secure authentication with Google Workspace
Domain-wide Delegation: Admin-controlled access to organizational docs
Token Management: Secure handling of authentication tokens
Input Validation: All inputs validated and sanitized
Minimal Permissions: Only requests necessary Google API scopes
📊 Performance Features
Large Document Handling: Automatic chunking and streaming for big docs
Request Timeouts: Prevents hanging requests
Memory Management: Size limits and safe processing
Error Recovery: Graceful handling of API failures
💡 Use Cases
Documentation Management: AI-powered document creation and updates
Content Analysis: Extract insights from document collections
Automated Reporting: Generate reports directly in Google Docs
Research Assistant: AI help with document research and organization
Project Management: Update project docs with status and progress
Meeting Notes: AI-assisted note-taking and document updates
🔗 Related Projects
📄 License
MIT License - see LICENSE file for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
DocBase MCP server for AI agents
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceA Model Context Protocol server that enables AI assistants like Claude to read from, append to, and format text in Google Documents programmatically.2,377 npm661MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol server that enables AI agents to interact with Google Workspace services including Drive, Docs, and Sheets through natural language commands.8MIT
- AlicenseCqualityDmaintenanceA Model Context Protocol server that provides an interface for AI models to interact with Google Docs, enabling reading, creating, updating, and searching Google Documents.449 npmMIT
- AlicenseBqualityDmaintenanceA Model Context Protocol (MCP) server that connects AI agents to Google Workspace (Gmail, Calendar, Drive, Docs, Sheets, and Slides).302MIT