gemini-mcp
MCP gateway for massive-payload Gemini analysis on the AI Studio free tier. Runs on a small VPS; a local Freebuff Desktop agent sends huge bodies to it and gets back a compact consolidated result — the agent's own context stays clean.
- Cascading Flash chain
3.8 → 3.7 → 3.6 → 3.5 → 3via gemini-router (per key×model RPD/RPM/TPM ledger shared withtldr-digest). - Over-limit bodies: split into overlapping chunks, each marked
[CHUNK N/M], analyzed separately, then consolidated (recursively if needed). thinking_leveldefault high, per-request override; opt-in overflow (flash-lite → gemma) when the daily quota is gone; hard stop otherwise; per-request wait policy for minute-limit resets (default: wait, countdown reported in progress).- Deep progress to the caller (MCP progress + logging notifications + embedded trace),
rotating disk logs,
gemini-mcp quota|logs|calls|doctorin the terminal. - Transports: SSH-stdio (primary) and streamable HTTP daemon (
127.0.0.1, bearer). - Dual backend (0.8.0):
router(fleet: shared SQLite ledger on the VPS) ordirect(plain Google AI Studio: same engine, in-memory counters, no server at all).backend: autopicks router only when persistent state exists; envGEMINI_MCP_BACKENDoverrides. Seedocs/08-dual-mode.md.
Quickstart — no server (direct mode)
uvx --from gemini-mcp-gateway gemini-mcp setup
# wizard: fleet-vs-simple question → masked key paste (aistudio.google.com/app/apikey)
# → ~/.config/gemini-mcp/{config.yaml,.env 0600} → live listModels probe → client snippet
Paste the printed snippet into your MCP client — for Freebuff/Claude Desktop/Cursor
(~/.agents/mcp.json, claude_desktop_config.json, ~/.cursor/mcp.json) it is:
{ "mcpServers": { "gemini": {
"command": "npx", "args": ["-y", "@vernikr/gemini-mcp", "stdio"] } } }
— then ask the agent to call quota_status. No env vars needed: the gateway
auto-discovers ~/.config/gemini-mcp/. Full client matrix + fleet JSON forms:
docs/06-consumer.md. Manual alternative:
export GEMINI_API_KEYS="AIza…,AIza…" + uvx --from gemini-mcp-gateway gemini-mcp stdio. gemini-mcp doctor re-checks keys/chain/limits; gemini-mcp uninstall --yes
removes everything the wizard wrote.
Direct mode needs nothing but API keys. Usage is tracked in a LOCAL persistent ledger
(~/.config/gemini-mcp/state.db): quota counters survive restarts and are shared by all
gateway processes on the machine — but not across machines (that's fleet mode: VPS
daemon + backend: router). Every response says backend=direct in its report line;
gemini-mcp uninstall --yes removes keys, config and ledger together. The npm shim
@vernikr/gemini-mcp (pnpm-first install) ships the same core at the same version.
Status
v0.8.0 — published consumer package. Fleet side (VPS daemon 0.6.x, SSH-stdio +
HTTP tunnel) runs in production; consumer side ships as PyPI gemini-mcp-gateway
(+ npm shim @vernikr/gemini-mcp) with the dual-mode backend (router/direct,
docs/08) and the setup wizard (M7.2). Router core: gemini-router 0.1.1 on PyPI.
80 tests green, no network needed (respx/fakes only).
Next: M7.3 dual-publish CI, M7.4 clean-machine beta.
Development
uv sync --extra dev # dev pin: gemini-router from git tag (tool.uv.sources);
# published metadata uses the PyPI version range — no auth needed
uv run pytest -q # 80 tests: chunker, pipeline, tools/server, logging, direct
# backend (respx), setup wizard — all faked, no network
uv run ruff check src tests
GEMINI_API_KEYS=... uv run gemini-mcp setup|quota|calls|logs|prune|doctor
| Stage | Artifact |
|---|---|
| 1 · Unpacking/reframing + Q&A | docs/01-unpacking-reframing.md |
| 2 · Functional/business requirements | docs/02-requirements.md |
| 3 · Architecture & stack | docs/03-architecture.md |
| 4 · Plan (M0–M6) | docs/04-plan.md |
| Consumer guide (client JSON, direct mode) | docs/06-consumer.md |
| Dual-mode backend design | docs/08-dual-mode.md |
| Risks | docs/blockers/ |
Planned usage (Freebuff, ~/.agents/mcp.json)
{ "mcpServers": {
"gemini": { // A) SSH-stdio — primary, encrypted, no open ports
"command": "ssh",
"args": ["root@38.244.152.2", "/opt/apps/gemini-mcp/.venv/bin/gemini-mcp", "stdio"] },
"gemini-http": { // B) HTTP via `ssh -L 8790:127.0.0.1:8790 root@38.244.152.2`
"type": "http", "url": "http://127.0.0.1:8790/mcp",
"headers": { "Authorization": "Bearer $GEMINI_MCP_TOKEN" } } } }
Tools: analyze_large (chunking pipeline), gemini_generate (single shot),
quota_status, router_logs.
Deployment (M4)
From the workstation (sibling checkout of gemini-router required next to this repo):
bash scripts/run_remote.sh setup # rsync both repos → venv, .env, systemd unit, doctor
bash scripts/run_remote.sh smoke # first real-key run on the VPS (spends ≤1 RPD)
bash scripts/run_remote.sh status|logs
Freebuff Desktop wiring (SSH-stdio and HTTP-via-tunnel snippets, verification steps):
docs/freebuff-wiring.md. The daemon never leaves
127.0.0.1:8790; no firewall changes are made (server-spec compliant).
Ops (after M4)
ssh root@38.244.152.2
sudo systemctl status gemini-mcp # daemon (HTTP)
/opt/apps/gemini-mcp/.venv/bin/gemini-mcp quota # what's left, per key×model
/opt/apps/gemini-mcp/.venv/bin/gemini-mcp logs -f # live app log
Conventions: English in files, Conventional Commits, SemVer, docs updated with every
functional change (see AGENTS.md).
Metadata
Release files for gemini-mcp-gateway 0.9.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gemini_mcp_gateway-0.9.1.tar.gz | 156.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gemini_mcp_gateway-0.9.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 203.6 kB
Release files / gemini_mcp_gateway-0.9.1.tar.gz
| Download URL | gemini_mcp_gateway-0.9.1.tar.gz |
|---|---|
| Size | 156.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8fe32f01c8af0ede1b35367008fab1cca957269c94f792b983dc419a23fdebf
|
|
BLAKE2b-256 checksum How to use checksums |
f6c7c9fa3d4c89a8b4252d40113bec3c035e9b9f1cc878e6e84c3242ea3715e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.
Transparency logRelease files / gemini_mcp_gateway-0.9.1-py3-none-any.whl
| Download URL | gemini_mcp_gateway-0.9.1-py3-none-any.whl |
|---|---|
| Size | 47.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d8fbe7a4b1b9682a048c02d557fd0a71890be80ff240c9344e0f0aae5d63e47
|
|
BLAKE2b-256 checksum How to use checksums |
4bb9afdee42b0b26fc1a57080c4d56a76609378a1dca55018368452b0e2f9651
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.
Transparency log