Skip to main content
Glama
Gemini MCP Connector

Gemini MCP Connector

by RamX571
README.md
# Gemini MCP Connector

Universal **Streamable HTTP MCP** server template + **multi-agent plugin** (**Antigravity**, **Claude Code**, **OpenAI Codex**, and **OpenCode**) for **Gemini Connected Apps** (`gemini.google.com`) and **Gemini Enterprise**.

Give it **any app URL, OpenAPI spec, GitHub repo, or remote MCP URL** — it auto-discovers endpoints, scaffolds MCP tools, generates OAuth client IDs / Bearer tokens, and gives you the exact **MCP HTTP URL** and **Sign-In / OAuth URL**.

---

## 1-Command Install (Termux, Linux, macOS)

Run this single command anywhere (Termux on Android, Linux, or macOS) to install prerequisites (`node >= 22`, `git`, `curl`), clone the repo, install `gemini-mcp`, and register the plugin/skill + MCP server across **Antigravity, Claude Code, Codex, and OpenCode**:

```bash
curl -fsSL https://raw.githubusercontent.com/RamX571/gemini-mcp-connector/main/install.sh | bash
```

*(Already cloned locally? Run `bash install.sh` inside the repository folder.)*

---

## Connect Any App Link Automatically

Pass any app, API, OpenAPI spec, GitHub repo, or MCP endpoint URL:

```bash
gemini-mcp connect https://example.com/openapi.json
```

Or if the target requires OAuth sign-in, run with `--login` to open the Sign-In URL and complete authentication:

```bash
gemini-mcp connect https://your-oauth-mcp-server.com/mcp --login
```

What `gemini-mcp connect <url>` automatically handles:
1. **Remote MCP Server (`/mcp`)**: Probes `initialize` + `tools/list`, detects `401` + `/.well-known/oauth-protected-resource` + `/.well-known/oauth-authorization-server`, performs **Dynamic Client Registration (RFC 7591)** for `client_id`, and prints a clickable **PKCE OAuth Sign-In URL**.
2. **OpenAPI / Swagger API**: Parses `openapi.json` / `swagger.json`, auto-generates typed MCP tools in `src/tools/`, registers them in `src/tools/index.ts`, and detects OAuth / API key requirements.
3. **GitHub Repo / Web App URL**: Inspects the target and scaffolds a dedicated connector tool in `src/tools/` plus ready-to-paste client configs.

Or just tell **Antigravity**, **Claude Code**, **Codex**, or **OpenCode** in plain English:
> *"Use gemini-mcp-connector to connect `<app-url>` to Gemini"*  
(In Claude Code, you can also run `/connect-app <app-url>`.)

---

## Enable OAuth 2.1 or Bearer Auth on Your Connector

```bash
# Configure AUTH_MODE=oauth in .env with a strong signing secret
gemini-mcp auth --mode oauth

# Or register an OAuth client_id & get a Sign-In URL for your deployed Worker
gemini-mcp auth --mode oauth --url https://gemini-mcp-connector.<your-subdomain>.workers.dev
```

Supported `AUTH_MODE` values:
- `none` *(default)* — Open `/mcp` endpoint for quick testing.
- `bearer` — Constant-time `Authorization: Bearer <MCP_AUTH_TOKEN>` verification.
- `oauth` — Stateless HMAC-SHA256 **OAuth 2.1 + PKCE (`S256`) + Dynamic Client Registration (RFC 7591)** with `.well-known/oauth-protected-resource` and `.well-known/oauth-authorization-server` (supports long Gemini OAuth `state` parameters).

---

## Deploy for Gemini (Public HTTPS `/mcp` URL)

Gemini custom connectors require a **public HTTPS URL** ending in `/mcp`.

### Option 1: Cloudflare Workers (Free `*.workers.dev/mcp`)

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/RamX571/gemini-mcp-connector)

```bash
npx wrangler login
npx wrangler deploy
```

### Option 2: Google Cloud Run (`Dockerfile` — ideal for Chromium/FFmpeg/Remotion tools)

```bash
gcloud run deploy gemini-mcp-connector \
  --source . \
  --platform managed \
  --region us-central1 \
  --allow-unauthenticated
```

---

## Connect in Gemini

### Consumer Gemini App (`gemini.google.com`)
1. Open [gemini.google.com](https://gemini.google.com) → **Settings** → **Connected Apps**.
2. Choose **Add Custom App / MCP Connector**.
3. Paste `https://<your-deployed-host>/mcp`.
4. If OAuth is enabled, click the sign-in prompt to authorize.

### Gemini Enterprise (Google Cloud Console)
1. Open **Gemini Enterprise → Data stores → Create data store → Custom MCP Server**.
2. Set **MCP Server URL** to `https://<your-deployed-host>/mcp` (StreamableHTTP).
3. For OAuth mode, use `https://<your-deployed-host>/oauth/authorize` and `https://<your-deployed-host>/oauth/token` (or discovery via `/.well-known/oauth-authorization-server`).

---

## Included AI Agent Plugin & Skill Layout

| Agent / Tool | Integration Included |
|---|---|
| **Antigravity** | `.agents/skills/gemini-mcp-connector/SKILL.md` + stdio MCP builder |
| **Claude Code** | `.claude-plugin/plugin.json`, `.claude-plugin/marketplace.json`, `.mcp.json`, `commands/connect-app.md`, `skills/` |
| **OpenAI Codex** | `.codex-plugin/plugin.json`, `plugin.json`, `.agents/skills/gemini-mcp-connector/SKILL.md`, `~/.codex/config.toml` |
| **OpenCode** | `opencode.json`, `.opencode/skills/gemini-mcp-connector/SKILL.md` |

---

## Local Commands

```bash
pnpm start              # Run HTTP Streamable MCP server at http://localhost:8787/mcp
pnpm run stdio          # Run local stdio MCP builder server for AI coding agents
pnpm run connect <url>  # Probe any URL, generate tools, print MCP + OAuth Sign-In URL
pnpm run new-tool name  # Scaffold a new empty tool in src/tools/
pnpm test               # Run all automated protocol, OAuth, discovery, and HTTP tests
```