antigravity-gemini-mcp
by tamekuniz
README.md
# antigravity-gemini-mcp
[日本語版 README はこちら (Japanese Guide)](./README.ja.md)
> **Disclaimer:** Unofficial community tool. Not affiliated with, endorsed by, or sponsored by Google.
A zero-dependency local **Model Context Protocol (MCP)** server (Streamable HTTP + OAuth 2.1) that connects **Gemini (Web / Mobile / Antigravity.app built-in browser)** to your local workspace so you can offload **planning, code review, and test verification** to Gemini (separate quota) while keeping **implementation in Antigravity.app**.
---
## Workflow at a Glance
1. **Plan in Gemini** — Gemini reads your local repo (and even your current Antigravity conversation context via `read_antigravity_session`) and writes `.gemini-collab/PLAN.md`.
2. **Implement in Antigravity.app** — Antigravity implements directly from `PLAN.md` without burning tokens on broad exploration.
3. **Review & Test in Gemini** — Gemini inspects `git_diff`, runs `run_tests`, and writes `.gemini-collab/REVIEW.md`.
## Features
- **Zero npm dependencies, zero build step** (Node.js 20+ standard modules only; works on macOS / Linux / Windows)
- **Gemini Custom MCP ready**:
- Streamable HTTP (`/mcp`)
- OAuth 2.1 with PKCE (`S256`), Discovery (`/.well-known/oauth-protected-resource`, `/.well-known/oauth-authorization-server`), Dynamic Client Registration (`/oauth/register`)
- Preserves long OAuth `state` parameters (>2,000 chars)
- Also supports static Bearer token (`Authorization: Bearer <AUTH_SECRET>`)
- **10 safe planning, context & QA tools** (source code files are never edited by Gemini):
- Exploration & planning: `list_projects`, `list_files`, `read_file`, `search_code`, `write_plan_file` (`.md`/`.txt` only)
- Review & testing: `git_status`, `git_diff`, `run_tests`
- Antigravity context sharing: `list_antigravity_sessions`, `read_antigravity_session` (sanitized user/assistant turns only)
---
## Step-by-Step Setup
### Option 0 — Zero-Effort Setup (Let Antigravity Do Everything)
Paste this prompt into Antigravity (or your coding agent):
```text
Clone https://github.com/tamekuniz/antigravity-gemini-mcp into my projects folder, configure .env with ALLOWED_ROOTS set to my projects parent directory, install the skills (/gemini, /relay, gemini-collab) into ~/.agents/skills/, start the daemon (`npm run daemon:install` on macOS or `npm run tunnel`), and open https://gemini.google.com/customize/connectors in my regular browser while showing me the Public MCP URL and AUTH_SECRET to paste.
```
### Prerequisites
- **Node.js 20+**
- **cloudflared** (for HTTPS tunnel): `brew install cloudflared` on macOS (or install from Cloudflare)
### 1. Clone & Configure
```bash
git clone https://github.com/tamekuniz/antigravity-gemini-mcp.git
cd antigravity-gemini-mcp
cp .env.example .env
```
Edit `.env` and set `ALLOWED_ROOTS` to the parent directory of your projects (comma-separated).
### 2. Start the Server + HTTPS Tunnel
**Option A — Auto-start on login (macOS LaunchAgent, recommended):**
```bash
npm run daemon:install # starts background server + Cloudflare Quick Tunnel
npm run status # prints Public MCP URL and AUTH_SECRET
```
**Option B — Foreground run (macOS / Linux):**
```bash
npm run tunnel
```
**Option C — Server only (any OS, including Windows):**
```bash
npm start
# Then expose http://127.0.0.1:8787 over HTTPS with your preferred tunnel
```
Note the two values shown by `npm run status` (or startup logs):
- **Public MCP URL**: `https://<random-host>.trycloudflare.com/mcp`
- **AUTH_SECRET**: auto-generated and saved in `.state/auth_secret`
### 3. Register in Gemini (Important: Use a Regular Browser First!)
> **Important:** Do the **first-time registration** in a regular browser (Chrome / Safari / Edge) rather than Antigravity.app's built-in browser. Inside an embedded WebView, Google's account-linking iframe can fail with a `401` due to third-party cookie restrictions. Once registered in Chrome, it syncs automatically to your Google account and immediately works inside Antigravity.app's built-in browser!
1. Open **`https://gemini.google.com/customize/connectors`** in your regular browser.
- Make sure you are signed in with the **same Google account** you use in Antigravity.app's built-in browser.
2. Click **`+ Custom`** (Japanese UI: **`+ カスタム`**).
3. Enter your **Public MCP URL** (`https://.../mcp`).
- Leave **Client ID** and **Client Secret** **blank** (handled automatically via Dynamic Client Registration).
4. Click **Next** and accept Gemini's custom connector confirmation.
5. On the `antigravity-gemini-mcp` authorization page, paste your **`AUTH_SECRET`** and approve.
6. Confirm **`Antigravity Gemini Mcp`** appears under **Custom apps**.
### 4. Verify in Gemini (Built-in Browser or Web)
Reload Gemini (if already open in Antigravity.app's built-in browser), open a new chat, and run:
```text
@Antigravity Gemini Mcp list_projects
```
If Gemini lists your local project folders, you are connected!
### 5. Install Antigravity Skills (`/relay`, `/gemini`, `gemini-collab`)
```bash
mkdir -p ~/.agents/skills/gemini-collab ~/.agents/skills/relay ~/.agents/skills/gemini
cp skill/gemini-collab/SKILL.md ~/.agents/skills/gemini-collab/SKILL.md
cp skill/relay/SKILL.md ~/.agents/skills/relay/SKILL.md
cp skill/gemini/SKILL.md ~/.agents/skills/gemini/SKILL.md
```
Now in Antigravity.app chat you can use:
- `/gemini <task>` or `/relay <task>` — Full plan → implement → test relay
- Copy any error log / spec and run `/gemini` or `/relay` — Relays clipboard content to Gemini
- `/gemini review` or `/relay review` — Asks Gemini to inspect `git_diff` and run `run_tests`
- `/gemini apply` or `/relay apply` — Implements the latest `PLAN.md` / `REVIEW.md` in Antigravity.app
---
## Troubleshooting
- **Google shows `401` during account linking in Antigravity's built-in browser**:
Complete the initial connector registration in Chrome/Safari instead, then reload the built-in browser.
- **Registered in Chrome, but not visible in Antigravity's built-in browser**:
Verify both browsers are signed into the **exact same Google account** (bottom-left profile icon in Gemini).
- **Quick Tunnel URL changes after reboot**:
Run `npm run status` to check the new URL, or set up a free **Cloudflare Named Tunnel** and put `CLOUDFLARED_TUNNEL_TOKEN` + `PUBLIC_BASE_URL` in `.env` for a permanent URL.
## Security Notes
- **Directory Sandboxing**: All file and git operations resolve symlinks and reject any path outside `ALLOWED_ROOTS`.
- **Plan File Guard**: `write_plan_file` only allows `.md` and `.txt` files.
- **Command Execution (`run_tests`)**: Runs shell commands inside `ALLOWED_ROOTS`. Keep `AUTH_SECRET` private, avoid untrusted repositories (prompt injection risk), and optionally restrict commands with `ALLOWED_TEST_PREFIXES` in `.env`.
- **Antigravity Transcripts**: `read_antigravity_session` extracts only sanitized user/assistant messages (omitting raw tool outputs and thinking). Set `ALLOW_ANTIGRAVITY_SESSIONS=false` in `.env` to disable it.
- **Local Secrets**: `.env`, `.state/auth_secret`, and `.state/oauth_store.json` are gitignored. Never commit them.
## Self-Test
```bash
npm test
```
## License
MIT