FA

Fal MCP Server: FLUX, Stable Diffusion, MusicGen

Generate AI images, videos, and music with FLUX, Stable Diffusion, and MusicGen via Fal.ai MCP server directly in Claude.

Quick Install
npx -y @raveenb/fal-mcp-server

Overview

Fal MCP Server is a lightweight MCP (Model Context Protocol) server that exposes multimedia generation tools—FLUX, Stable Diffusion, and MusicGen—so an MCP-aware assistant (for example, Claude via Fal.ai) can call them programmatically. It acts as a bridge between the client (assistant or app) and underlying generative models, exposing a consistent tool interface for image, video, and audio generation.

This server is useful when you want to integrate multimodal synthesis into conversational agents or automation pipelines without wiring each model individually. Instead of embedding model SDKs inside the assistant, you register the Fal MCP Server as an MCP tool provider; the assistant can then request images, video clips, or music tracks as discrete tool invocations, and the server handles the model orchestration, parameter translation, and result hosting.

Features

  • Exposes FLUX, Stable Diffusion, and MusicGen capabilities through MCP-compatible endpoints
  • Standardized tool signatures so assistants can request media generation with prompts and options
  • Supports synchronous and asynchronous workflows (job IDs, status polling, and result URLs)
  • Runs locally or in containerized environments (Docker)
  • Simple configuration via environment variables or a .env file
  • HTTP JSON API for direct use (curl, scripts) in addition to MCP discovery

Installation / Configuration

Prerequisites: Python 3.8+, Docker (optional), and any external model API keys or URLs required for FLUX, Stable Diffusion, or MusicGen providers.

Clone and install locally:

git clone https://github.com/raveenb/fal-mcp-server.git
cd fal-mcp-server
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Create a .env file with provider configuration (example):

# Server
PORT=8080

# Stable Diffusion (local or hosted inference)
STABLE_DIFFUSION_URL=http://localhost:5000/api/generate
STABLE_DIFFUSION_API_KEY=your_sd_key

# FLUX (video / animation)
FLUX_API_URL=https://api.flux.example/v1/render
FLUX_API_KEY=your_flux_key

# MusicGen (audio synthesis)
MUSICGEN_API_URL=https://api.musicgen.example/v1/generate
MUSICGEN_API_KEY=your_musicgen_key

Run the server:

# from the repo root
export $(cat .env | xargs)  # Unix-like systems load env vars
python app.py
# server will be available at http://localhost:8080

Run with Docker:

docker build -t fal-mcp-server .
docker run -p 8080:8080 \
  -e PORT=8080 \
  -e STABLE_DIFFUSION_URL="http://sd:5000/api/generate" \
  -e STABLE_DIFFUSION_API_KEY="..." \
  -e FLUX_API_KEY="..." \
  -e MUSICGEN_API_KEY="..." \
  fal-mcp-server

Available Tools / Resources

The server exposes a set of tools (examples — check the running server /tools endpoint for exact signatures):

Tool nameTypePrimary inputs
stable-diffusionImageprompt, width, height, steps, guidance_scale
flux-renderVideo/Imageprompt, duration, fps, style, seed
musicgenAudioprompt, duration, sample_rate, style

Typical responses include a job id, status, and a URL to the generated asset when completed. The server may support transforming outputs (PNG/JPEG, MP4, WAV/MP3).

Example: list tools (HTTP GET)

curl http://localhost:8080/tools

Example: submit a generation job (HTTP POST)

curl -X POST http://localhost:8080/generate \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "stable-diffusion",
    "prompt": "A serene futuristic city at sunset, cinematic, 4k",
    "options": {"width":1024,"height":768,"steps":30}
  }'

Response (example):

{
  "job_id": "abc123",
  "status": "queued",
  "result_url": null
}

Poll status:

curl http://localhost:8080/jobs/abc123

Use Cases

  • Assistant-generated marketing assets: Ask Claude to create campaign images and a short ambient music intro. The assistant calls the MCP tools (stable-diffusion and musicgen) and returns URLs for review.
  • Multimodal content pipelines: Automate generation of thumbnails (Stable Diffusion), short promo clips (FLUX), and background tracks (MusicGen) for a video publishing workflow. The server centralizes model endpoints and keys.
  • Prototyping creative workflows: Developers can prototype prompt-to-media flows without embedding SDKs into their app—just call the Fal MCP Server API from backend code or register it as a tool with Fal.ai and similar platforms.
  • Interactive demos: Build chatbots that generate on-demand visuals and audio. When a user asks for “a 10-second lo-fi beat for my loop,” the assistant triggers MusicGen via the MCP server and returns an audio URL.

Tips and Best Practices

  • Provide concise, descriptive prompts and experiment with temperature/guidance parameters for variety.
  • Use asynchronous flows for longer jobs: submit, then poll or subscribe to webhook callbacks to avoid timeouts.
  • Secure API keys and restrict network access in production; prefer internal network calls or private endpoints for model hosts.
  • Check the server’s /tools and /jobs endpoints to discover supported parameters and job lifecycle details specific to your deployment.

For detailed API signatures, example prompt templates, and advanced configuration, inspect the repository and the running server’s discovery endpoints.

Tags:media