GoogleDrive-mcp-server

VarnithChordia/GoogleDrive-mcp-server

3.1

If you are the rightful owner of GoogleDrive-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

Google Drive MCP Server is a protocol server designed to facilitate seamless integration and interaction with Google Drive using the Model Context Protocol (MCP).

Google Drive MCP Server

A Model Context Protocol (MCP) server for Google Drive that makes it easier to search, read, and extract information from documents—for example, quickly retrieving details needed when filling out forms. It is built with FastMCP, uses Google OAuth for authentication, and supports OCR to handle scanned PDFs and images


✨ Features

  • 🔍 Search: Query files in Google Drive by name, type, or content.
  • 📂 Read: Fetch and display file contents (text, PDFs, images).
  • 🔑 Secure Auth: Uses Google OAuth 2.0 for authentication.
  • MCP Ready: Easily integrates into MCP clients.

Project Structure

.
├── src/
│   ├── server.py           # Entry point, starts the FastMCP server
│   ├── tools.py            # MCP tools (gdrive_search, read_file, etc.)
│   ├── auth.py             # Google OAuth / service account handling
│   ├── file_utils.py       # Helpers for reading Drive files, PDFs, images
│   └── config.py           # Config (scopes, constants)
├── pyproject.toml / requirements.txt
├── README.md
└── .gitignore


Authentication

There are two auth modes:

  1. OAuth Client (Interactive)

    • Recommended for local testing / personal use.
    • Requires credentials.json from Google Cloud Console. Store them in the ~/credentials folder.
    • On first run, you’ll be prompted to log in via browser.
  2. Service Account (Server-to-Server)

    • For automated deployments.
    • Requires a service account key JSON.
    • The service account must have access to the Drive files (share files/folders with its email).

Sensitive documents: No file content is stored locally;


🛠 MCP Tools

Currently implemented:

  • gdrive_search(query: str)
    Search files in Google Drive. Returns metadata (id, name, mimeType).

  • read_file(file_id: str)
    Download and return file content.

    • Text → returned as string.
    • PDFs → extracted text (if text-based) or OCR (if scanned).
    • Images → OCR text extraction.

Running Locally

With Poetry

poetry install
poetry run python src/server.py


## Configuring MCP Desktop Claude

To connect this server with **MCP Desktop (Claude)**, update your Claude config file (usually located at `~/.mcp/config.json`) to include the `gdrive` server.

Example config snippet:

```json
{
  "mcpServers": {
    "gdrive": {
      "command": "poetry",
      "args": [
        "run",
        "python",
        "src/server.py"
      ],
      "env": {
        "GOOGLE_APPLICATION_CREDENTIALS": "credentials.json"
      }
    }
  }
}