Skip to main content
Glama
HydroChlorix

Google Drive MCP Server

by HydroChlorix

📁 Google Drive MCP Server (Least Privilege Key)

Enterprise-grade Google Drive integration for AI assistants — seamless Shared Drive boundary control, Least Privilege Key Authentication, and real-time audit logging for Gemini, Claude, Cursor, and more.

npm version npm downloads Node.js Version TypeScript Biome Formatted Least Privilege Key License: MIT MCP Spec Version Buy Me A Coffee

An MCP server providing secure Google Drive access to AI assistants using Least Privilege Key Authentication, Application Default Credentials (ADC), and Service Account Impersonation.


⚡ Quick Start

Add to your MCP client configuration (e.g., claude_desktop_config.json, mcp_config.json, or Cursor):

{
  "mcpServers": {
    "googledrive": {
      "command": "npx",
      "args": ["-y", "@hydrochlorix/googledrive-mcp-server"],
      "env": {
        "GOOGLE_DRIVE_SHARED_DRIVE_ID": "<YOUR_SHARED_DRIVE_ID>",
        "GOOGLE_DRIVE_ROOT_FOLDER_ID": "<OPTIONAL_ROOT_FOLDER_ID>"
      }
    }
  }
}
CAUTION

MANDATORY BOUNDARY (v2.3.0+) GOOGLE_DRIVE_SHARED_DRIVE_ID is MANDATORY. The server will refuse to start without a configured Shared Drive boundary. GOOGLE_DRIVE_ROOT_FOLDER_ID is optional for further narrowing the boundary.

[!WARNING] STRUCTURED OPERATION LOGGING (v2.4.0+) Direct console.error() calls have been eliminated. All process lifecycle events and crash tracebacks are written to a persistent NDJSON file at ~/.mcp/logs/operation.log with clean [LEVEL] message output on stderr. Raw OAuth JSON responses (invalid_grant, invalid_rapt) are automatically sanitized into human-readable messages with actionable hint remediation steps.


Related MCP server: mcp-google-drive

✨ Features

  • 🛡️ Least Privilege Key Security: Supports Service Account JSON keys alongside Application Default Credentials (ADC) while strongly enforcing Drive and Root Folder boundaries.

  • 🎯 Two-Layer Boundary Control: Combined mandatory Shared Drive boundary with an optional narrower Root Folder boundary (GOOGLE_DRIVE_ROOT_FOLDER_ID).

  • 🏢 Google Workspace Shared Drive Support: Full support for enterprise Shared Drives (supportsAllDrives: true) for 24/7 automation.

  • 📋 Structured Operation Logger: Machine-readable NDJSON process log (~/.mcp/logs/operation.log) with crash reporting, zero-dependency sync durability, and automatic credential sanitization.

  • 📂 Automatic Local Destination Folders: Missing local directory structures are created automatically when downloading files.

  • 📄 Auto-Text Workspace Docs Export: Automatically converts Google Workspace Docs/Sheets to plain text (text/plain) for immediate consumption by LLMs.

  • 📊 Real-time Audit Dashboard: Built-in SQLite WAL logger (~/.mcp/audit.db), REST API, SSE streaming, and a glassmorphism web SPA dashboard (default http://127.0.0.1:3001).

  • 🔒 Read-only Enforcement: Option to restrict tool registration to read-only tools via GOOGLE_DRIVE_MODE="readonly".


💡 Why @hydrochlorix/googledrive-mcp-server?

Feature

Legacy SA Key JSON

OAuth 2.0 Client Secret

@hydrochlorix/googledrive-mcp-server

Authentication

Long-lived Private Key

User Refresh Tokens

Least Privilege Key / ADC / Impersonation

Credentials on Disk

⚠️ High Risk (.json)

⚠️ Plaintext Tokens

✓ Supported (Keyless or Key-based)

Shared Drive Support

Partial

Partial

✓ Full Enterprise Support

Boundary Guardrail

✗ None

✗ None

✓ Shared Drive + Root Folder Boundary

Audit & Logging

✗ Console Log

✗ Console Log

✓ Embedded Dashboard & SQLite Engine

Read-Only Mode

✗ Manual Code Edit

✗ Scope Editing

✓ Environment Variable (GOOGLE_DRIVE_MODE)


🏗️ How It Works

AI Assistant (e.g. Gemini / Claude / Cursor)
       │  MCP Protocol (stdio)
       ▼
googledrive-mcp-server (Node.js Process)
       │  Google Auth Application Default Credentials (ADC)
       ▼
Google Cloud IAM (Service Account Impersonation)
       │  Short-Lived Access Token (OAuth2)
       ▼
Google Drive API v3 (Shared Drive Boundary Enforcement)

🛠️ Tools

1. drive_list_files (Read)

List files and folders in Google Drive within configured boundaries.

  • pageSize (number, optional): Maximum number of items to return (1-100, default: 10).

  • query (string, optional): Search query string (e.g. name contains 'Report').

2. drive_download_file (Read)

Download a file from Google Drive to local disk.

  • fileId (string, required): The ID of the file to download.

  • destPath (string, required): Local file path where the file will be saved. Missing parent directories are created automatically.

3. drive_download_file_from_url (Read)

Download a file using a public/shared Google Drive URL.

  • url (string, required): Full Google Drive shareable link.

  • destPath (string, required): Local file destination path.

4. drive_create_folder (Write)

Create a new folder inside Google Drive.

  • name (string, required): Name of the folder.

  • parentId (string, required): Parent folder ID within boundary.

5. drive_upload_text_file (Write)

Upload a text file to Google Drive.

  • name (string, required): File name.

  • content (string, required): Text file contents.

  • parentId (string, required): Parent folder ID within Shared Drive.

Note: Setting GOOGLE_DRIVE_MODE="readonly" hides write tools (drive_create_folder, drive_upload_text_file).


🚀 Setup & Authentication (3 Steps)

Step 1: One-Time Google Cloud IAM Setup

gcloud config set project <PROJECT_ID>
gcloud services enable drive.googleapis.com iamcredentials.googleapis.com --project="<PROJECT_ID>"

# Grant Impersonation Permission to your user account
gcloud iam service-accounts add-iam-policy-binding <SERVICE_ACCOUNT_EMAIL> \
    --member="user:<YOUR_WORKSPACE_EMAIL>" \
    --role="roles/iam.serviceAccountTokenCreator" \
    --project="<PROJECT_ID>"

Step 2: Configure Shared Drive Permissions

Add your Service Account email (<SERVICE_ACCOUNT_EMAIL>) as a member of your target Google Workspace Shared Drive (Viewer for read-only, Contributor for write access).

Step 3: Authenticate (Choose A or B)

Option A: Local Desktop (ADC / Impersonation) Run Application Default Credentials (ADC) login with impersonation:

# Desktop (GUI)
gcloud auth application-default login --impersonate-service-account="<SERVICE_ACCOUNT_EMAIL>"

# Headless (WSL / SSH)
gcloud auth application-default login --no-browser --impersonate-service-account="<SERVICE_ACCOUNT_EMAIL>"

Verify setup:

gcloud auth application-default print-access-token

Option B: Server / 24-7 Headless (Least Privilege Key) For servers where session controls cause ADC to expire daily, use a Service Account JSON Key:

  1. Ensure your Service Account has no project-level IAM roles (this enforces Least Privilege). It only needs to be invited directly to the target Google Workspace Shared Drive.

  2. Download the JSON key file to your server.

  3. Set the environment variable in your MCP client config or shell:

export GOOGLE_APPLICATION_CREDENTIALS="/absolute/path/to/service-account-key.json"

📊 Real-Time Audit & Governance Dashboard

Logs all MCP tool calls to SQLite (~/.mcp/audit.db) with zero performance overhead.

  • Dashboard Web UI: http://127.0.0.1:3001?token=<TOKEN>

  • REST Logs API: GET http://127.0.0.1:3001/api/audit/logs

  • SSE Stream: GET http://127.0.0.1:3001/api/audit/stream

  • Environment Options:

    • MCP_DASHBOARD_ENABLED=false — Disable dashboard server.

    • MCP_DASHBOARD_PORT=3001 — Change HTTP port.

    • MCP_DASHBOARD_TOKEN=<CUSTOM_TOKEN> — Set authentication token.

  • Generate Token: Run npx -- @hydrochlorix/googledrive-mcp-server --gen-token (or locally: npm run build && node dist/server.mjs --gen-token) to securely generate a 256-bit token.


💻 Development & Testing

  • Development Mode: npm run dev

  • Build Production: npm run build

  • Run Full Suite (Lint, Build & All Tests): npm run test:all

  • Run Unit Tests: npm test

  • Run Dashboard & Security Tests: npm run test:dashboard


❓ Troubleshooting

  • insufficient authentication scopes or 401/403 Permission Denied: Re-run gcloud auth application-default login --impersonate-service-account="<SERVICE_ACCOUNT_EMAIL>" (add --no-browser for headless/WSL).

  • invalid_rapt Reauthentication Error / Token Expiration: Token expiration is typically governed by your Google Workspace Admin's Session Control policies.

    • Local/Desktop: Perform a clean reset using gcloud auth revoke --all followed by gcloud auth application-default login --impersonate-service-account="<SERVICE_ACCOUNT_EMAIL>".

    • Server/Headless: If you need 24/7 uptime without manual re-auth, you may use a Service Account JSON Key as a fallback (ADR-0011) by setting export GOOGLE_APPLICATION_CREDENTIALS="/path/to/key.json".

  • Service Account Storage Quota Error: Service accounts do not have personal Drive storage quota. Ensure uploads target a Google Workspace Shared Drive.


💖 Support

If this project helped you, please consider supporting its development!


📜 License

Distributed under the MIT License.

Available Tools

4 tools
drive_create_folderB

Create a new folder in Google Drive

ParametersJSON Schema
NameRequiredDescriptionDefault
nameYesName of the new folder
parentIdYesID of the parent folder

TDQS

B3/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description carries the full burden. It merely states the action and doesn't disclose side effects, permission requirements, or behavior in edge cases (e.g., duplicate folder names).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that is direct and front-loaded, with no unnecessary verbiage. It is appropriately concise for a simple tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description should explain more about return values or side effects, but it only provides the basic purpose. The tool is simple, but the description is not complete enough to fully inform an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema provides full descriptions for both parameters (name and parentId), achieving 100% coverage. The description adds no additional parameter context, so the baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the specific verb 'Create' and resource 'new folder in Google Drive', clearly distinguishing it from sibling tools (list, upload, download). It clearly states the tool's function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description simply states the action without any context, exclusions, or prerequisite conditions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

drive_download_fileA

Download a binary or regular file from Google Drive to the local file system (Note: Cannot download Google Docs/Sheets directly).

ParametersJSON Schema
NameRequiredDescriptionDefault
fileIdYesID of the file to download
destPathYesLocal destination path (e.g. ./downloads/image.jpg)

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description carries the burden of behavioral disclosure. It states the action and a key limitation (cannot download Google Docs/Sheets), but does not mention authentication, overwrite behavior, or error handling. The disclosed limitation adds some value, but more transparency would be expected.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that front-loads the purpose ('Download a binary or regular file') and adds a parenthetical caveat. No waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple two-parameter download tool, the description covers the primary purpose and a critical limitation. Since there is no output schema, it could mention what happens after download (e.g., return value), but the simplicity of the tool makes this a minor gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% with both parameters (fileId, destPath) already described in the schema. The tool description adds no additional parameter-specific context, so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description names the specific verb 'Download' and the resource 'binary or regular file from Google Drive to the local file system', clearly distinguishing it from sibling tools like upload or list. The note about Google Docs/Sheets further refines its scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context by stating the tool downloads binary/regular files and explicitly warns it cannot handle Google Docs/Sheets, which implies not to use it for those. It does not name an alternative tool, but the limitation serves as a clear exclusion for some use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

drive_list_filesA

List files in Google Drive. You can specify pageSize (max 100) and a search query.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryNoGoogle Drive search query string (e.g. name contains "report")
pageSizeNoNumber of files to return (default 10)

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the behavioral burden. It adds that pageSize has a max of 100 and that a search query can be used, but does not disclose return format, pagination behavior beyond pageSize, or whether it is read-only (though implied). This is adequate but not rich.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, concise, and front-loaded with the main purpose. No wasted words or redundant details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple list tool with no output schema, the description covers the essential function and parameters. It could mention the return value (e.g., file metadata) but is otherwise sufficient given the tool's straightforward nature and clear sibling context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already explains the parameters. The description reiterates pageSize and query without adding new meaning, which aligns with the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool lists files in Google Drive, using a specific verb and resource. It naturally distinguishes itself from sibling tools (upload, create folder, download) by focusing on the read/list operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for listing or searching files and mentions configurable parameters (pageSize, query). It doesn't explicitly state when not to use it or compare to alternatives, but the sibling tools have obviously different purposes, so context is sufficient.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

drive_upload_text_fileB

Upload a text file to Google Drive

ParametersJSON Schema
NameRequiredDescriptionDefault
nameYesName of the file
contentYesText content of the file
parentIdYesID of the parent folder

TDQS

B3/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure, but it offers none beyond the action itself. It does not mention overwrite behavior, authentication requirements, return values, or side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no unnecessary words. It is maximally concise and wastes no tokens.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no output schema and no annotations, the description should provide more context about expected outcomes or side effects. It only states the action, leaving the agent without information about what the call returns or whether it can overwrite existing files.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already describes all three parameters with 100% coverage, so the description adds no additional semantic value. Baseline 3 applies because the schema fully covers parameter meaning.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the specific verb 'Upload' with a clear resource ('a text file to Google Drive'), distinguishing it from sibling tools like drive_list_files, drive_create_folder, and drive_download_file.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, and does not mention any exclusions or prerequisites. It simply states the action without contextual direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A3.6/5.0
Disambiguation5/5

Each tool targets a distinct action: list files, upload text, create folder, download file. No overlapping purposes.

Naming Consistency5/5

All tools follow the consistent 'drive_verb_noun' pattern (list_files, upload_text_file, create_folder, download_file).

Tool Count5/5

With 4 tools covering basic Drive operations, the count is well-scoped for a minimal but functional server.

Completeness2/5

The surface lacks update and delete operations, and upload is restricted to text files, leaving significant gaps in Drive management.

Maintenance

ActivityMaintained
ResponsivenessResponsive

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/HydroChlorix/googledrive-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server