fast-flow
# fast-flow-mcp
A lean, high-speed local **Model Context Protocol (MCP)** server and CLI for **Google Flow** (`flow.google.com`) over Chrome DevTools Protocol (CDP).
Designed to use your existing Google AI / Flow credits directly from Claude, Cursor, Codex, Antigravity, or the terminal — without slow character-by-character typing, arbitrary inter-job sleeps, or redundant re-uploads.
## Benchmarks (measured live)
| Operation | Time | Notes |
|---|---|---|
| Prompt input (515 chars) | **~7–10 ms** | CDP `Input.insertText` + `execCommand` (vs 10–15 s char-by-char) |
| Settings popover + `<mat-slider>` duration + credit quote | **~75–128 ms** | Direct DOM radio clicks + native range value setter |
| Full video submission (settings + cached Start/End frames + prompt) | **1.84 s** | Verified on 4 s `360p` video (4 credits) |
| 2 concurrent reference-guided images (end-to-end) | **34.7 s wall** | Both rendered in parallel, SHA-256 upload cache hit on scene 2 |
| `status --detailed` (cold start + credits balance) | **~515 ms** | Attaches over CDP to running Flow Chrome |
## Why it's fast
- **Instant prompt & rename entry**: Clears `.ProseMirror` via `execCommand` and injects the entire prompt via `page.keyboard.insertText()`.
- **In-page JS settings & slider control**: Clicks only unchecked `role="radio"` toggles and updates Angular Material `<mat-slider>` duration directly via `HTMLInputElement.prototype.value` setter + `input`/`change` events with state-driven `waitForFunction` checks (zero blind `500–2500 ms` sleeps).
- **Concurrent render pipeline (`FLOW_CONCURRENCY=3`, `FLOW_PAUSE_MS=0`)**: Serializes only brief UI interactions (`~1.5–2 s`) with an async mutex while up to 3 renders run simultaneously on Google's servers. New tiles are tagged in the DOM (`data-ffm-job`) for reliable concurrent attribution.
- **SHA-256 upload deduplication**: Caches local file hashes per Flow project (`~/.fast-flow-mcp/uploads-cache.json`) so identical start/end frames or references are uploaded once instead of every run.
- **CDP event-driven downloads**: Subscribes directly to `Browser.downloadWillBegin` and `Browser.downloadProgress` instead of polling download folders, releasing the UI lock as soon as Chrome starts streaming the file.
- **Hard credit cap (`max_credits`)**: Reads Flow's live credit quote before clicking **Start generation** and aborts without spending anything if the quote exceeds `max_credits`.
---
## Quick Start (1 command)
**Prerequisites:** Node.js 20+ and Google Chrome. (Optional: `ffmpeg` in PATH if you want to pass `.mp4` files as `first_frame`/`last_frame`.)
### Option 1: One-command setup via `npx`
```bash
npx -y github:maximhar/fast-flow-mcp setup
```
The interactive setup wizard will:
1. Check Node, Chrome, and optional `ffmpeg`.
2. Launch a dedicated Chrome profile (`~/.fast-flow-mcp/chrome-profile`, keeping your everyday browser untouched; automatically reuses `~/.flow-mcp/chrome-profile` if you already signed in there).
3. Wait automatically while you sign in to Google Flow, and create a starter Flow project if none is open.
4. Detect installed MCP clients (Claude Desktop, Cursor, Antigravity/Gemini) and offer to register `fast-flow` automatically, plus print the Claude Code one-liner.
### Option 2: Clone & install locally
```bash
git clone https://github.com/maximhar/fast-flow-mcp.git
cd fast-flow-mcp
npm install
npm run build
npm run setup
```
You can also run non-interactive diagnostics or auto-install into a specific client:
```bash
fast-flow-mcp setup --check
fast-flow-mcp setup --install claude-desktop # or: cursor | antigravity
```
---
## MCP Client Configuration
### Claude Code
```bash
claude mcp add fast-flow -- npx -y github:maximhar/fast-flow-mcp
```
Or with a local clone:
```bash
claude mcp add fast-flow -- node /absolute/path/to/fast-flow-mcp/dist/index.js
```
### Claude Desktop / Cursor / Antigravity / Gemini
Add to your MCP config JSON (`claude_desktop_config.json`, `~/.cursor/mcp.json`, or `~/.gemini/config/mcp_config.json`):
```json
{
"mcpServers": {
"fast-flow": {
"command": "npx",
"args": ["-y", "github:maximhar/fast-flow-mcp"]
}
}
}
```
For faster cold starts with a local clone, point directly to `node` + `dist/index.js`:
```json
{
"mcpServers": {
"fast-flow": {
"command": "node",
"args": ["/absolute/path/to/fast-flow-mcp/dist/index.js"]
}
}
}
```
---
## MCP Tools
| Tool | Description |
|---|---|
| `flow_status` | Check Chrome session, active project, composer settings, optional `credits_remaining`, and queue state. |
| `flow_generate` | Queue 1–100 image or video scenes. Supports `first_frame`, `last_frame`, `reference_images`, `chain_previous`, `reference_previous`, `model`, `resolution`, `duration`, `aspect_ratio`, `variants`, `download_quality`, `rename`, and `max_credits`. |
| `flow_wait` | Wait up to 40 s for queued/active jobs and return files + per-stage timings (`uiWaitMs`, `submitMs`, `renderMs`, `downloadMs`, `totalMs`). |
| `flow_cancel` | Cancel a queued job before submission. |
| `flow_retry` | Re-queue failed or cancelled jobs. |
| `flow_assets` | Fast-scan the active Flow project grid (`image` / `video` / `scene`). |
| `flow_download` | Download existing project assets by title prefix (0 credits, original or upscaled). |
| `flow_new_project` | Create and open a new Google Flow project. |
---
## CLI Usage
```bash
# Check status and credit balance
fast-flow-mcp status --detailed
# Generate 2 images concurrently (0 credits)
fast-flow-mcp generate Demo '[
{"type":"image","max_credits":0,"aspect_ratio":"16:9","prompt":"Misty alpine lake at sunrise"},
{"type":"image","max_credits":0,"aspect_ratio":"16:9","prompt":"Neon rain-soaked Tokyo alley at midnight"}
]'
# Generate a 720p video with start & end frames
fast-flow-mcp generate Demo '[
{
"type": "video",
"max_credits": 20,
"resolution": "720p",
"duration": 6,
"aspect_ratio": "16:9",
"first_frame": "/abs/path/start.png",
"last_frame": "/abs/path/end.png",
"prompt": "Slow cinematic camera push with drifting clouds"
}
]'
# List or re-download existing project media (0 credits)
fast-flow-mcp assets
fast-flow-mcp download Demo "Demo-scene-01"
```
---
## Configuration (Environment Variables)
| Variable | Default | Description |
|---|---|---|
| `FLOW_CONCURRENCY` | `3` | Maximum simultaneous renders in Flow (`1–6`). |
| `FLOW_PAUSE_MS` | `0` | Optional delay (ms) between consecutive submissions. |
| `FLOW_CDP_PORT` | `9333` | Chrome remote debugging port. |
| `FLOW_PROFILE_DIR` | `~/.fast-flow-mcp/chrome-profile` | Dedicated Chrome user-data directory (auto-reuses `~/.flow-mcp/chrome-profile` if present). |
| `FLOW_OUTPUT_DIR` | `~/fast-flow-out` | Root output directory for downloaded media (auto-reuses `~/flow-mcp-out` if present). |
| `FLOW_CHROME_PATH` | auto-detected | Explicit path to Chrome/Chromium executable. |
---
## Security & Privacy
- Runs 100% locally on your machine — no relay server, no external API keys, no telemetry.
- Never reads or types your Google credentials; you sign in manually once in the isolated Chrome profile.
- Drives Flow's real UI cleanly without bypassing reCAPTCHA or forging backend RPCs.
## License
[MIT](LICENSE)
TDQS
Scored across 8 tools
Each tool targets a distinct step in the generation workflow: status check, queueing, polling, cancel, retry, asset listing, download, and project creation. The only mild overlap is between flow_status (which reports queue state) and flow_wait (which polls job state), but the descriptions make the boundary reasonably clear.
All eight tools share a uniform snake_case 'flow_' prefix, which makes the family instantly recognizable. However, the suffix pattern mixes verbs (generate, wait, cancel, retry, download) with nouns/adjectives (status, assets, new_project), so it isn't a pure verb_noun convention.
Eight tools map cleanly onto the async job lifecycle plus project/asset management, with no redundant entries. Every tool earns its place and the count sits squarely in the well-scoped range.
The core lifecycle (create project, generate, wait, cancel, retry, list assets, download) is fully covered with no dead ends for the primary workflow. Minor gaps exist: there is no way to list/switch existing projects, no delete/cleanup operation, and no single-job status lookup outside the blocking flow_wait.