Skip to main content
Glama

🎨 Google Flow MCP Server & API Gateway | سرور MCP گوگل فلو

تولید تصویر و ویدیوی هوش مصنوعی (Veo / Imagen / Nano Banana) با Google Flow از طریق پروتکل MCP و REST API

An open-source Model Context Protocol (MCP) server & FastAPI REST/OpenAI-compatible gateway for automating Google Flow image generation, video creation, character consistency, narration, and video assembly.

TypeScript Node.js FastAPI MCP Chrome CDP License: MIT


📖 معرفی (Overview)

Google Flow MCP Server یک راهکار کامل برای اتصال Google Flow (flow.google.com) به ایجنت‌های هوش مصنوعی (Claude، Cursor، Antigravity، n8n و سرویس‌های بک‌اند) است. این پروژه شامل دو بخش مکمل است:

  1. هسته MCP Daemon (src/ — TypeScript/Node.js): کنترل مرورگر Chrome واقعی از طریق CDP، مدیریت صف کارها (Queue)، نگهداری پروفایل لاگین‌شده گوگل، تولید تصویر/ویدیو، حفظ ثبات شخصیت‌ها (Character Consistency)، ویرایش تصویر و ویدیو، و مونتاژ خروجی.

  2. درگاه FastAPI REST & OpenAI-Compatible (bridge/flow_api_bridge.py — Python): لایه امنیتی و API با پشتیبانی از X-API-Key، اندپوینت‌های استاندارد REST، سازگاری با فرمت OpenAI (/v1/images/generations و /v1/chat/completions) و پنل وضعیت ورود گوگل (noVNC).


Related MCP server: io.github.ethanhamilthon/yenflow

✨ ویژگی‌های کلیدی (Features)

  • 🖼️ تولید تصویر و ویدیو با مدل‌های گوگل: پشتیبانی از Imagen / Nano Banana / Veo در Google Flow با نسبت‌های تصویر مختلف (16:9, 9:16, 1:1, 4:5).

  • 🧬 حفظ ثبات شخصیت (Character Consistency): تعریف و فراخوانی شخصیت‌های ثابت در تمام صحنه‌ها (flow_character, flow_character_edit).

  • 🎬 تداوم و ویرایش ویدیو: ادامه دادن ویدیو از فریم آخر (flow_continue) و ویرایش بخش‌های تصویر/ویدیو (flow_edit).

  • 🎙️ نریشن، صداگذاری و زیرنویس: تولید صدا و زیرنویس و مونتاژ نهایی کلیپ‌ها (flow_narrate, flow_captions, flow_assemble).

  • 🔌 درگاه REST و سازگار با OpenAI API: امکان فراخوانی مستقیم از n8n، وردپرس، ربات تلگرام یا هر کلاینت سازگار با OpenAI.

  • 🔐 امنیت با X-API-Key: محافظت کامل از API و لینک‌های دانلود خروجی.

  • 🖥️ پشتیبانی از لاگین روی سرور بی‌مانیتور (noVNC): ورود امن به حساب گوگل از طریق مرورگر تحت وب بدون نیاز به ذخیره رمز عبور در کد.


🎯 کاربردها (Use Cases)

  • تولید خودکار ریلز، شورتس و ویدیوهای اینستاگرام/یوتیوب/آپارات: ساخت سناریو، تصویرسازی شخصیت‌محور، تبدیل به ویدیو و مونتاژ خودکار با ایجنت‌های هوش مصنوعی.

  • اتصال به n8n و ربات‌های تلگرام/وب: ارائه یک API اختصاصی روی سرور شخصی برای تولید تصویر و ویدیو بدون محدودیت کلاینت‌های محلی.

  • تولید محتوای انبوه برای فروشگاه‌ها و انتشارات: ساخت کاور، تیزر معرفی کتاب/محصول و بنرهای تبلیغاتی با برندینگ یکپارچه.


🏗️ معماری پروژه (Architecture)

MCP Client / n8n / AI Agent
        │  (HTTPS + X-API-Key)
        ▼
  Nginx Reverse Proxy  (/flow/ -> 127.0.0.1:8796)
        │
        ▼
  FastAPI Gateway (bridge/flow_api_bridge.py :8796)
        │  (HTTP / Internal Queue)
        ▼
  Flow MCP Daemon (src/daemon.ts :8795)
        │  (Chrome DevTools Protocol :9333)
        ▼
  Google Chrome (Signed-in Google Flow Session)

🛠️ ابزارهای MCP و اندپوینت‌ها

ابزارهای اصلی MCP

  • flow_status — بررسی وضعیت سرویس، صف و لاگین حساب گوگل

  • flow_generate — تولید تصویر یا ویدیو از پرامپت (با انتخاب مدل، نسبت تصویر و تصویر مرجع)

  • flow_wait / flow_cancel / flow_retry — مدیریت صف و انتظار تکمیل رندر

  • flow_assets / flow_download / flow_trash — مدیریت فایل‌ها و دانلود خروجی‌ها

  • flow_edit / flow_continue — ویرایش خروجی یا ادامه ویدیو

  • flow_character / flow_character_edit / flow_characters — مدیریت شخصیت‌های ثابت

  • flow_new_project / flow_techniques — مدیریت پروژه و تکنیک‌های پرامپت‌نویسی

  • flow_narrate / flow_voices / flow_assemble / flow_transcribe / flow_captions / flow_presenter — ابزارهای صداگذاری، زیرنویس و مونتاژ

اندپوینت‌های REST API Gateway (bridge/flow_api_bridge.py)

  • GET /health — بررسی سلامت سرویس

  • GET /status — وضعیت کامل دیمن و لاگین گوگل (نیازمند X-API-Key)

  • POST /generate | POST /generate/image | POST /generate/video — ثبت درخواست تولید

  • GET /jobs/{job_id} — پیگیری وضعیت کار

  • GET /outputs — لیست خروجی‌های تولیدشده

  • POST /v1/images/generations & POST /v1/chat/completions — اندپوینت‌های سازگار با OpenAI SDK


⚙️ آموزش نصب و راه‌اندازی کامل (Installation & Setup)

پیش‌نیازها

  • Ubuntu 22.04 / 24.04 (یا لینوکس با قابلیت اجرای Google Chrome)

  • Node.js 20+ و npm

  • Python 3.10+

  • Google Chrome نصب‌شده روی سرور (به‌همراه Xvfb و اختیاری x11vnc + noVNC برای لاگین اولیه)

۱. دریافت سورس و بیلد هسته TypeScript

git clone https://github.com/mromidkamangar-lab/google-flow-mcp-server.git
cd google-flow-mcp-server
npm install
npm run build

۲. راه‌اندازی درگاه FastAPI (Python Bridge)

python3 -m venv .venv
source .venv/bin/activate
pip install -r bridge/requirements.txt

۳. تنظیم متغیرهای محیطی (.env)

cp .env.example .env
chmod 600 .env

یک کلید تصادفی قوی بسازید:

openssl rand -hex 24

و مقدار FLOW_API_KEY، FLOW_PUBLIC_URL و FLOW_VNC_URL را داخل .env قرار دهید.

۴. اجرای سرویس‌ها

ترمینال ۱ — اجرای دیمن MCP (با DISPLAY=:99 روی Xvfb):

FLOW_MCP_PORT=8795 FLOW_MCP_CDP_PORT=9333 DISPLAY=:99 node dist/daemon.js

ترمینال ۲ — اجرای درگاه FastAPI:

cd bridge
FLOW_MCP_URL=http://127.0.0.1:8795 FLOW_API_KEY="YOUR_SECRET_KEY" \
  ../.venv/bin/uvicorn flow_api_bridge:app --host 127.0.0.1 --port 8796

۵. لاگین حساب گوگل (یک‌بار برای همیشه)

  1. اگر روی سرور بدون گرافیک هستید، سرویس Xvfb + x11vnc + noVNC را روی پورت 6080 اجرا کنید.

  2. از طریق آدرس https://your-domain.com/flow-login/vnc.html?autoconnect=true وارد محیط مرورگر شوید و در https://flow.google.com با حساب گوگل خود لاگین کنید.

  3. نشست در پروفایل کروم (~/.flow-mcp/chrome-profile) ذخیره می‌شود و از این به بعد تمام درخواست‌ها به‌صورت خودکار انجام خواهند شد.

۶. انتشار پشت Nginx + Cloudflare

نمونه تنظیمات در deploy/nginx.conf.example قرار دارد.


🔌 نمونه تست و فراخوانی API

curl -X POST "https://your-domain.com/flow/generate/image" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_SECRET_KEY" \
  -d '{
    "prompt": "Minimalist studio photography of an open language textbook on a warm wooden desk, soft morning sunlight",
    "aspect_ratio": "9:16"
  }'

🔒 نکات امنیتی (Security Best Practices)

  1. هرگز فایل .env، توکن‌ها و پوشه پروفایل کروم (.flow-mcp/chrome-profile/) را در گیت یا محیط عمومی آپلود نکنید.

  2. پس از اتمام لاگین گوگل، دسترسی مسیر /flow-login/ (noVNC) را در Nginx ببندید یا با Basic Auth / IP Whitelist محافظت کنید.

  3. همیشه برای FLOW_API_KEY از یک رشته تصادفی بلند استفاده کنید.


📄 مجوز (License)

این پروژه تحت مجوز MIT License منتشر شده است.


Google Flow MCP Server & API Gateway combines a TypeScript/Node.js Model Context Protocol (MCP) daemon automating Google Flow via Chrome DevTools Protocol (CDP) with a Python FastAPI REST & OpenAI-compatible gateway (X-API-Key protected). Supports Imagen/Veo generation, character consistency, video continuation, narration, captions, and FFmpeg assembly.

Keywords: google-flow-mcp, google-flow-api, veo-automation, imagen-mcp, model-context-protocol, mcp-server, fastapi-gateway, openai-compatible, cdp-automation, ai-video-pipeline.

Available Tools

22 tools
flow_agent_imagesFast image batch via Flow's agentA

Hand up to 50 image scenes to Flow's own Agent mode, which renders them all in parallel (minutes for a whole batch instead of one paced job per scene) and enriches each prompt itself. Images only, 0 credits. Pass references (characters, places, objects, each with a short name) to attach them once in the agent's composer, the way its + button does, and scene_references to say which scenes use which, so a whole story stays on-model. Scenes the agent drops are asked for again, then made one by one with their references. The finished images are moved into one Flow collection (-) and downloaded as ONE ZIP of originals, not one by one; if that download stops, the job fails without making anything again and flow_download with collection fetches them. Less exact than flow_generate: the agent picks the wording, no techniques, and each image is matched back to its scene by its stored prompt. Returns a job id; use flow_wait.

Inputs: scenes (required), project (required), references, aspect_ratio, +2 more.

flow_assembleAssemble clips into one videoA
Idempotent

Join a project's downloaded scene clips in order into one MP4 (local ffmpeg, no credits). Keeps each clip's own sound and can lay a music track and a voiceover on top.

Inputs: project (required), size, clips, music, +15 more.

flow_assetsList project mediaB
Read-only

List the images and videos in the open Flow project (title and kind). Titles can be used as 'asset:' in flow_generate or with flow_download.

Inputs: kind.

flow_cancelCancel a queued Flow jobA
Idempotent

Cancel a job that has not started yet. A running generation cannot be cancelled.

Inputs: job_id (required).

flow_captionsAdd captions to a videoA

Burn spoken-word captions into a video, in the style short-form apps use, for landscape or vertical footage (local and free: whisper.cpp hears the words on this computer, nothing is uploaded). Styles: bold (big capitals, the spoken word lights up), highlight, reveal, clean, boxed. Works in about 100 languages, including ones written without spaces (Japanese, Chinese, Thai) and right to left (Arabic, Hebrew); pass language (en, es, tr, ja...) whenever you know it. The first call downloads a speech model once: 148 MB for English, 574 MB for other languages. Saves -captions.mp4 plus an .srt. Before calling this, call flow_transcribe, show the user the words with any likely mishearings fixed, and get their OK: then pass the agreed words as text (matching words keep their timing), so the video is made once, right.

Inputs: video (required), lead, size, text, +8 more.

flow_characterCreate a reusable characterA

Create a reusable Flow character (person, mascot, product) so it looks the same in every scene. Free. Give describe and Flow draws the portrait first, or image to use a picture you already have; optionally a personality and a stock voice. Afterwards pass 'asset:' in a scene's reference_images.

Inputs: name (required), look, image, voice, +3 more.

flow_character_editRestyle an existing characterA

Change how an existing character looks without creating a new one (Flow redraws the portrait in place, free), and save the new portrait to /_cast. The character keeps its name, personality and voice, so every scene that references it picks up the new look. Pass look with the full updated description so scene prompts stop quoting the old one. With no change it only saves the current portrait.

Inputs: name (required), look, change.

flow_charactersList charactersA
Read-only

List the reusable characters in the open Flow project. Each can be used in a scene as 'asset:'.

Inputs: no named parameters.

flow_continueContinue a clip, keeping a character attachedA

Start a new clip from the last frame of one already in the project, for a continuous take across a cut. It saves the source clip's real final frame, animates it through Flow's agent mode, and downloads the result. mode 'exact' (default) gives an invisible join - the clip opens on the actual last frame - but attached characters are ignored, so the likeness must come from that frame; mode 'likeness' keeps a character or your avatar locked at the cost of an only-approximate opening frame. Flow cannot do both at once. Agent mode shows no credit quote beforehand, so ask the user before calling. Queued like a generation; use flow_wait for the file.

Inputs: prompt (required), project (required), from_asset (required), acknowledge_cost (required), +5 more.

flow_downloadDownload existing project mediaA
Idempotent

Download media that already exists in the Flow project, without regenerating it (no credits, including 1080p/2K upscales). Matches by the start of the title. collection fetches a whole Flow collection as ONE ZIP (originals, each under its own title): agent image batches put their images in a collection named - and download it that way.

Inputs: project (required), assets, quality, collection.

flow_editEdit an existing videoA

Video-to-video edit of a clip already in the Flow project (relight, change weather/background, remove or restyle objects) using Flow's edit view. Queued like a generation; use flow_wait for the file. Spends credits without a prior quote (about 20 for a 4 s clip), so ask the user before calling.

Inputs: asset (required), prompt (required), project (required), acknowledge_cost (required), +1 more.

flow_generateQueue Flow generationsA

Queue one clip or image per scene in the open Flow project. Runs one at a time with human-like pauses and spends the user's Google AI credits (per video, at 720p: Omni 1.2 Flash 3 a second up to 10 s and 6 a second after, so 30 for 10 s and 60 for 15 s; at 360p a third of that; Veo 3.1 Lite 10; images 0). Each scene is checked against max_credits using Flow's own quote before anything is spent. Returns job ids immediately; use flow_wait for results.

Inputs: scenes (required), project (required).

flow_narrateRecord narrationA

Record narration as an .m4a, free. The default engine: "kokoro" is Kokoro, a voice that runs on this computer: no key, no daily limit, any length, 28 English voices (flow_voices lists them; default am_michael) and a speed. The first Kokoro take downloads its model once (326 MB, about a minute). engine: "gemini" uses Google AI Studio's text-to-speech (the same voices Flow has, a free key in ~/.flow-mcp/gemini-key, a daily limit, takes a short style note); if that limit is used up the line is recorded with Kokoro and the result says so. Neither costs credits. Record a whole narration in one take; flow_assemble can lay it over a film.

Inputs: text (required), project (required), speed, style, +2 more.

flow_new_projectStart a new Flow projectA

Create a new, empty Google Flow project and open it in the Flow window, optionally with a name - for starting a film or ad from scratch. Free. Characters belong to a project, so make them again in the new one.

Inputs: title.

flow_presenterTalking presenter over footageA

Build an explainer from one recording of a talking presenter (an avatar video, say): each stretch shows them full frame, with an optional slow zoom, or in a circle in a corner over another clip. Their sound plays throughout. Local and free. Add music, loudness and watermark removal afterwards with flow_assemble.

Inputs: project (required), segments (required), presenter (required), size, +2 more.

flow_retryRetry failed Flow jobsA

Put failed jobs back in the queue with the same settings and file names (default: all failed jobs). Scenes already retry once on their own when Flow reports a failure. An image batch that finished with some images still failed (its job lists failed_scenes) is not run again whole: only those images are made again, saved under their own scene numbers.

Inputs: job_ids.

flow_statusFlow statusA
Read-only

Check the Flow Chrome session (signed in, project open, plan, credits left) and the generation queue. Call this first; it says what the user must fix before generating, and returns the prompt playbook.

Inputs: detailed.

flow_techniquesFilm technique presetsA
Read-onlyIdempotent

List ready-made prompt phrases for camera moves, product shots, first→last-frame transitions and image commands. Pass an id as a scene's technique in flow_generate.

Inputs: category.

flow_transcribeHear the words in a video or audio fileA
Read-only

Transcribe a video or audio file on this computer with every word's start and end time (whisper.cpp, local and free, about 100 languages; pass language when you know it. The first call in English downloads a 148 MB speech model once, in any other language a 574 MB one). Use the times to check a take said the right words and to cut lines out of it for flow_assemble's voice_lines.

Inputs: video (required), words, language.

flow_trashMove an item to Flow's TrashA
Destructive

Move one image, video or scene in the open Flow project to Flow's Trash, by its exact title from flow_assets. Recoverable: Flow keeps it in Trash with a Restore button. Never deletes permanently. Flow asks no confirmation of its own, so confirm with the user before calling. Refuses if two items share the title.

Inputs: name (required).

flow_voicesList Flow voicesA
Read-onlyIdempotent

Narrator voices available for flow_narrate: Kokoro's (free, on this computer, with whether its model is downloaded yet) and Google AI Studio's (with whether a key is set up).

Inputs: no named parameters.

flow_waitWait for Flow jobsA
Read-only

Wait for queued jobs (default: all), or for the task_id of a call that answered still_working, then return their status, results and file paths. Comes back within about 40 s even when they are still running: call again until finished is true.

Inputs: job_ids, timeout_seconds.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 22 tools

    Disambiguation4/5

    Most tools target clearly different stages of the video workflow: generation, waiting, downloading, assembly, narration, transcription, captions, and character management. A few close pairs could still be confused at a glance, especially flow_characters vs flow_character vs flow_character_edit and flow_generate vs flow_agent_images, though their descriptions clarify the boundaries.

    Naming Consistency4/5

    All tools use a consistent flow_ prefix and snake_case, making the namespace predictable. The pattern is mostly verb-based, but several list-style tools use plural nouns (flow_assets, flow_characters, flow_voices, flow_techniques) and flow_character is a create action, which are minor deviations.

    Tool Count3/5

    At 22 tools, the surface is heavy for a single MCP server, though the breadth of the video-production domain justifies many of them. Each tool maps to a distinct capability, but the set is large enough that discoverability and selection burden are real concerns.

    Completeness4/5

    The server covers a strong end-to-end pipeline: project creation, generation, job control, asset listing/download/trash, characters, narration, transcription, captions, assembly, and presenter videos. Minor gaps remain around managing or opening existing projects, editing scene prompts/settings, and importing arbitrary local media outside the character/presenter flows.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers