Google Drive MCP server

Search and access Google Drive files and folders via read-only API.
Back to servers
Provider
Anthropic
Release date
Nov 19, 2024
Language
TypeScript
Package
Stats
13.5K downloads
41.6K stars

The Google Drive MCP server integrates with Google Drive, allowing you to list, read, and search over your files. It provides an interface to access Google Drive content through the Model Context Protocol, with automatic export of Google Workspace files to compatible formats.

Installation

Prerequisites

  1. Create a new Google Cloud project
  2. Enable the Google Drive API
  3. Configure an OAuth consent screen ("internal" is fine for testing)
  4. Add OAuth scope https://www.googleapis.com/auth/drive.readonly
  5. Create an OAuth Client ID for application type "Desktop App"
  6. Download the JSON file of your client's OAuth keys
  7. Rename the key file to gcp-oauth.keys.json and place it in the appropriate location

Building the Server

Build the server with either:

npm run build

or for development with auto-rebuild:

npm run watch

Authentication

To authenticate and save credentials:

  1. Run the server with the auth argument:
    node ./dist auth
    
  2. This will open an authentication flow in your system browser
  3. Complete the authentication process
  4. Credentials will be saved as .gdrive-server-credentials.json

Usage

Features

The server provides two main components:

  • Search Tool: Search for files in your Google Drive using a query string
  • File Resources: Access files via gdrive:///<file_id> URI format

Google Workspace files are automatically exported to these formats:

  • Google Docs → Markdown
  • Google Sheets → CSV
  • Google Presentations → Plain text
  • Google Drawings → PNG

Integration with Desktop App

Docker Method

For authentication with Docker:

docker run -i --rm --mount type=bind,source=/path/to/gcp-oauth.keys.json,target=/gcp-oauth.keys.json -v mcp-gdrive:/gdrive-server -e GDRIVE_OAUTH_PATH=/gcp-oauth.keys.json -e "GDRIVE_CREDENTIALS_PATH=/gdrive-server/credentials.json" -p 3000:3000 mcp/gdrive auth

Open the URL displayed in your browser and complete the authentication process.

Once authenticated, add this configuration to your app:

{
  "mcpServers": {
    "gdrive": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "-v", "mcp-gdrive:/gdrive-server", "-e", "GDRIVE_CREDENTIALS_PATH=/gdrive-server/credentials.json", "mcp/gdrive"]
    }
  }
}

NPX Method

Add this configuration to your app:

{
  "mcpServers": {
    "gdrive": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-gdrive"
      ]
    }
  }
}

Integration with VS Code

Manual Installation

Add one of the following configurations to your VS Code User Settings (JSON):

NPX Method:

{
  "mcp": {
    "servers": {
      "gdrive": {
        "command": "npx",
        "args": [
          "-y",
          "@modelcontextprotocol/server-gdrive"
        ],
        "env": {
          "GDRIVE_CREDENTIALS_PATH": "/path/to/.gdrive-server-credentials.json"
        }
      }
    }
  }
}

Docker Method:

{
  "mcp": {
    "servers": {
      "gdrive": {
        "command": "docker",
        "args": [
          "run",
          "-i",
          "--rm",
          "-v",
          "mcp-gdrive:/gdrive-server",
          "-e",
          "GDRIVE_CREDENTIALS_PATH=/gdrive-server/credentials.json",
          "mcp/gdrive"
        ]
      }
    }
  }
}

Alternatively, you can add the configuration to .vscode/mcp.json in your workspace (without the mcp key).

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later