Skip to main content
Glama
README.md
# claude-gemini-mcp

Servidor MCP local para que **Claude Code sea el arquitecto** (piensa, decide, define criterios de aceptación y aprueba) y **Gemini sea el obrero** (implementa) mediante **Antigravity CLI (`agy`)** con tu licencia Google AI Pro. Objetivo: ahorrar cuota de Claude sin perder control de calidad.

```
Claude ──create_task(spec + ACs)──► servidor ──► worktree aislado (rama gemini/T-000N)
                                       │
                                       ├─ loop interno (sin Claude): agy -p → commit → checks (ACs command) → reintento
                                       │
Claude ◄──── reporte compacto (≤3.000 chars) ◄┘
Claude ──submit_review(approve | revise + feedback | reject)──► nueva ronda o cierre
Claude ──finish_task(merge | keep | discard)
```

## Por qué existe

Se investigaron proyectos open source (nov-2026). Ninguno cubría a la vez Claude-arquitecto + Gemini-obrero + loop con criterios de aceptación:

- [VKirill/antigravity-for-claude-code](https://github.com/VKirill/antigravity-for-claude-code): roles correctos, pero archivado (jun-2026) y dependiente de tmux.
- [shinpr/Galley](https://dev.to/shinpr/a-second-pair-of-eyes-for-claude-code-building-galley-a-local-runner-that-checks-the-work-before-9ie): loop con ACs con ID y veredictos, sin Gemini.

Este proyecto toma la división de roles del primero y el loop con ACs del segundo. Diseño completo: [docs/superpowers/specs/2026-11-30-claude-gemini-orchestra-design.md](docs/superpowers/specs/2026-11-30-claude-gemini-orchestra-design.md).

## Requisitos

- Windows 11 (también funciona en Linux/macOS), Python ≥ 3.11, git ≥ 2.30, Git Bash (para ACs con sintaxis bash).
- **Antigravity CLI (`agy`) instalado y con sesión iniciada** con tu cuenta AI Pro. Desde 2026-06-18 Gemini CLI dejó de servir cuentas personales/AI Pro; `agy` es el reemplazo oficial.

## Instalación

```powershell
.\scripts\install.ps1
```

Crea `.venv`, instala el paquete, copia la skill `gemini-architect` a `~/.claude/skills/` y una config de ejemplo a `~/.claude-gemini-mcp/config.toml`. Después registra el MCP (el script imprime la ruta exacta):

```powershell
claude mcp add gemini-worker -s user -- "C:\ruta\a\claude-gemini-mcp\.venv\Scripts\python.exe" -m claude_gemini_mcp
```

Reinicia Claude Code y pide, por ejemplo: *"delega a Gemini: añade paginación al endpoint /users con tests"*.

## Herramientas MCP

| Tool | Uso |
|---|---|
| `create_task` | Crea la tarea: spec, ACs (`command`/`review`), `seed_files` (tests protegidos), `copy_untracked`, `setup_command` |
| `run_task` / `wait_task` | Ejecuta el loop interno y espera (devuelve `running` si tarda más de `wait_seconds`) |
| `get_diff` / `get_log` | Detalle bajo demanda (diff por archivo, cola del log de Gemini) |
| `submit_review` | `approve` / `revise` (feedback por AC → nueva ronda) / `reject` |
| `finish_task` | `merge` (squash en tu rama base), `keep`, `discard` |
| `list_tasks` | Estado de las tareas |

## Configuración (`~/.claude-gemini-mcp/config.toml`)

Ver [config.example.toml](config.example.toml). Claves: `agy_path`, `agy_args` (placeholders `{prompt_file}`, `{model}`), `model`, `agy_timeout_s`, `ac_shell`, `bash_path`, `report_max_chars`, `prompt_template`. Variables de entorno: `CGM_DATA_DIR`, `CGM_CONFIG`.

El prompt completo para Gemini se escribe en `<worktree>/.cgm/prompt.md` y `agy` recibe una instrucción corta que apunta a ese archivo (evita el límite de longitud de línea de comandos de Windows). Plantilla editable: [src/claude_gemini_mcp/prompts/worker.md](src/claude_gemini_mcp/prompts/worker.md).

**Timeouts de Claude Code:** `run_task` espera hasta 540 s por defecto. Si tu Claude Code corta antes las llamadas MCP, baja `wait_seconds` o sube `MCP_TOOL_TIMEOUT`.

## Garantías

- Tu rama y tu árbol de trabajo no se tocan hasta `finish_task(merge)`, que exige árbol limpio y estar en la rama base.
- Solo los checks deterministas marcan ACs `command` como pass; solo Claude aprueba.
- Archivos protegidos (y `seed_files`) modificados por Gemini se revierten y se reportan.
- `copy_untracked` (p. ej. `.env`) y lo que cree `setup_command` nunca se commitean.
- Presupuestos: 3 iteraciones internas × 3 rondas por defecto.
- Varias sesiones de Claude Code pueden compartir el estado: cada tarea en curso registra el PID de su sesión, y las demás no la interrumpen ni la relanzan. Los IDs se reservan de forma atómica.
- En Windows, `agy` y los checks corren dentro de un Job Object: si el servidor muere (aunque sea forzado), sus procesos hijos mueren con él.

## Seguridad

`agy` ejecuta comandos en tu máquina con tus permisos. El worktree aísla el **código**, no el **sistema**. Usa el modo de permisos de `agy` más restrictivo que te funcione (p. ej. `--mode auto` con sandbox, vía `agy_args`). Las transcripciones quedan locales en `~/.claude-gemini-mcp/runs/`.

## Desarrollo

```powershell
.\.venv\Scripts\python -m pytest -q
```

Las pruebas usan un `agy` falso ([tests/fake_agy.py](tests/fake_agy.py)); no gastan cuota.

## Estado verificado

- Suite automatizada con `agy` simulado: verde (incluye una prueba sobre el transporte stdio real).
- Prueba real (2026-11-30, Windows 11, `agy` 1.5.20, cuenta AI Pro, flags por defecto): tarea *fizzbuzz* con un test de aceptación sembrado y un AC de revisión. Gemini implementó en 1 iteración (~110 s), AC-1 pasó, reporte de 460 caracteres, `approve` + `merge` produjo un único commit squash en `main` y limpió worktree y rama.
- Con `agy` 1.5.20 los argumentos por defecto (`-p "<instrucción>"`) bastan: en modo print `agy` edita archivos y ejecuta comandos sin pedir confirmación. Para más aislamiento puedes añadir `"--sandbox"` a `agy_args`.

TDQS

A3.5/5.0

Scored across 8 tools

Disambiguation4/5

Each tool maps to a distinct phase of the task lifecycle: create, run, wait, inspect diff, inspect log, review, finish, list. The only borderline pair is run_task and wait_task, but descriptions make the boundary clear (run_task starts the loop and waits up to wait_seconds; wait_task resumes waiting on an already-running task). get_diff vs get_log are also clearly separated by purpose (review changes vs diagnose errors).

Naming Consistency5/5

All eight tools follow a strict verb_noun snake_case pattern (create_task, run_task, wait_task, get_diff, get_log, submit_review, finish_task, list_tasks). Verbs are used consistently for their semantic class (create/run/wait/get/submit/finish/list), with no camelCase or stylistic mixing.

Tool Count5/5

Eight tools is well within the ideal 3-15 range and each tool covers a necessary lifecycle stage with no filler. The set is tightly scoped to orchestration of Gemini tasks in git worktrees, with no redundant or trivial entries.

Completeness4/5

The surface covers the full lifecycle: create, execute, wait, inspect (diff and log), review with approve/revise/reject, finalize with merge/keep/discard, and list. Minor gaps exist, such as no explicit way to cancel/abort a running task or fetch full task details beyond the compact list entry, but agents can work around these via finish_task discard and wait_task.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues