gemini-agent-mcp
Health Warn
- License — License: GPL-3.0
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 7 GitHub stars
Code Fail
- fs.rmSync — Destructive file system operation in packages/client/scripts/build-binary.mjs
- os.homedir — User home directory access in packages/client/src/config.ts
- process.env — Environment variable access in packages/client/src/index.ts
- fs.rmSync — Destructive file system operation in packages/client/src/tools.ts
- os.homedir — User home directory access in packages/client/src/tools.ts
- process.env — Environment variable access in packages/client/src/tools.ts
Permissions Pass
- Permissions — No dangerous permissions requested
No AI report is available for this listing yet.
A remote MCP (Model Context Protocol) agent harness that lets Gemini Web or CLI clients inspect workspaces, read and edit files, track diffs, and execute shell commands on local machines behind NAT via a lightweight gateway and Go client binary.
A remote MCP (Model Context Protocol) agent harness that lets Gemini Web or CLI clients inspect workspaces, read and edit files, track diffs, and execute shell commands on local machines behind NAT via a lightweight gateway and Go client binary.
Architecture
Gemini Web / CLI
│ HTTPS (POST/GET /mcp/<deviceId>, Bearer or X-Gateway-Token)
▼
Gateway Server (Cloudflare Workers or self-hosted workerd)
├── RegistryHub (SQLite DO) ── device list, clientToken, PBKDF2 admin password
├── RelayHub[deviceId] (SQLite DO + WebSocket Hibernation)
│ ├── workspaces, diffs, command logs, pending approvals, device gatewayToken
│ └── /ws/ui (live WebSocket updates to the web console)
└── ASSETS (packages/web static bundle)
▲
│ Outbound WSS (/ws/client, X-Client-Token + X-Device-Id)
▼
Local Go Client (gemini-mcp)
└── ~/.gemini-mcp/config.json ── serverUrl, clientToken, deviceId, mcpUrl, gatewayToken
Each connected machine receives its own deviceId, an isolated /mcp/<deviceId> endpoint, and a server-issued gatewayToken. Rotating or setting a custom device password in the web console updates the connected client's local configuration file automatically.
Server deployment
Option A: Cloudflare Workers
One-click deploy
During deployment, Cloudflare prompts for the secrets defined in .dev.vars.example:
ADMIN_PASSWORD: initial administrator password for the web console (can be changed later inside the WebUI).CLIENT_TOKEN: pre-shared registration token used by local client binaries to connect via WebSocket.SESSION_SECRET: HMAC-SHA256 key used to sign WebUI session cookies.
Manual deploy via Wrangler
npm install
npm run build
npx wrangler secret put ADMIN_PASSWORD
npx wrangler secret put CLIENT_TOKEN
npx wrangler secret put SESSION_SECRET
npx wrangler deploy
The root wrangler.jsonc runs the @gemini-mcp/shared and @gemini-mcp/web builds automatically before packaging the Worker and static assets.
Option B: Self-hosted outside Cloudflare (VPS / Docker)
The server runs on any Linux/macOS host or container using the open-source workerd runtime via Wrangler with local SQLite persistence, without requiring a Cloudflare account.
Run directly on a VPS
npm install
npm run build -w @gemini-mcp/shared && npm run build -w @gemini-mcp/web
cp .dev.vars.example .dev.vars
# Edit .dev.vars with your ADMIN_PASSWORD, CLIENT_TOKEN, and SESSION_SECRET
npm run start:server
This listens on 0.0.0.0:8787 and stores SQLite Durable Object state under ./data.
Run with Docker
cp .dev.vars.example .dev.vars
# Edit .dev.vars with your secrets
docker build -t gemini-agent-mcp .
docker run -d \
--name gemini-agent-mcp \
--restart unless-stopped \
-p 8787:8787 \
-v "$(pwd)/data:/app/data" \
-v "$(pwd)/.dev.vars:/app/.dev.vars:ro" \
gemini-agent-mcp
Reverse proxy notes
Gemini Web requires HTTPS for remote MCP endpoints. Place Caddy, Nginx, or Traefik in front of port 8787 with WebSocket upgrade enabled and X-Forwarded-Proto / X-Forwarded-Host headers forwarded so the gateway assigns public https:// MCP URLs to connecting clients.
Example Caddyfile:
mcp.example.com {
reverse_proxy 127.0.0.1:8787
}
Client usage
Download prebuilt binaries
Prebuilt static binaries for windows/amd64, linux/amd64, linux/arm64, and linux/armhf are published on GitHub Releases.
Example on Linux (amd64):
curl -fsSL -o gemini-mcp https://github.com/XTxiaoting14332/gemini-agent-mcp/releases/latest/download/gemini-mcp-linux-amd64
chmod +x gemini-mcp
sudo mv gemini-mcp /usr/local/bin/gemini-mcp
First-run setup and configuration
Run the binary with flags once, or run gemini-mcp in an interactive terminal to follow the prompt:
gemini-mcp \
--url https://your-gateway.example.com \
--token <CLIENT_TOKEN> \
--name workstation
On connection, the server assigns deviceId, mcpUrl, and gatewayToken, writes them to ~/.gemini-mcp/config.json (mode 0600), and prints the assigned endpoint and password to stdout. Subsequent runs only require:
gemini-mcp
To use a custom config file path or update connection fields:
gemini-mcp --config /path/to/config.json
gemini-mcp init --url https://your-gateway.example.com --token <CLIENT_TOKEN> --name server-01
Gemini MCP configuration
Gemini Web (gemini.google.com)
In Gemini Web under custom MCP server connections (Connect to MCP server), the gateway exposes OAuth 2.1 discovery (/.well-known/oauth-protected-resource, /.well-known/oauth-authorization-server) and PKCE authorization (/oauth/authorize, /oauth/token):
- MCP Server URL:
https://your-gateway.example.com/mcp/<deviceId> - Expand Other settings (optional if using dynamic client registration, or fill directly from the WebUI Overview tab):
- Client ID (
OAuth Client ID):<deviceId> - Client Secret (
OAuth Client Secret):<DEVICE_GATEWAY_TOKEN>
- Client ID (
- Click Next and approve access on the gateway authorization page using your device password (
<DEVICE_GATEWAY_TOKEN>) or WebUI admin password.
Gemini CLI / Gateway clients
Clients that support custom HTTP headers can connect directly using static Bearer or gateway headers:
{
"mcpServers": {
"workstation": {
"httpUrl": "https://your-gateway.example.com/mcp/<deviceId>",
"headers": {
"Authorization": "Bearer <DEVICE_GATEWAY_TOKEN>",
"X-Gateway-Token": "<DEVICE_GATEWAY_TOKEN>"
}
}
}
}
Command policy and security
- Workspace sandboxing: file operations (
list_dir,find_files,read_file,write_file,edit_file,delete_file,grep_search,git_status,git_diff) andrun_commandworking directories are validated on the client against enabled workspace paths registered in the WebUI using symlink-aware realpath resolution. automode (default):run_commandrequiresrisk_level(safe,moderate, orhigh) andrisk_reason, combined with deterministic server-side pattern escalation in packages/shared/src/risk.ts (rm -rf,sudo, piped remote scripts,git push --force, etc.).safecommands execute immediately;moderateandhighcommands pause withAPPROVAL_REQUIREDand anapproval_id, requiring user confirmation in chat (允许/拒绝) or via the WebUI Commands tab.bypassmode: executes workspace commands directly without approval prompts while still recording stdout, stderr, exit codes, and duration.- Credential storage: the WebUI administrator password is stored as a salted PBKDF2-SHA256 hash inside
RegistryHubSQLite. Changing the password in WebUI Settings increments the password version and invalidates prior session cookies.
Repository layout
.github/workflows/ CI checks and multi-arch client release workflow
packages/
shared/ shared TypeScript protocol types, MCP tool schemas, risk classifier
worker/ gateway router, MCP Streamable HTTP handler, RelayHub & RegistryHub DOs
web/ React + Vite + Tailwind CSS v4 web console
client-go/ standalone Go client binary (cmd/gemini-mcp)
client/ Node.js/TypeScript reference client and esbuild single-file bundle
scripts/ end-to-end integration test against local wrangler dev
Dockerfile self-hosted container image using workerd + local SQLite persistence
wrangler.jsonc root Workers configuration for one-click, CLI, and self-hosted runs
Development
Requirements: Node.js 20+ (tested on Node 22) and Go 1.24+.
npm install
npm run build
npm run typecheck
Run the end-to-end integration test (starts local wrangler dev, connects both the Go binary and Node bundle clients simultaneously, and verifies auth, multi-device isolation, diffs, auto approval, and bypass execution):
npm test
Cross-compile all release binaries locally:
npm run build:binary-all
License
Source code is licensed under the GNU General Public License v3.0 (GPL-3.0); see LICENSE.
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found