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"
      }
    }
  }
}