Skip to main content
Glama
yottabit42

Google Drive & Workspace MCP Server for Antigravity

by yottabit42
README.md
# Google Drive & Workspace MCP Server for Antigravity

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![MCP](https://img.shields.io/badge/MCP-Model%20Context%20Protocol-orange)](https://modelcontextprotocol.io/)

A Model Context Protocol (MCP) server that equips [Google Antigravity (`agy`)](https://github.com/google/antigravity) and other MCP-compliant agents with comprehensive tools to create, read, update, and search across Google Drive, Google Docs, Google Sheets, Google Slides, and Google Forms.

---

## šŸ› ļø Included Tools

### šŸ“ Google Drive
- **`gdrive_search`**: Search for files, folders, Docs, Sheets, and Slides using Drive queries (e.g. `name contains 'Report' and mimeType = 'application/vnd.google-apps.document'`).
- **`gdrive_list`**: List files and folders with optional parent folder filtering and page sizing.
- **`gdrive_create_folder`**: Create new folders/directories in Drive or within specific subfolders.

### šŸ“ Google Docs
- **`gdocs_create`**: Create a new Google Document with an optional initial text body and destination folder.
- **`gdocs_read`**: Extract and read text content, headings, and table data by Document ID.
- **`gdocs_modify`**: Append text, insert text at specific character indexes, or perform find-and-replace updates.

### šŸ“Š Google Sheets
- **`gsheets_create`**: Create a new Google Spreadsheet with custom sheet tab names and initial 2D cell row/column data.
- **`gsheets_read`**: Read spreadsheet metadata and retrieve cell values using standard A1 notation (e.g. `Sheet1!A1:D20`).
- **`gsheets_modify`**: Update cell values, append rows to tables, clear ranges, add or remove sheet tabs, or execute raw batch updates.

### šŸ“½ļø Google Slides
- **`gslides_create`**: Create a new Google Slides presentation with a title and optional destination folder.
- **`gslides_read`**: Inspect presentation structure, slides, text frames, shapes, and tables.
- **`gslides_modify`**: Create new slides (with custom predefined layouts), replace text across slides, insert text into shapes, create text boxes, or execute raw batch updates.

### šŸ“‹ Google Forms
- **`gforms_create`**: Create a new Google Form with title, description, and initial questions. Supports `TEXT`, `PARAGRAPH`, `RADIO`, `CHECKBOX`, `DROP_DOWN`, `SCALE`, `DATE`, `TIME`, and `SECTION_HEADER`.
- **`gforms_read`**: Read form structure, questions, items, edit URL, and responder URL by Form ID.
- **`gforms_modify`**: Update form metadata, add question items, delete items, or execute raw batch updates.
- **`gforms_read_responses`**: Fetch user responses, mapping question IDs to question titles with respondent emails and timestamps.

---

## šŸš€ Quick Setup Guide for Antigravity (`agy`)

### 1. Prerequisites: Google Cloud OAuth 2.0 Credentials
Each user authenticates with their own Google account:

1. Open the [Google Cloud Console](https://console.cloud.google.com).
2. Create a new Google Cloud Project (e.g., `Antigravity-Workspace-MCP`).
3. Navigate to **APIs & Services > Library** and enable the following 5 APIs:
   - **Google Drive API**
   - **Google Docs API**
   - **Google Sheets API**
   - **Google Slides API**
   - **Google Forms API**
4. Navigate to **APIs & Services > OAuth consent screen**:
   - Choose **External** user type and click **Create**.
   - Fill in required fields (App name: `Antigravity Workspace`, User support email, Developer email).
   - Under **Scopes**, click **Add or Remove Scopes** and add:
     - `https://www.googleapis.com/auth/drive`
     - `https://www.googleapis.com/auth/documents`
     - `https://www.googleapis.com/auth/spreadsheets`
     - `https://www.googleapis.com/auth/presentations`
     - `https://www.googleapis.com/auth/forms.body`
     - `https://www.googleapis.com/auth/forms.responses.readonly`
   - Under **Test users**, add your Google Account email address (the account that owns the Drive files you want to access).
   - Save and complete the consent screen setup.
5. Navigate to **APIs & Services > Credentials**:
   - Click **+ Create Credentials > OAuth client ID**.
   - Application type: **Desktop app** (or **Web application** with Authorized redirect URI `http://localhost:3000/oauth2callback`).
   - Click **Create**, then click **Download JSON**.
   - Save the downloaded JSON file to `~/.gemini/gdrive-credentials.json` on the machine running Antigravity.

---

### 2. Installation

Clone this repository to your global Antigravity MCP directory:

```bash
mkdir -p ~/.gemini/mcp-servers
git clone https://github.com/yottabit42/google_drive_mcp_antigravity.git ~/.gemini/mcp-servers/gdrive-mcp
cd ~/.gemini/mcp-servers/gdrive-mcp
npm install
```

---

### 3. Authenticate

Run the authorization script:

```bash
# Print the OAuth URL (ideal for remote, headless containers, or agent-assisted flow)
node auth.js --url
```

1. Open the printed authorization URL in your web browser.
2. Sign in with the Google Account added as a test user and click **Allow** on the consent screen.
3. The browser will redirect to `http://localhost:3000/oauth2callback?code=...`.
4. Copy either the full URL or the `code` parameter value from your browser address bar.
5. Finish token exchange by running:
   ```bash
   node auth.js "<PASTED_CODE_OR_REDIRECT_URL>"
   ```
6. The token is securely saved to `~/.gemini/gdrive-token.json`. Refresh tokens are automatically persisted when refreshed.

---

### 4. Configure Antigravity (`agy`)

Add the server to your Antigravity configuration at `~/.gemini/config/mcp_config.json`:

```json
{
  "mcpServers": {
    "google-drive": {
      "command": "node",
      "args": [
        "/root/.gemini/mcp-servers/gdrive-mcp/index.js"
      ],
      "env": {
        "GDRIVE_OAUTH_PATH": "/root/.gemini/gdrive-credentials.json",
        "GDRIVE_CREDENTIALS_PATH": "/root/.gemini/gdrive-token.json"
      }
    }
  }
}
```
*(Note: Replace `/root` with your actual home directory if running as a non-root user, or omit the `env` block to use the default `~/.gemini/` path).*

---

### 5. Verify Setup

Run the smoke test to verify API communication:

```bash
node smoke_test.js
```

You should see:
```text
--- Google Drive & Workspace MCP Smoke Test ---
āœ… Google Drive API connection successful!
Found 5 recent files.
   - Quarterly Plan (application/vnd.google-apps.document) [ID: ...]
```

Restart your `agy` session, and the Google Drive tools will be automatically available to the agent!

---

## šŸ”’ Security & Privacy

- No credentials, client secrets, or OAuth tokens are bundled with this repository.
- Tokens and OAuth credentials are saved locally in the user's `~/.gemini/` directory.
- All tokens are managed directly between the host machine and official Google APIs (`googleapis`).

## šŸ“„ License

MIT