Cloud Services·
intermediate
·11 min read·Apr 4, 2026

How to Use the Google Drive MCP Server for Document Access

Connect Google Drive to your AI agent for searching, reading, and managing documents, spreadsheets, and files stored in your Drive.

Google Drivecloud storagedocumentsGoogle Workspacefiles

Use the Google Drive MCP Server

The Google Drive MCP server enables AI agents to search your Google Workspace environment and read files stored in your Drive, including Google Docs, Google Sheets, PDFs, and standard text files.

Prerequisites

  • A Google Cloud Platform (GCP) account.
  • OAuth 2.0 credentials configured for a Desktop Application.
  • Node.js 18+ installed on your host machine.

Setting Up Google Cloud Credentials

To authenticate the MCP server securely, you must provision an OAuth application:

  1. Go to the Google Cloud Console.
  2. Create a new project or select an existing one.
  3. Search for and enable the Google Drive API.
  4. Navigate to APIs & Services → Credentials.
  5. Click Create CredentialsOAuth client ID.
  6. Select Desktop App as the application type.
  7. Download the resulting credentials.json file or copy the Client ID and Secret.

Configuration Setup

Add the following to your MCP client config file:

json
{
  "mcpServers": {
    "gdrive": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-gdrive"],
      "env": {
        "GOOGLE_CLIENT_ID": "your-client-id.apps.googleusercontent.com",
        "GOOGLE_CLIENT_SECRET": "your-client-secret",
        "GOOGLE_REDIRECT_URI": "/callback"
      }
    }
  }
}

First-Time Authentication Flow

Because this MCP server uses OAuth 2.0, it requires human interaction on its first run:

  1. When the agent first attempts to use a tool, the MCP server will output a Google OAuth URL to the console (or try to pop open your browser).
  2. You must log into your Google Account and grant the application permission to access your Drive.
  3. The server captures the callback and saves a refresh_token locally, allowing the agent to run autonomously in the future.

Supported File Types & Conversions

The read_file tool automatically parses proprietary Google formats so your LLM can read them:

  • Google Docs: Converted to clean Markdown.
  • Google Sheets: Converted to CSV format.
  • PDF files: Raw text extraction.
  • Images: Metadata reading only.

Example Workflows

  • Research Assistant: "Search my Drive for all documents containing 'Q4 planning' and summarize the key objectives."
  • Document Analysis: "Read the 'Product Roadmap' Google Doc and create a timeline of milestones."
  • Cross-Reference: "Compare the data in the 'Sales Report Q3' spreadsheet with the 'Q3 Targets' document."

Troubleshooting

  • Unverified App Warning: When logging into Google during the OAuth flow, Google will show a stark warning saying the app is unverified. Since you created the GCP project yourself, it is perfectly safe to click Advanced → Go to app (unsafe).
  • Payload Too Large: If you ask the agent to read a 100-page PDF or a Sheet with 50,000 rows, the resulting text extraction will exceed the JSON-RPC maximum payload limits and crash the connection. Use targeted searches instead.

Using with OpenAI Codex

You can use this MCP server with the OpenAI Codex CLI by adding it to your configuration:

bash
codex mcp add --name google-drive --command "npx -y @modelcontextprotocol/server-google-drive"

Note: You will need to complete OAuth authentication on first run.

For a full list of recommended servers, see Best MCP Servers for OpenAI Codex.

Related Guides