Google Drive MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone https://github.com/dylancaponi/gdrive-mcp-server.git
cd gdrive-mcp-server
npm install
npm run build
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add gdrive-mcp-server -- node "<FULL_PATH_TO_GDRIVE_MCP_SERVER>/dist/index.js"

Replace <FULL_PATH_TO_GDRIVE_MCP_SERVER>/dist/index.js with the actual folder you prepared in step 1.

README.md

An actively maintained fork of the official Google Drive MCP server

Google Drive MCP Server

An actively maintained fork of Anthropic's archived `@modelcontextprotocol/server-gdrive`, with a critical bug fix for OAuth token auto-refresh.

Why this fork?

The original server was archived on May 29, 2025 and is no longer maintained. It also has a bug that causes OAuth access tokens to expire after 1 hour with no auto-refresh, requiring manual token rotation and server restarts.

The bug: The original creates new google.auth.OAuth2() without passing client_id and client_secret, so the google-auth-library has no way to use the refresh_token to get new access tokens. One-line fix, but the archived repo doesn't accept PRs.

What's fixed

  • Auto-refresh tokens: OAuth2 client is initialized with client_id and client_secret from your OAuth keys file, enabling the Google auth library to automatically refresh expired access tokens
  • Token persistence: Refreshed tokens are written back to the credentials file, so restarts also pick up valid tokens
  • Input validation: Added validation for resource URIs, search queries, and file IDs
  • Search results include file IDs: So you can actually use them with the download tool or resource reader
  • Read tool: Read file contents inline (Google Docs as Markdown, Sheets as CSV, etc.)
  • Download tool: Save files to a local directory instead of returning base64 blobs that overflow LLM context windows
  • Sheets read tool: Read Google Sheets with A1 range notation, returned as formatted markdown tables
  • Shared Drive support: Search and read files from Shared Drives (formerly Team Drives)
  • Folder listing: Browse Drive folders by ID
  • PDF export: Export Google Workspace files as PDF
  • File upload: Push local files to Drive (opt-in, requires drive scope)
  • Opt-in resources: MCP resource handlers are disabled by default to prevent hangs in clients that call resources/list on startup

Setup

1. Create Google Cloud OAuth credentials

  1. Go to the Google Cloud Console
  2. Create a project (or use an existing one)
  3. Enable the Google Drive API and Google Sheets API
  4. Create OAuth 2.0 credentials (Desktop application type)
  5. Download the JSON and save it as gcp-oauth.keys.json

Tip: If your OAuth consent screen is in "Testing" mode, refresh tokens expire after 7 days. Publish to "Production" for permanent refresh tokens.

2. Clone, build, and star

git clone https://github.com/dylancaponi/gdrive-mcp-server.git
cd gdrive-mcp-server
npm install && npm run build
gh api user/starred/dylancaponi/gdrive-mcp-server -X PUT

Per the LICENSE, starring this repository is required (Section 2).

3. Authenticate

GDRIVE_OAUTH_PATH=/path/to/your/gcp-oauth.keys.json node dist/index.js auth

This opens a browser for Google OAuth consent and saves credentials to ~/.gdrive-server-credentials.json.

4. Configure in Claude Code

Add to your ~/.claude.json (global) or project .mcp.json:

{
  "mcpServers": {
    "gdrive": {
      "type": "stdio",
      "command": "node",
      "args": ["/path/to/gdrive-mcp-server/dist/index.js"],
      "env": {
        "GDRIVE_OAUTH_PATH": "/path/to/gcp-oauth.keys.json",
        "GDRIVE_CREDENTIALS_PATH": "/path/to/.gdrive-server-credentials.json"
      }
    }
  }
}

Or use the Claude Code CLI:

claude mcp add --scope user gdrive -- node /path/to/gdrive-mcp-server/dist/index.js

Environment variables

Variable Default Description
GDRIVE_CREDENTIALS_PATH ~/.gdrive-server-credentials.json Path to saved OAuth credentials
GDRIVE_OAUTH_PATH gcp-oauth.keys.json (relative to package) Path to OAuth client keys
GDRIVE_ENABLE_RESOURCES false Set to true to enable MCP resource handlers (gdrive:/// URIs). Disabled by default because some MCP clients call resources/list on startup, which triggers drive.files.list() and can hang.
GDRIVE_ENABLE_SHEETS false Set to true to enable the sheets_read tool and request the spreadsheets.readonly OAuth scope. Requires enabling the Google Sheets API in your GCP project and re-running auth.
GDRIVE_ENABLE_UPLOAD false Set to true to enable the upload tool. Upgrades the OAuth scope from drive.readonly to drive (full read/write). Requires re-running auth.
GDRIVE_DOWNLOAD_DIR System temp dir + /gdrive-downloads Directory where the download and export_pdf tools save files

Tools

`search`

Search for files in Google Drive by full-text query. Searches across personal and Shared Drives.

{ "query": "quarterly report" }

Returns file names, MIME types, and IDs.

`read`

Read

Tools (6)

searchSearch for files in Google Drive by full-text query.
readRead file contents inline, including converting Google Docs to Markdown and Sheets to CSV.
downloadSave files to a local directory.
sheets_readRead Google Sheets with A1 range notation, returned as formatted markdown tables.
uploadPush local files to Drive.
export_pdfExport Google Workspace files as PDF.

Environment Variables

GDRIVE_CREDENTIALS_PATHPath to saved OAuth credentials
GDRIVE_OAUTH_PATHPath to OAuth client keys
GDRIVE_ENABLE_RESOURCESSet to true to enable MCP resource handlers
GDRIVE_ENABLE_SHEETSSet to true to enable the sheets_read tool
GDRIVE_ENABLE_UPLOADSet to true to enable the upload tool
GDRIVE_DOWNLOAD_DIRDirectory where the download and export_pdf tools save files

Configuration

claude_desktop_config.json
{"mcpServers": {"gdrive": {"type": "stdio", "command": "node", "args": ["/path/to/gdrive-mcp-server/dist/index.js"], "env": {"GDRIVE_OAUTH_PATH": "/path/to/gcp-oauth.keys.json", "GDRIVE_CREDENTIALS_PATH": "/path/to/.gdrive-server-credentials.json"}}}}

Try it

Search for the 'Q3 Financial Report' in my Google Drive.
Read the contents of the Google Doc with ID 1abc123 and summarize the key points.
Download the spreadsheet 'Project Roadmap' to my local machine.
Export the document 'Meeting Notes' as a PDF.
Read the data from the 'Sales' sheet in the spreadsheet with ID 1xyz789.

Frequently Asked Questions

What are the key features of Google Drive MCP Server?

Automatic OAuth token refresh for uninterrupted access. Converts Google Workspace documents to Markdown or CSV for LLM consumption. Supports searching and reading files from Shared Drives. Allows downloading files directly to a local directory. Supports file uploads and PDF exports.

What can I use Google Drive MCP Server for?

Summarizing long Google Docs directly within the Claude interface. Analyzing data from Google Sheets by reading them as formatted markdown tables. Managing project documentation by searching and downloading files from Shared Drives. Automating the conversion of Google Workspace files to local formats for offline use.

How do I install Google Drive MCP Server?

Install Google Drive MCP Server by running: git clone https://github.com/dylancaponi/gdrive-mcp-server.git && cd gdrive-mcp-server && npm install && npm run build

What MCP clients work with Google Drive MCP Server?

Google Drive MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Google Drive MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare