Google Drive & Sheets MCP server

Integrates Google Drive and Sheets functionality for file operations and spreadsheet data manipulation.
Back to servers
Setup instructions
Provider
Phil Isaac
Release date
Dec 26, 2024
Language
TypeScript
Package
Stats
3.7K downloads
146 stars

This MCP server integrates with Google Drive, allowing you to search files, read file contents, and work with Google Sheets documents. It provides a structured way to interact with your Google Drive content through the Model Context Protocol.

Features

Available Tools

  • gdrive_search: Search for files in your Google Drive with filtering options
  • gdrive_read_file: Read the contents of any file from your Google Drive
  • gsheets_read: Read data from Google Spreadsheets with flexible range selections
  • gsheets_update_cell: Update cell values in Google Spreadsheets

Accessible Resources

The server provides access to Google Drive files using the format gdrive:///<file_id> and supports automatic file format conversion:

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

Installation

Prerequisites

Before installing the MCP Google Drive server, you'll need to set up a Google Cloud project with the necessary APIs:

  1. Create a new Google Cloud project
  2. Enable the Google Drive API
  3. Enable the Google Sheets API
  4. Enable the Google Docs API
  5. Configure an OAuth consent screen (select "internal" for testing)
  6. Add OAuth scopes:
    • https://www.googleapis.com/auth/drive.readonly
    • https://www.googleapis.com/auth/spreadsheets
  7. Create an OAuth Client ID for application type "Desktop App"
  8. Download the JSON file containing your OAuth credentials

Setup

  1. Install the package:

    npm install @isaacphi/mcp-gdrive
    
  2. Create a configuration directory:

    mkdir -p ~/.config/mcp-gdrive
    
  3. Move your OAuth credentials file to the configuration directory:

    mv ~/Downloads/client_secret_*.json ~/.config/mcp-gdrive/gcp-oauth.keys.json
    
  4. Create a .env file with your configuration:

    GDRIVE_CREDS_DIR=~/.config/mcp-gdrive
    CLIENT_ID=your-client-id
    CLIENT_SECRET=your-client-secret
    
  5. Build the server:

    npm run build
    

Authentication

To complete setup, you need to authenticate with Google:

  1. Start the server for the first time:

    node ./dist/index.js
    
  2. A browser window will open asking you to authenticate with your Google account

  3. Complete the authentication process

  4. Your OAuth token will be saved in your configuration directory

Usage

Starting the Server

Once configured, you can start the server by running:

node ./dist/index.js

Integration with Desktop Apps

To integrate this server with an MCP-compatible desktop application, add the following to your app's server configuration:

{
  "mcpServers": {
    "gdrive": {
      "command": "npx",
      "args": ["-y", "@isaacphi/mcp-gdrive"],
      "env": {
        "CLIENT_ID": "your-client-id",
        "CLIENT_SECRET": "your-client-secret",
        "GDRIVE_CREDS_DIR": "/path/to/config/directory"
      }
    }
  }
}

Example Tool Usage

Searching Files

// Search for Google Docs files containing "meeting notes"
const searchResults = await gdrive_search({
  query: "name contains 'meeting notes' and mimeType = 'application/vnd.google-apps.document'",
  pageSize: 10
});

Reading a File

// Read the contents of a file by its ID
const fileContents = await gdrive_read_file({
  fileId: "1aBcDeFgHiJkLmNoPqRsTuVwXyZ"
});

Working with Spreadsheets

// Read data from a Google Sheet
const sheetData = await gsheets_read({
  spreadsheetId: "1aBcDeFgHiJkLmNoPqRsTuVwXyZ",
  ranges: ["Sheet1!A1:D10"]
});

// Update a cell in a Google Sheet
const updateResult = await gsheets_update_cell({
  fileId: "1aBcDeFgHiJkLmNoPqRsTuVwXyZ",
  range: "Sheet1!B5",
  value: "Updated value"
});

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "gdrive" '{"command":"npx","args":["-y","@isaacphi/mcp-gdrive"],"env":{"CLIENT_ID":"<CLIENT_ID>","CLIENT_SECRET":"<CLIENT_SECRET>","GDRIVE_CREDS_DIR":"/path/to/config/directory"}}'

See the official Claude Code MCP documentation for more details.

For 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 > Tools & Integrations and click "New MCP Server".

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

{
    "mcpServers": {
        "gdrive": {
            "command": "npx",
            "args": [
                "-y",
                "@isaacphi/mcp-gdrive"
            ],
            "env": {
                "CLIENT_ID": "<CLIENT_ID>",
                "CLIENT_SECRET": "<CLIENT_SECRET>",
                "GDRIVE_CREDS_DIR": "/path/to/config/directory"
            }
        }
    }
}

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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "gdrive": {
            "command": "npx",
            "args": [
                "-y",
                "@isaacphi/mcp-gdrive"
            ],
            "env": {
                "CLIENT_ID": "<CLIENT_ID>",
                "CLIENT_SECRET": "<CLIENT_SECRET>",
                "GDRIVE_CREDS_DIR": "/path/to/config/directory"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

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