Enables retrieval of document contents, listing and creating comments, replying to comment threads, and inserting/updating/removing auto-numbered styled note blocks within documents.
Provides tools for searching files across Google Drive, accessing document contents, managing comments and replies, and inserting styled note blocks into documents.
gdrive-mcp
A Model Context Protocol (MCP) server that provides access to Google Drive documents.
Features
search_drive: Search for files and documents across all of Google Drive
get_doc_contents: Retrieve the full text contents of a Google Doc by URL or document ID
list_doc_comments: List all comment threads on a Google Doc with details
create_doc_comment: Create unanchored comments on a Google Doc
reply_to_comment: Reply to existing comment threads
insert_doc_note: Insert auto-numbered styled note blocks (π NOTE 1:, π NOTE 2:, etc.) into document content
update_doc_note: Update the text of an existing note by its number
remove_doc_note: Remove a note from the document by its number
Installation
No installation needed! Use bunx to run directly, or clone from source.
Option 1: Use with bunx (Recommended)
No installation required - bunx will download and cache the package automatically.
Option 2: Clone from Source
Quick Start
2. Create Google OAuth2 Credentials
You need to create your own OAuth2 credentials from Google Cloud Console.
π See detailed instructions: docs/CREATE_OAUTH_CREDENTIALS.md
Quick version:
Go to Google Cloud Console
Create a project and enable Google Drive API + Google Docs API
Create OAuth 2.0 Desktop credentials
Copy your Client ID and Client Secret
3. Run the OAuth Setup
The setup script will open your browser and handle the OAuth2 flow:
With bunx (recommended):
If cloned from source:
This will:
β Open your browser for Google authorization
β Handle the OAuth2 callback automatically
β Securely store credentials in your system keychain
β Display configuration ready to copy
Example output:
4. Configure MCP Client
Add the server to your MCP client configuration.
Note: Credentials are securely stored in your system keychain (macOS Keychain, Linux libsecret, or Windows Credential Manager) - no need to add them to config files!
OpenCode
Add to your opencode.jsonc:
With bunx (recommended):
If cloned from source:
Claude Desktop
Add to your Claude Desktop configuration:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
With bunx (recommended):
If cloned from source:
Usage
Available Tools
search_drive
Search for files and documents across all of Google Drive using text queries.
Parameters:
query(string): Search query text. Supports Google Drive search syntax:Simple text:
"quarterly report"- searches in file names and contentBy name:
name:report- searches only file namesBy type:
type:document- filters by file typeCombined:
type:spreadsheet budget- combines filters
max_results(number, optional): Maximum number of results to return (default: 10, max: 100)
Returns:
File name, type, ID, modification date, owner, size, and view link for each matching file
Examples:
get_doc_contents
Retrieves the full text contents of a Google Doc.
Parameters:
doc_id_or_url(string): Either a full Google Docs URL or just the document ID
Examples:
URL:
https://docs.google.com/document/d/1a2b3c4d5e6f7g8h9i0j/editDocument ID:
1a2b3c4d5e6f7g8h9i0j
list_doc_comments
Lists all comment threads on a Google Doc, including quoted text, replies, and status.
Parameters:
doc_id_or_url(string): Google Docs URL or document ID
create_doc_comment
Creates an unanchored comment on a Google Doc (appears in "All Comments" view).
Parameters:
doc_id_or_url(string): Google Docs URL or document IDcomment(string): The comment text to add
Note: Due to Google Drive API limitations, comments cannot be anchored to specific text selections.
reply_to_comment
Replies to an existing comment thread on a Google Doc.
Parameters:
doc_id_or_url(string): Google Docs URL or document IDcomment_id(string): The ID of the comment to reply toreply(string): The reply text
insert_doc_note
Inserts an auto-numbered styled note block directly into the document content. Notes are automatically numbered sequentially (π NOTE 1:, π NOTE 2:, etc.). This is a workaround for the API's inability to create anchored comments or suggestions. The note appears as a visually distinctive block with:
Auto-incrementing note numbers
Colored background (light yellow/cream)
Indentation and spacing
Bold, colored header
Normal text size for readability
Parameters:
doc_id_or_url(string): Google Docs URL or document IDsearch_text(string): Exact text to search for; note will be inserted after the paragraph containing this textnote(string): The note text (the "π NOTE #:" prefix is added automatically)
Example:
This will insert a styled block with a yellow background that looks like:
(with indentation, yellow background, and spacing)
update_doc_note
Updates the text of an existing note by its number. The note number and formatting remain the same.
Parameters:
doc_id_or_url(string): Google Docs URL or document IDnote_number(number): The note number to update (e.g., 1 for π NOTE 1:)new_text(string): The new note text (without the 'π NOTE #:' prefix)
remove_doc_note
Removes a note from the document by its number. This completely deletes the note block including all formatting.
Parameters:
doc_id_or_url(string): Google Docs URL or document IDnote_number(number): The note number to remove (e.g., 1 for π NOTE 1:)
Testing the Server
After running the OAuth setup, you can test the server directly:
The server will load credentials from your system keychain automatically.
Troubleshooting
"Access blocked: Authorization Error - OAuth client was not found"
This error means you're using placeholder/invalid credentials. You need to:
Create your own OAuth2 credentials (see docs/CREATE_OAUTH_CREDENTIALS.md)
Run the setup script with YOUR credentials
"No refresh token received"
If you've authorized the app before:
Go to https://myaccount.google.com/permissions
Remove the "gdrive-mcp" app
Run setup again
Port 48127 already in use
Change the REDIRECT_PORT in src/setup-auth.ts to a different port.
Development
Linting and Formatting
This project uses Biome for linting and formatting:
How It Works
This MCP server uses OAuth2 with a browser-based consent flow, similar to popular tools like rclone:
Setup phase: Run
src/setup-auth.tswhich starts a local callback server and opens your browserAuthorization: You approve the app in Google's OAuth consent screen
Token exchange: The auth code is exchanged for a refresh token
Secure storage: Credentials are stored in your system keychain using Bun.secrets
Runtime: The MCP server loads credentials from the keychain and uses the refresh token to get temporary access tokens
Secure Credential Storage
Unlike other tools that store credentials in plaintext .env files, gdrive-mcp uses Bun's native secrets API to store credentials securely:
macOS: Keychain Services
Linux: libsecret (GNOME Keyring, KWallet, etc.)
Windows: Windows Credential Manager
Your OAuth credentials are:
β Encrypted at rest by the operating system
β Protected with user-level access control
β Never stored in plaintext configuration files
β Automatically available to the MCP server without env vars
This is the most user-friendly and secure approach used by modern CLI tools.
License
MIT