Skip to content

About

Turn your Gemini Web subscription into a modern zero-API-cost local terminal CLI with Task mode, Thinking trajectory, invisible background browser & pluggable MCP Connectors.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | 简体中文

Gemini Web Bridge CLI

Latest Release MIT License Windows 10/11 | macOS Python 3.10+ OpenAI Local Adapter Not a Reverse Proxy

Turn your Gemini Web subscription (https://gemini.google.com/app) into a fast, modern, zero-API-cost local terminal CLI — complete with /goal autonomous loops, Task mode, Thinking trajectory viewer, One-Dark syntax-highlighted streaming, invisible background browser execution, local OpenAI Chat adapter, and pluggable MCP Connectors.


One-Click Deployment for New Users

Tip

One-Sentence AI Agent Deployment (Policy-Friendly) — Paste this into Claude Code, Codex, Cursor, or Antigravity to clone, install dependencies, create your Desktop shortcut, and verify pytest:

Clone the open-source repo https://github.com/Krittof/gemini-web-bridge-cli.git into a local folder of my choice, inspect the installer script (Install.ps1 on Windows, or install.sh on macOS) and requirements.txt first, then run .\Install.ps1 -CreateDesktopShortcut (Windows) or ./install.sh --create-desktop-shortcut (macOS) to set up the local venv and Desktop shortcut, and verify pytest passes. When done, just print the 3-step guide for what I should do after launching the Gemini-Web-CLI Desktop shortcut (do not launch a browser, sign into Google, or touch browser extensions — I will do that manually).

Or install directly in Terminal / PowerShell (no AI agent needed):

  • Windows (PowerShell):
git clone https://github.com/Krittof/gemini-web-bridge-cli.git; cd gemini-web-bridge-cli; powershell -NoProfile -ExecutionPolicy Bypass -File .\Install.ps1 -CreateDesktopShortcut
  • macOS (Terminal):
git clone https://github.com/Krittof/gemini-web-bridge-cli.git && cd gemini-web-bridge-cli && ./install.sh --create-desktop-shortcut

Then simply double-click Gemini-Web-CLI on your Desktop to launch.


One-Click Upgrade for Existing Users (Preserves Login & Config)

Note

One-Sentence AI Agent Upgrade (Windows & macOS) — Safely stops old processes, pulls latest main, syncs dependencies, and verifies pytest without touching profiles/, config.json, or secrets.json:

Upgrade my existing local gemini-web-bridge-cli folder to the latest version without touching profiles/, config.json, or secrets.json: on Windows run .\Update.ps1 (or .\scripts\Stop-All.ps1 then git pull --ff-only origin main and .\venv\Scripts\pip.exe install -r requirements.txt); on macOS run ./scripts/mac/update.sh (or ./scripts/mac/stop-all.sh then git pull --ff-only origin main and ./venv/bin/pip install -r requirements.txt). Then verify pytest passes and remind me to run /reload inside the CLI if extension files changed (do not open a browser or sign into Google).

Or upgrade directly in Terminal / PowerShell (inside the project folder):

  • Inside CLI (v1.3.0+): simply run /update (or /update --check to check first).
  • Windows (PowerShell):
# v1.3.0+: .\Update.ps1   |   v1.0-v1.2 one-liner:
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\Stop-All.ps1; git pull origin main; .\venv\Scripts\pip.exe install -r requirements.txt; .\venv\Scripts\pytest.exe -q
  • macOS (Terminal):
./scripts/mac/update.sh

Note: Starting in v1.3.0, CLI & /ui perform a lightweight, 24h-cached, read-only GitHub Releases check (disable anytime via "check_updates": false in config.json or GWB_NO_UPDATE_CHECK=1). When the browser extension needs a reload, simply run /reload inside the CLI (or click the reload button in /ui) — no need to open edge://extensions!


Originality & Clean-Room Copyright Statement

  • 100% Original Open-Source CLI: The standalone terminal interface (bridge/cli.py), local FastAPI bridge (bridge/server.py), SSE/Markdown engine (bridge/gemini_sse.py), Companion web panel (bridge/static/), and MV3 bridge scripts (bridge-ws.js, bridge-dom.js) are written from scratch using standard open-source libraries (FastAPI, uvicorn, httpx, rich, prompt_toolkit, Pygments).
  • Zero Proprietary Code or Binary Dependencies: Does not bundle, reverse-engineer, redistribute, or depend on any closed-source CLI binaries, icons, or proprietary SDKs.
  • Permissive MIT License: Free to use, fork, modify, and redistribute under the MIT License. (Note: "Gemini" and "Google" are trademarks of Google LLC; this is an independent community local bridge tool.)

Why This Exists (Core Advantages)

Advantage What You Get
Maximize Your Gemini Web Quota Use your existing Google AI Pro / Ultra web subscription (rolling window + weekly quota) directly in the terminal — zero per-token API billing. Official Usage limits auto-sync every 5 minutes and stay visible in your CLI bottom status bar.
Web-Exclusive Capabilities in a CLI Keep full access to features standard API keys often lack or charge extra for: Task autonomous mode, Thinking depth (Low / Medium / High), native Google Search with clickable Markdown citations (/web), native image input/output (@img: & auto-captured images), and Gemini Web MCP Connectors.
Modern Terminal UX Zero-flicker character-by-character streaming, One-Dark 24-bit syntax highlighting for code blocks, / interactive autocomplete menu, built-in ? quick-guide box, pinned bottom status bar (stays visible even while streaming), Ctrl+T multi-turn Thinking Trajectory viewer, F2 trace visibility toggle, and Ctrl+C real web Stop interruption.
100% Invisible Background Browser On Windows, the dedicated browser runs off-screen with WS_EX_TOOLWINDOW — hidden from both desktop and Taskbar while remaining 100% unthrottled. Show/hide anytime via /browser, and closing the CLI automatically shuts down all bridge and browser processes cleanly.
Zero Global Side Effects Everything lives inside this project directory (venv/, profiles/, secrets.json, logs/). Never touches your personal Chrome/Edge profile or global system configs.

Interface Showcase

1. Standalone TUI CLI (Main Interface)

Pixel emblem, live Task mode, collapsed rolling Thinking trace, One-Dark true-color code blocks, and a permanently pinned bottom status bar showing official web quota remaining, context meter, model, and mode:

Gemini Web Bridge CLI Main Interface

2. Multi-Turn Thinking Trajectory Viewer (Ctrl+T)

Zero-duplication VT100 Alternate Screen overlay — inspect every step of the current or any earlier turn (← / →) without cluttering or shifting your main chat scrollback:

Ctrl+T Thinking Trajectory Viewer

3. On-Demand Companion Mini-Window (/ui)

Opened only when you type /ui in the CLI — manage multiple Google accounts, switch models/thinking levels/Chat↔Task mode, monitor official usage & context guard, hot-switch MCP Connectors, and drag-and-drop images:

Companion Control Panel


Beginner Step-by-Step Guide

Prerequisites

  • Windows 10/11 (PowerShell 5.1+) or macOS (Apple Silicon / Intel, bash/zsh)
  • Python 3.10+ (tested on Python 3.12+)
  • Microsoft Edge (recommended) or Google Chrome

Step 1: Install (1 Command)

Windows (PowerShell):

git clone https://github.com/Krittof/gemini-web-bridge-cli.git gemini-web-bridge-cli
cd gemini-web-bridge-cli
powershell -NoProfile -ExecutionPolicy Bypass -File .\Install.ps1 -CreateDesktopShortcut

This creates a local venv, installs dependencies from requirements.txt, copies config.example.json → config.json, and places a launcher shortcut on your Desktop.

macOS (Terminal):

git clone https://github.com/Krittof/gemini-web-bridge-cli.git gemini-web-bridge-cli
cd gemini-web-bridge-cli
./install.sh --create-desktop-shortcut

This sets up venv/, clears Gatekeeper quarantine flags on the launchers, and optionally creates a Gemini-Web-CLI.command launcher on your Desktop. Launch via ./scripts/mac/launch-all.sh or double-click 启动-Gemini网页CLI.command in Finder (and 停止全部.command to stop all background processes).

Step 2: One-Time Login & Extension Setup

  1. Windows: Double-click 一键启动-Gemini网页CLI.cmd (or your Desktop shortcut Gemini-Web-CLI.lnk). macOS: Run ./scripts/mac/launch-all.sh or double-click 启动-Gemini网页CLI.command in Finder.
  2. Inside the CLI, type /browser and press Enter — the dedicated Edge/Chrome window appears on screen.
  3. Sign into your Google account at https://gemini.google.com/app.
  4. Open a new tab to edge://extensions (or chrome://extensions), turn on Developer Mode, click Load unpacked, and select the bundled extension folder inside this repository. (Already bundles both the Gemini Web bridge and Always Allow auto-confirmation into one extension — one-time only, persists permanently across restarts. Note: Chrome 137+ ignores --load-extension, so manual one-time loading in chrome://extensions is required when using Chrome.)
  5. Back in the CLI, type /browser again to hide the browser silently into the background.
    • macOS Permissions & Behavior: On macOS, /browser show/hide uses AppleScript (System Events) matched strictly by the isolated browser PID (note: hiding hides the window while the Dock icon remains visible per macOS behavior). If prompted, grant Accessibility and Automation (System Events) permissions to your terminal app (Terminal / iTerm2) or Python in System Settings → Privacy & Security.
    • macOS Terminal Hotkeys & Drag-and-Drop: Use Ctrl+O (or Fn+F2) to cycle trace visibility, Option+Enter / Esc+Enter / Ctrl+J for multi-line input, and drag files/images directly from Finder after @img: or @file: (escaped spaces like \ are parsed automatically).

Step 3: Start Using Immediately (Zero MCP Required)

  • Out of the box (without configuring any MCP tool), you can already chat in Task or Chat mode, switch models/thinking levels, run /web Google Search, attach @img: images, switch past chats via /history, roll over long sessions via /handoff, and view live official quota in the bottom bar.
  • Forget a command? Type ? (or /help) at the ❯ prompt anytime to pop up the built-in ? Quick Guide box, or type / to open the top-10 command autocomplete dropdown.
╭─ ? 使用指南 / Quick Guide ───────────────────────────────────────────────────╮
│ 新手 4 步速览 / Beginner Quick Start                                         │
│   1. 首次启动输入 /browser 唤出网页 → 登录 Google 并加载 extension/ → 隐藏   │
│   2. 无需配置 MCP 即可直接对话、Task 模式、/web 联网、@img: 传图、/history   │
│   3. (可选) 输入 /ui 绑定任意网页端 MCP(推荐单机 local-shell-mcp)          │
│   4. 快捷键:Ctrl+T 轨迹(←/→ 翻轮) · F2 隐藏 · Ctrl+C 打断 · Alt+Enter 换行│
╰──────────────────────────────────────────────────────────────────────────────╯

Step 4 (Optional Power-Up): Give Gemini Local File & Shell Access via MCP

Want Gemini Web to read/edit files and run commands on your PC like a full coding agent? Jump directly to Connecting MCP Tools (Recommended Default: Single-PC local-shell-mcp) below — local-shell-mcp (LSM) is our recommended out-of-the-box option, and you can also swap in any other Gemini Web MCP Connector at any time.


Core Commands & Hotkeys Cheatsheet

Command / Key Category Action
/goal <objective> Autonomy Run a multi-turn autonomous goal loop (--verify "<cmd>" evidence gate, --max N, auto /handoff, low-quota pause, STEERING.md steering, /goal resume)
/plan <task> Planning Read-only planning mode; review the numbered plan, then /plan run or /plan goal to execute
/review [focus] Review Send current uncommitted Git diff to Gemini for a structured code review
/checkpoint Safety Non-destructive Git snapshots (/checkpoint save [note], list, restore <id>); auto-created before /goal runs
/init / /memory Memory /init scaffolds GEMINI.md; first turn auto-loads GEMINI.md/AGENTS.md (/memory on|off)
/commands Custom Auto-loads custom slash commands from <cwd>/.gemini-bridge/commands/*.md with $ARGUMENTS expansion
/reload Updates Hot-reload the browser extension from disk (chrome.runtime.reload) without opening edge://extensions
/update Updates Check GitHub Releases (/update --check) or safely fast-forward upgrade (git pull --ff-only, auto-reloads extension when changed)
@file:<path> / @git Context Inject local source files or git status + diff directly into prompts — works without MCP
? / /help Help Open the built-in beginner Quick Guide box & full command table
/history (or /resume) Sessions List your 25 most recent Gemini Web chats; /history 2 or /resume <keyword> switches to & continues that chat
/new Sessions Start a fresh blank Gemini Web chat and reset context counters
/handoff Sessions Summarize a long chat → save brief to handoffs/ → open fresh chat & carry context forward
/browser Window Show or completely hide the background Edge/Chrome window (/browser show / /browser hide)
/ui (or /panel) Window Open the bilingual Companion control panel (http://127.0.0.1:18765) on demand
/mode task / /mode chat Model Switch between Gemini Web Task (autonomous multi-step) and Chat modes
/think Model View or switch Thinking depth (/think low, /think medium, /think high)
/model Model List available web models or fuzzy-switch (e.g., /model Everyday help, /model Code)
/usage Quota Sync & display official Gemini Web Usage limits (% + reset time) and local ledger
/web <query> Tools Bypass MCP connectors and run native Google Search with Markdown citations
/raw <prompt> Tools Skip MCP auto-prefix for this single turn
/mcp <prompt> Tools Force @Connector prefix for this single turn
@img:<path> Media Attach local PNG/JPG/WEBP/GIF image(s) (quote paths with spaces: @img:"C:\a b\1.png")
Ctrl+T Hotkey Open zero-duplication multi-turn Thinking Trajectory viewer (←/→ flip turns, Esc/Ctrl+T return)
F2 Hotkey Cycle Thinking trace display mode (Collapsed rolling → Hidden → Always expanded)
Ctrl+C Hotkey Immediately abort active generation (clicks Gemini Web's real Stop button & unlocks bridge)
Alt+Enter Hotkey Insert a newline inside a multi-line prompt
/exit / Window X Lifecycle Exit CLI and automatically shut down both the bridge daemon and dedicated browser

How It Works (Architecture)

flowchart LR
    CLI["Standalone TUI CLI\n(bridge/cli.py)\nRich + prompt_toolkit"]
    UI["Companion Panel (/ui)\nhttp://127.0.0.1:18765"]
    SRV["Local FastAPI Bridge\n(bridge/server.py)\n127.0.0.1:18765 + Bearer Token"]
    SW["MV3 Extension Worker\n(bridge-ws.js)\nWebSocket + Tab Control"]
    DOM["Content Script\n(bridge-dom.js + Always Allow)\ngemini.google.com/app"]
    MCP["Any Gemini Web MCP Connector\n(e.g., local-shell-mcp / GitHub / DB)"]

    CLI <-->|"Gemini v1beta SSE\n(streamGenerateContent)"| SRV
    UI <-->|"REST + /ws/companion"| SRV
    SRV <-->|"/ws/extension"| SW
    SW <-->|"chrome.tabs / runtime"| DOM
    DOM <-->|"Native @Chip + Auto-Approve"| MCP
Loading

Browser Compatibility

Browser Status Notes
Microsoft Edge Recommended (Default) Works smoothly with -Browser auto / -Browser edge; full Win32 WS_EX_TOOLWINDOW off-screen hiding (invisible on desktop & Taskbar, zero background throttling).
Google Chrome Supported Chrome 137+ ignores --load-extension. Launch with -Browser chrome, run /browser, open chrome://extensions → Developer Mode → Load unpacked → <repo>/extension once. Chrome persists it permanently inside profiles/<id>/.

Connecting MCP Tools (Pluggable — Not Locked to LSM)

This bridge is not locked to local-shell-mcp — it works with any MCP Connector registered in your Gemini Web account:

  • Run /ui → MCP Connector Auto-Prefix to change App Name / Chip Query live without restarting;
  • Or choose Manual (/mcp) mode and simply type @AnyConnectorName ... in any prompt to mix multiple MCP tools freely.

Personal, Single-Machine local-shell-mcp (LSM) Guide (No Mesh / No VPS)

If you want Gemini Web to read/edit files and run commands on your own PC only (without setting up a VPS or multi-node mesh):

Tip

Optional: One-Sentence AI Agent Setup for Single-Machine LSM (Standalone — Does Not Modify Core Bridge)

Set up a standalone personal local-shell-mcp installation in D:\LSM-Standalone (do not modify the gemini-web-bridge-cli repository):
1) Create an isolated Python virtualenv and install local-shell-mcp;
2) Generate a random 32-byte Bearer Token, restrict LOCAL_SHELL_MCP_WORKSPACE_ROOT strictly to a single dev folder I specify (never C:\ or my user home), and create start/stop scripts bound only to 127.0.0.1;
3) Check if cloudflared is installed (or show me the winget install command) and give me a single-port Cloudflare Tunnel start command;
4) Print the 3 values I need to paste once into Gemini Web's Connector settings (Connector Name, HTTPS Tunnel URL, Bearer Token) — do not launch a browser or sign into Google.

Manual steps overview:

  1. Install local-shell-mcp in a dedicated local Python virtualenv (pip install local-shell-mcp).
  2. Scope & lock it down locally: set LOCAL_SHELL_MCP_WORKSPACE_ROOT to a dedicated working folder (never C:\ or your entire user home) and enable bearer token authentication.
  3. Expose only that single local port over HTTPS using a personal tunnel such as Cloudflare Tunnel (cloudflared tunnel --url http://127.0.0.1:<port>) or Tailscale Funnel — zero VPS servers, zero WireGuard mesh, zero router port-forwarding.
  4. Register the Connector in Gemini Web: add the tunnel HTTPS URL + bearer token in Gemini Web's Connectors settings (e.g., named Local Shell Mcp).
  5. Enable hands-free execution: open /ui, set App Name to your Connector name, pick First Turn (declares @Connector once per conversation; Gemini remembers it automatically for follow-ups), and let the built-in Always Allow module auto-confirm tool cards.

Connecting Third-Party Clients & External Agents (Local Loopback Adapter)

Beyond the built-in TUI CLI, the bridge also exposes a local-only (127.0.0.1) OpenAI Chat Completions adapter (bridge/protocols/openai_chat.py) — still executing 100% through your own signed-in browser with zero cookie scraping, zero private RPC reverse-engineering, and no public exposure:

Setting Value
Base URL http://127.0.0.1:18765/v1
API Key bridge_token from your local secrets.json (accepts Authorization: Bearer and x-goog-api-key)
Model gemini-web (or aliases like gemini-2.5-pro)
Endpoints POST /v1/chat/completions (stream: true/false, SSE [DONE], reasoning_content, multi-turn messages, system, Base64 image_url) & GET /v1/models
  • Ready-to-use local clients:
    • Cline / Roo Code (VS Code extensions — XML text tool protocol works directly for reading/editing files), Aider (aider --openai-api-base http://127.0.0.1:18765/v1 --openai-api-key <token> --model openai/gemini-web), Cherry Studio, Open WebUI, Continue, T3 Code, and standard OpenAI SDKs.
    • Note: Cursor routes custom OpenAI Base URL requests through Cursor's cloud servers, so it cannot reach local 127.0.0.1 directly.
  • Subprocess / Pipe invocation from external harnesses (-p + --json):
    # Pipe logs or code snippets directly into CLI and parse structured JSON (answer + thoughts)
    Get-Content .\error.log | .\venv\Scripts\python.exe bridge\cli.py -p "Identify root cause and suggest a minimal fix" --json
  • Bonus workflow — Use as a Zero-API-Cost "Second Brain" inside Claude Code / Codex / Antigravity (Ready-to-Use Skill):
    • Keep this bridge running in the background and drop the bundled pure-Markdown Skill template examples/skill/gemini-web-assistant/SKILL.md into your host agent's skills/ directory (no plugin installation or code changes required).
    • Your main coding agent can then delegate Google Search (/web), second-opinion diff reviews, long-log diagnosis, or screenshot inspection (@img:) directly to your local Gemini Web subscription via bridge/cli.py -p ... --json.

Multi-Account Switching

Each Google account uses an isolated profile folder (profiles/<id>/) with independent cookies, MCP bindings, and usage ledgers:

  • GUI: Run /ui → click + Add (e.g. work) → select it → click Switch.
  • CLI (Windows): powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\Switch-Profile.ps1 -Profile work -Label "Work Account".
  • CLI (macOS): ./scripts/mac/switch-profile.sh --profile work --label "Work Account".

Usage Risk, Fair Use & Native Tool Call Notes

⚠️ Account & Automation Risk Notice (Please Read)

  • This bridge is not a reverse proxy, does not scrape cookies, and never routes traffic through third-party servers — it runs locally on 127.0.0.1 against your own signed-in browser session.
  • However, browser automation sits in a gray area under Google's Terms of Service. Unattended 24/7 high-frequency hammering via /goal can still trigger CAPTCHAs, temporary throttling, or account risk controls.
  • Built-in pacing guardrails are enabled by default in /goal: 3s inter-turn cooldown (--cooldown), 12-turn cap (--max), and auto-pause when official remaining quota ≤10% (--min-quota). Use responsibly and at your own discretion.
  • Native Tool Call Support:
    • Gemini Web side (Supported): Any MCP Connector registered in Gemini Web (e.g., local-shell-mcp, GitHub MCP) runs native tool-call cards with automatic approval via the bundled extension.
    • Bridge HTTP API side (Not yet supported): /v1beta/models/...:streamGenerateContent and /v1/chat/completions forward text, images, and thoughts only; they do not currently translate external JSON tools schemas into functionCall / tool_calls JSON round-trips (text/XML-based tools like Cline, Roo Code, and Aider work directly for file edits, while JSON-only tool clients are limited to chat).

Privacy & Security Checklist (Before Pushing Forks)

All private/runtime artifacts are blocked by .gitignore by default — verify with git status before pushing:

  • profiles/ (Google login cookies & browser data — NEVER commit)
  • secrets.json & extension/src/shared/bridge-bootstrap.js (local random bearer token)
  • config.json (your personal MCP names, custom prefixes, account labels — commit config.example.json only)
  • logs/, media/, handoffs/, goals/, venv/, *.lnk

License

Released under the MIT License.

About

Turn your Gemini Web subscription into a modern zero-API-cost local terminal CLI with Task mode, Thinking trajectory, invisible background browser & pluggable MCP Connectors.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages