Skip to main content
Glama

flowmusic-cli

CI

Lightweight Python CLI and MCP server for Google Flow Music (https://www.flowmusic.app), modeled after gflow-cli's engineering discipline (real-Chrome OAuth bootstrap, ProfileLease locking, billing-safe SubmitAttempt, --json envelopes, and --no-spend MCP policy) while taking advantage of Flow Music's pure-HTTP Supabase + REST/SSE stack (no resident browser or reCAPTCHA minting required for daily commands).

Installation

git clone https://github.com/Eleven1111/flowmusic-cli.git
cd flowmusic-cli
uv sync --extra dev

# Install global `flowmusic` and `flowmusic-mcp` executables:
uv tool install -e .
flowmusic --version

Related MCP server: fmusic

Quick Start

# 1. One-time sign-in via your currently active Google Chrome (PKCE OAuth)
flowmusic auth login

# Or non-interactive two-step PKCE / isolated Playwright profile / refresh_token import:
flowmusic auth login --start
flowmusic auth login --code <CODE>
flowmusic auth login --method isolated-chrome
flowmusic auth import-token

# 2. Verify live session & inspect account/models/library (pure HTTP, no browser)
flowmusic auth status
flowmusic me
flowmusic credits
flowmusic models
flowmusic list --limit 10

# 3. Generate a song (`Lyria 3.5` / `Lyria 3 Pro` / `Lyria 4`) and auto-download MP3
flowmusic generate "warm lo-fi beats for midnight coding" --instrumental --bpm 85 --out-dir ./out

# 4. Conversational Producer mode
flowmusic chat "Make an acoustic indie folk song about autumn rain in Tokyo" --download --out-dir ./out

# 5. Stems separation, remixing (`cover` / `extend` / `replace`), upload & download
flowmusic stems <clip-id> --out-dir ./stems
flowmusic cover <clip-id> --strength 0.5 -i "acoustic jazz piano trio" --out-dir ./out
flowmusic extend <clip-id> --seconds 30 --out-dir ./out
flowmusic replace <clip-id> --region 12:24 -i "bright brass solo" --out-dir ./out
flowmusic upload-audio ./track.mp3 --json
flowmusic download <clip-id> --format wav --out-dir ./out

# 6. Search, favorites, clip metadata, conversations & playlists (0 credits)
flowmusic search "lofi piano" --limit 10
flowmusic search "jazz" --type playlists --limit 10
flowmusic favorites --limit 10
flowmusic clip update <clip-id> --title "Midnight Sketch" --privacy unlisted
flowmusic clip favorite <clip-id>
flowmusic clip preference <clip-id> liked
flowmusic conversations list --limit 10
flowmusic conversations show <conversation-id>
flowmusic conversations rename <conversation-id> "Tokyo Rain Drafts"
flowmusic playlists list --kind mine
flowmusic playlists list --kind featured
flowmusic playlists create "Late Night Focus" --privacy private
flowmusic playlists update <playlist-id> --name "Focus v2" --privacy unlisted
flowmusic playlists add <playlist-id> <clip-id>
flowmusic playlists remove <playlist-id> <clip-id>
flowmusic playlists favorite <playlist-id>
flowmusic playlists show <playlist-id>
flowmusic playlists delete <playlist-id> --yes

# 7. Clip video render, music-video library, social video & audio trim (v0.4)
flowmusic video clip <clip-id> --preset modern --out ./clip.mp4
flowmusic video quota
flowmusic video list --limit 20
flowmusic video show <video-id>
flowmusic video social <clip-id> --length 15
flowmusic trim <clip-id> --start 0 --end 10 --title "Intro Hook" --out-dir ./out

MCP Server (mcp>=2.0.0)

# Start stdio MCP server for Claude Desktop / Cursor / Antigravity:
flowmusic mcp run
flowmusic-mcp

# Hide credit-spending tools (`generate`, `chat`, `stems`, `edit`, `create_social_video`, `trim_clip`):
flowmusic mcp run --no-spend

Exposed MCP tools (26 total):

  • Read / search / library / media utilities (20, always available): flowmusic_auth_status, flowmusic_credits, flowmusic_models, flowmusic_list_clips, flowmusic_get_clips, flowmusic_download_audio, flowmusic_upload_audio, flowmusic_search, flowmusic_favorites, flowmusic_update_clip, flowmusic_list_conversations, flowmusic_get_conversation, flowmusic_rename_conversation, flowmusic_list_playlists, flowmusic_get_playlist, flowmusic_manage_playlist, flowmusic_render_clip_video, flowmusic_social_video_quota, flowmusic_list_music_videos, flowmusic_get_music_video

  • Credit/quota-spending tools (6, removed under --no-spend): flowmusic_generate_song, flowmusic_chat_generate, flowmusic_split_stems, flowmusic_edit_song, flowmusic_create_social_video, flowmusic_trim_clip

Multi-Profile & Agent Usage

  • Every command supports --profile <name> (isolated sessions under ~/Library/Application Support/flowmusic-cli/profiles/<name>/session.json with 0600 permissions, overridable via FLOWMUSIC_CLI_HOME).

  • Every CLI command supports --json for stable machine-readable output ({"ok": true, ...} or {"ok": false, "error": {"type", "detail", "charged", "retryable", "next_action"}}), and MCP failures set isError: true.

Architecture

  • src/flowmusic_cli/session.py — Dynamic Supabase config discovery from www.flowmusic.app, chunked/base64- @supabase/ssr cookie decoding, 0600 atomic persistence, and GoTrue refresh_token rotation.

  • src/flowmusic_cli/auth_chrome.py — One-time real Chrome OAuth login (channel="chrome" with anti-webdriver flags) + import-token fallback.

  • src/flowmusic_cli/profile_lease.py — Cross-process OS file locking (fcntl.flock / msvcrt.locking) preventing concurrent refresh-token rotation collisions.

  • src/flowmusic_cli/submit_policy.py — Phase-tracked SubmitAttempt: never resends a generation POST once bytes leave the client.

  • src/flowmusic_cli/payloads.py — Pure recipe/payload builders (CoverSong, ExtendSection, ReplaceSection, Lyria 4 edit plans), stem base64 validation, and MIME inference.

  • src/flowmusic_cli/operations.py, library_ops.py, video_ops.py & client.py — Pure-HTTP async httpx client (/__api/ REST, multipart audio upload, SSE streaming, library search/favorites/conversations/playlists, clip video render, music-video library, social video, trim, atomic downloads).

  • src/flowmusic_cli/cli_helpers.py, cli_auth.py, cli_library.py, cli_video.py, cli.py — Click CLI surface.

  • src/flowmusic_cli/mcp_server.py, mcp_library.py & mcp_video.py — MCPServer stdio server (26 tools) with stdout isolation, --no-spend policy, and isError failure flagging.

Design Philosophy

  • Pure HTTP for daily calls, Chrome only once: Flow Music runs on Supabase Auth + /__api/ REST/SSE with no resident browser needed after the initial PKCE OAuth handshake.

  • Billing-safe by construction: Mutating/generation POSTs are guarded by phase-tracked SubmitAttempt (never auto-retried once bytes leave the client), and --no-spend hides all credit/quota-spending MCP tools.

  • Agent-friendly contracts: Every CLI command emits stable --json envelopes (ok, error.type, charged, retryable, next_action), every MCP failure flags isError=True, and session files enforce 0600 permissions under cross-process ProfileLease locks.

Directory Tree

flowmusic-cli/
├── LICENSE
├── README.md
├── pyproject.toml
├── src/flowmusic_cli/
│   ├── auth_chrome.py      # One-time active/isolated Chrome PKCE OAuth
│   ├── cli.py              # Root Click CLI entry point
│   ├── cli_auth.py         # `auth` subcommands
│   ├── cli_helpers.py      # Shared JSON envelopes, Rich tables, profile validation
│   ├── cli_library.py      # `search`, `favorites`, `clip`, `conversations`, `playlists`
│   ├── cli_video.py        # `video` and `trim` subcommands
│   ├── client.py           # Async httpx client + auth/SSE transport
│   ├── config.py           # Settings, profile paths, timeouts
│   ├── errors.py           # Typed error hierarchy & exit codes
│   ├── library_ops.py      # Zero-credit library REST mixin
│   ├── mcp_library.py      # MCP library tool registrations
│   ├── mcp_server.py       # MCPServer stdio host + `--no-spend` policy
│   ├── mcp_video.py        # MCP video & trim tool registrations
│   ├── operations.py       # Generation, stems, remix edits, upload, download
│   ├── payloads.py         # Pure recipe/payload builders & ID validation
│   ├── profile_lease.py    # Cross-process refresh-token file lock
│   ├── session.py          # Dynamic Supabase config discovery & 0600 persistence
│   ├── sse.py              # Incremental SSE parser
│   ├── submit_policy.py    # Phase-tracked billing-safe SubmitAttempt
│   └── video_ops.py        # Clip video render, music-video library, social video, trim
└── tests/                  # 34 unit & stdio MCP tests (pytest)

License

See LICENSE (MIT).

Available Tools

26 tools
flowmusic_auth_statusB

Verify Flow Music session live against /users/me and return redacted summary.

Inputs: profile. Returns: object

flowmusic_chat_generateC

Send a conversational prompt to Flow Music Producer and collect generated clips.

Inputs: message (required), profile, model_name, conversation_id. Returns: object

flowmusic_create_social_videoC

Create a social music video from a clip (consumes social video quota/credits).

Inputs: clip_id (required), profile, length_s, conversation_id. Returns: object

flowmusic_creditsC

Check current Flow Music credits balance and subscription tier.

Inputs: profile. Returns: object

flowmusic_download_audioC

Download clip audio by ID (mp3, wav, or m4a) to a local file path.

Inputs: clip_id (required), out_path (required), profile, audio_format. Returns: object

flowmusic_edit_songC

Edit a clip via cover, extend, or replace (regions as ['start:end', ...]).

Inputs: kind (required), clip_id (required), seed, wait, +11 more. Returns: object

flowmusic_favoritesC

List favorited Flow Music clips for the signed-in profile.

Inputs: limit, offset, profile. Returns: object

flowmusic_generate_songC

Generate a song (Lyria 3.5 / Lyria 3 Pro / Lyria 4) and optionally save audio files.

Inputs: prompt (required), bpm, seed, wait, +8 more. Returns: object

flowmusic_get_clipsB

Fetch metadata and audio URLs for one or more clip IDs.

Inputs: clip_ids (required), profile. Returns: object

flowmusic_get_conversationB

Fetch full message history for one producer conversation ID.

Inputs: conversation_id (required), profile. Returns: object

flowmusic_get_music_videoB

Fetch metadata (or generation status when status_only=True) for a music video.

Inputs: video_id (required), profile, status_only. Returns: object

flowmusic_get_playlistC

Get playlist metadata and ordered track items by playlist ID.

Inputs: playlist_id (required), limit, offset, profile. Returns: object

flowmusic_list_clipsC

List generated Flow Music clips for the signed-in profile.

Inputs: limit, offset, profile, filter_kind. Returns: object

flowmusic_list_conversationsC

List producer conversation sessions for the signed-in profile.

Inputs: limit, offset, profile. Returns: object

flowmusic_list_music_videosC

List music videos from Flow Music.

Inputs: limit, offset, profile, user_id, +1 more. Returns: object

flowmusic_list_playlistsC

List playlists (mine, following, featured, or trending-daily/weekly/monthly).

Inputs: kind, profile, user_id. Returns: object

flowmusic_manage_playlistC

Create, update, favorite, delete (confirm_delete=True), or add/remove clips on a playlist.

Inputs: action (required), name, privacy, profile, +5 more. Returns: object

flowmusic_modelsC

List available Flow Music models on this account.

Inputs: profile. Returns: object

flowmusic_rename_conversationC

Rename a producer conversation session.

Inputs: title (required), conversation_id (required), profile. Returns: object

flowmusic_render_clip_videoC

Render (or fetch cached) shareable MP4 clip video and optionally save it to out_path.

Inputs: clip_id (required), preset, profile, out_path, +1 more. Returns: object

flowmusic_social_video_quotaB

Return remaining social music-video quota (used and limit).

Inputs: profile. Returns: object

flowmusic_split_stemsC

Separate a clip into stems (out_dir is required unless create_clips=True).

Inputs: clip_id (required), wait, out_dir, profile, +2 more. Returns: object

flowmusic_trim_clipC

Trim a clip to [start_s, end_s] seconds via audio__apply_effect.

Inputs: end_s (required), clip_id (required), start_s (required), wait, +6 more. Returns: object

flowmusic_update_clipC

Update clip metadata (title, privacy, lyrics, description), favorite flag, or like/dislike.

Inputs: clip_id (required), title, lyrics, privacy, +4 more. Returns: object

flowmusic_upload_audioC

Upload a local audio file, wait for analysis, and confirm it to obtain a clip_id.

Inputs: file_path (required), profile, filename, model_name, +2 more. Returns: object

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 26 tools

    Disambiguation4/5

    Most tools target a distinct resource and action, and the descriptions clarify overlapping areas such as list_clips vs. favorites vs. search. The main ambiguity is between create_social_video and render_clip_video, and to a lesser extent chat_generate vs. generate_song, but the boundaries are mostly inferable.

    Naming Consistency4/5

    All tools use the flowmusic_ prefix and snake_case, with a mostly predictable verb_noun pattern. Minor deviations include noun-only names like credits, models, favorites, and search, plus the reversed chat_generate.

    Tool Count3/5

    At 26 tools, the surface is heavy and near the upper bound for a single MCP server. The broad music-platform domain justifies many operations, but several related tools could likely be consolidated.

    Completeness4/5

    The server covers a wide lifecycle: auth, credits, models, generation, upload/download, editing, stems, clips, videos, conversations, playlists, and search. Minor gaps remain, notably no clear delete operations for clips, conversations, or music videos.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      A
      maintenance
      Drives Google Flow from an agent or the terminal: Veo text-to-video, image-to-video and clip extension, plus Imagen image generation. Runs locally against your own Google account with Flow access; video generation bills that account's credits.
      31
      8,232 PyPI
      1,421
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to create music with Google Flow Music (Lyria) using your own account: generate songs from text prompts, use custom lyrics, make instrumentals, restyle uploaded audio, continue and refine songs in a conversation, split tracks into stems, and list, download, rename, or delete clips. It also reports account credits and subscription status, so an agent can drive the whole song-production workflow without a browser.
      5
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients to create and edit Lyria songs, generate lyrics and videos, split stems, chat with the Producer agent, and manage sessions, playlists, and Spaces on Google Flow Music via Chrome CDP. It also queues credit-spending jobs with wait/cancel/retry controls and downloads audio, video, and cover art into an indexed local library.
      4
      MIT