mcp-google-drive

ghchinoy/mcp-google-drive

3.2

If you are the rightful owner of mcp-google-drive 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.

This is an MCP server for the Google Drive API, written in Go.

Tools
  1. listFiles

    Lists the first 10 files in your Google Drive.

  2. getFile

    Retrieves metadata for a specific file, with an option to get full content.

  3. searchFiles

    Searches for files in your Google Drive.

  4. getVersion

    Returns the version of the MCP Drive server.

Google Drive MCP Server

This is an MCP server for the Google Drive API, written in Go.

Prerequisites

  • Go 1.24 or later
  • A Google Cloud Platform project with the Drive API enabled

Setup

  1. Install dependencies:

    go mod tidy
    
  2. Create a credentials.json file:

    • Go to the Google Cloud Console.
    • Create a new project or select an existing one.
    • Enable the Google Drive API.
    • Create an OAuth 2.0 Client ID for a "Desktop app".
    • Download the JSON file and save it as credentials.json in the mcp-google-drive directory.

Running the Server

The server can be run in two modes: STDIO and HTTP.

Credentials

The path to the credentials.json file can be provided in three ways, in order of precedence:

  1. --credentials flag:

    go run . --credentials /path/to/your/credentials.json
    
  2. MCP_DRIVE_CREDENTIALS environment variable:

    export MCP_DRIVE_CREDENTIALS=/path/to/your/credentials.json
    go run .
    
  3. Default path: If neither the flag nor the environment variable is set, the server will look for credentials.json in the current directory.

STDIO Mode (Default)

This mode is useful for local development and testing.

go run .

HTTP Mode

This mode exposes the server over HTTP.

go run . --transport http

The server will be available at http://localhost:8080/mcp.

Authentication

The first time you run the server, it will automatically open your web browser to a Google consent page. After you grant access, the server will automatically receive the authorization token and save it in a token.json file. This file will be used for all future requests.

Usage

Once authenticated, you can use the following tools:

  • listFiles: Lists the first 10 files in your Google Drive.
  • getFile: Retrieves metadata for a specific file. Use the fullContent parameter to retrieve the full content of a Google Doc, Sheet, or Presentation.
  • searchFiles: Searches for files in your Google Drive. You can search by title (default) or by content. To search by content, use the searchIn parameter with the value content.
  • getSheet: Retrieves an entire Google Sheet.
  • getSheetRange: Retrieves a specific range of rows or columns from a Google Sheet.
  • getVersion: Returns the version of the MCP Drive server.

Command-line Testing

To verify that the server is working correctly without having to interact with the MCP server, you can use the following flags:

  • --test-auth: This flag will initiate the authentication flow if a token.json file is not present. If a token.json file is present, it will verify that the token is still valid.
  • --test-list: This flag will list the first 10 files in your Google Drive to the console.
  • --test-get-sheet <spreadsheetId>: This flag will retrieve the specified Google Sheet.
  • --test-get-sheet-range <spreadsheetId> <range>: This flag will retrieve the specified range from the specified Google Sheet.

These flags are useful for command-line creation of the token.json file (if needed) and for testing the listing of files to verify that the server works without MCP.

Disclaimer

This is not an official Google project.