mcp-gdrive is a Model Context Protocol (MCP) server for integration with Google Drive. It allows listing, reading, and searching files, and supports reading and writing Google Sheets. The project contains code originally developed by Anthropic, PBC and licensed under the MIT License.
Main capabilities (tools):
- gdrive_search: Search for files in Google Drive. Inputs include query (string, search query), pageToken (string, optional, token for the next page of results), pageSize (number, optional, number of results per page, maximum 100). Outputs the names and MIME types of matching files.
- gdrive_read_file: Read the contents of a file in Google Drive. The input is fileId (string, ID of the file to read). Outputs the contents of the specified file.
- gsheets_read: Read data from a Google spreadsheet, supporting flexible range and format options. Inputs include spreadsheetId (string, ID of the spreadsheet to read), ranges (array of strings, optional, A1 notation ranges, such as ['Sheet1!A1:B10']; if not provided, reads the entire sheet), sheetId (number, optional, specific sheet ID to read; if not provided with ranges, reads the first sheet). Outputs the specified data from the spreadsheet.
- gsheets_update_cell: Update a cell value in a Google spreadsheet. Inputs include fileId (string, spreadsheet ID), range (string, cell range in A1 notation, such as 'Sheet1!A1'), value (string, new cell value). Outputs confirmation of the updated value in the specified cell.
File access: The server provides access to Google Drive files (gdrive:///<file_id>), supporting all file types. Google Workspace files are automatically exported: Docs → Markdown, Sheets → CSV, Presentations → plain text, Drawings → PNG; other files are provided in their original format.
Usage:
- Create a new Google Cloud project
- Enable the Google Drive API
- Configure the OAuth consent screen (using "internal" is sufficient for testing)
- Add the OAuth scope https://www.googleapis.com/auth/drive.readonly and https://www.googleapis.com/auth/spreadsheets
- To allow interaction with sheets and docs, you also need to enable the Google Sheets API and Google Docs API in the "Enabled APIs and services" section of the workspace
- Create an OAuth client ID with the application type "Desktop App"
- Download the JSON file of the client OAuth key
- Rename the key file to gcp-oauth.keys.json and place it in the path specified by GDRIVE_CREDS_DIR (for example /Users/username/.config/mcp-gdrive)
- Note down the OAuth Client ID and Client Secret, which must be provided as environment variables along with the configuration directory
- You also need to set up a .env file in the project and fill in the corresponding fields; the Client ID and Client Secret can be found in the Credentials section of the Google Cloud Console
- Build the server using npm run build or npm run watch
- Run node ./dist/index.js to trigger the authentication step
- You will be prompted to authenticate through the browser, and you must authenticate using an account within the same organization as the Google Cloud project
- The OAuth token is saved in the directory specified by the GDRIVE_CREDS_DIR environment variable
Using with a desktop app: To integrate this server with a desktop app, add the relevant configuration to the app's server configuration.
License: This MCP server is licensed under the MIT License and may be freely used, modified, and distributed, subject to the terms and conditions of the MIT License. See the LICENSE file in the project repository for details.