Skip to content

About

MCP server for generating xLights light show sequences from music analysis

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

⚠️ Beta: This project is currently in beta. Features may change, and you may encounter bugs. Feedback and contributions are welcome!

xLights MCP Server

An MCP (Model Context Protocol) server that analyzes music and generates xLights light show sequences. Works with any MCP-compatible AI tool — GitHub Copilot CLI, Claude Desktop, Cursor, VS Code + Copilot Chat, Windsurf, Cline, and more.

Give it an .mp3, and it will analyze the beats, song structure, and energy — then generate a valid .xsq sequence file with effects placed across all of your light models, synced to the music.


What It Does

🎵 Audio Analysis

  • Beat & tempo detection — identifies every beat, downbeat, and bar boundary
  • Song structure — detects intro, verse, chorus, bridge, and outro sections
  • Frequency spectrum — bass, mid, and high energy curves over time
  • Energy profiling — loudness dynamics, peak detection, dynamic range
  • Source separation — isolate vocals, drums, bass, and other stems via Demucs (optional)

💡 Sequence Generation

  • Generates valid .xsq files that open directly in xLights — no xLights GUI required during generation
  • Reads your actual show config — knows your models, controllers, channel counts, and model types
  • Baseline sequences — works from your xLights groups: a dimmed wash in quiet sections, feature groups taking turns by height, and short accent hits on downbeats in choruses and drops
  • Hand-made-style sequences — the sequence_song prompt walks your AI through planning a sequence section by section and writing it with write_sequence
  • Palettes — colour names or #RRGGBB via palette_hint, or a theme's colours (Christmas, Halloween, …)
  • Generation modes:
    • Automatic — writes the baseline, you review in xLights
    • Guided — AI shows song structure, you choose effects per section
  • Never overwrites — existing sequences are safe; generated files get a (generated N) suffix

📦 Sequence Import & Remapping

  • Import community sequences — take any .xsq or .zip package from the xLights community and remap it to your show layout
  • Intelligent model matching — automatically maps imported models to yours by name, type, and pixel count
  • Zip package support — extracts audio, video, shader, and image assets; rewrites hardcoded file paths
  • Singing model awareness — singing face models only match to other singing models
  • Full mapping report — see exactly what matched, how, and what was skipped
  • Manual overrides — correct any mapping before the remapped sequence is generated

📡 FPP Integration

  • Check status of your Falcon Pi Player
  • Upload sequences (.fseq + audio) to FPP
  • Manage playlists — list, start, stop
  • Works with FPP's REST API

Prerequisites

  • Python 3.11+
  • uv (recommended) or pip
  • ffmpeg — for audio format handling (brew install ffmpeg on macOS, apt install ffmpeg on Linux); also required by madmom (the beats extra) to decode mp3. Note: librosa 1.0 dropped m4a support — convert .m4a files to .mp3 or .wav before analyzing.
  • xLights — installed with at least one show folder configured

Installation

Step 1: Clone the repository

git clone https://github.com/JohnBreault/xlights-mcp-server.git
cd xlights-mcp-server

Step 2: Create a virtual environment and install

uv venv
uv pip install -e .

Optional extras for enhanced features:

# Stem separation — isolates vocals/drums/bass for smarter sequencing (~2GB model download)
uv pip install -e ".[separation]"

# Lyrics/singing faces — transcribes vocals for lip-sync animation
uv pip install -e ".[lyrics]"

# Better beat detection (madmom, installed from a git commit and built from
# source — needs git and a C compiler; on Windows install git and
# "Desktop development with C++" from the VS Build Tools)
uv pip install -e ".[beats]"

# Everything (also needs git + a C compiler on Windows, for the beats extra above)
uv pip install -e ".[all]"

Step 3: Show folder configuration

On first run, the server auto-detects your xLights show folders by scanning common locations:

OS Locations checked
macOS ~/Library/Mobile Documents/com~apple~CloudDocs/xLights/, ~/Documents/xLights/
Windows ~/Documents/xLights/
Linux ~/Documents/xLights/, ~/xLights/, /opt/xLights/

It looks for directories containing xlights_rgbeffects.xml (the file xLights creates in every show folder).

If auto-detection doesn't find your folders, create or edit ~/.xlights-mcp/config.json:

{
  "show_folders": {
    "christmas": "/path/to/your/xLights/Christmas",
    "halloween": "/path/to/your/xLights/Halloween"
  },
  "active_show": "christmas",
  "fpp": {
    "host": "fpp.local",
    "port": 80
  }
}

Step 4: Connect to your AI tool

The server uses stdio transport — your AI tool launches it as a subprocess.

GitHub Copilot CLI

Add to ~/.copilot/mcp-config.json:

{
  "mcpServers": {
    "xlights": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/xlights-mcp-server", "xlights-mcp-server"]
    }
  }
}

Restart Copilot CLI after saving.

Claude Desktop

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "xlights": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/xlights-mcp-server", "xlights-mcp-server"]
    }
  }
}

Restart Claude Desktop after saving.

VS Code + Copilot Chat

Add to your VS Code settings.json:

{
  "mcp": {
    "servers": {
      "xlights": {
        "command": "uv",
        "args": ["run", "--directory", "/path/to/xlights-mcp-server", "xlights-mcp-server"]
      }
    }
  }
}
Cursor

Add to Cursor MCP settings (Settings → MCP Servers → Add):

  • Name: xlights
  • Command: uv
  • Args: run --directory /path/to/xlights-mcp-server xlights-mcp-server
Other MCP clients

Any tool that supports the Model Context Protocol can use this server. Point it at:

command: uv
args: run --directory /path/to/xlights-mcp-server xlights-mcp-server
transport: stdio

Replace /path/to/xlights-mcp-server with the actual path where you cloned the repo.


Usage

Once connected, interact with the server through natural language in your AI tool. Here are some example workflows:

Explore your show

> List my xLights shows
> Switch to the Halloween show
> List all my light models
> Show me the controllers
> What sequences do I have?
> Inspect the "Deck The Halls" sequence

Analyze a song

> Analyze the song ~/Music/Jingle Bell Rock.mp3
> Show me the song structure for ~/Music/Monster Mash.mp3
> Get the beat map for this song
> What's the energy profile look like?

Generate a sequence

> Create a sequence for ~/Music/Jingle Bell Rock.mp3
> Create a sequence for ~/Music/Jingle Bell Rock.mp3 using red and green colors
> Preview what a sequence would look like for this song before creating it

When generating, you'll be asked to choose a mode:

  • auto — writes a simple baseline sequence
  • guided — see the song structure first, then choose effects per section
  • template — not implemented yet

Import a community sequence

> Import the sequence ~/Downloads/Holly Jolly Christmas SD.zip to my show
> Import ~/Downloads/Christmas Time.xsq and show me the model mapping
> Import this sequence but map "Arch Left" to my "Arches-1" model

The importer supports both standalone .xsq files and .zip packages (which include audio, video assets, and the source show's model data). It automatically matches models from the imported sequence to your layout using:

  1. Exact name match → identical model names
  2. Similar words → shared words like "snowflake", "arch", "tree"
  3. Model type → same display_as type (e.g., both Arches)
  4. Pixel count → within 70% of each other
  5. Manual overrides → you choose specific mappings

Manage FPP (when controllers are online)

> Check the FPP status
> List playlists on FPP
> Start the Christmas playlist
> Stop playback

Available Tools

Show Management

Tool Description
list_shows List all configured xLights show folders
switch_show Switch the active show folder
list_models List all light models with type, controller, and category info ("Dont Map" placeholders hidden unless include_placeholders)
get_show_layout Model groups with a suggested tier (wash / feature / skip), hierarchy, height range and accent props; override tiers in xlights-mcp.json in the show folder (an override can change which groups count as sub-parts of a feature)
list_controllers List controllers with IPs, protocols, and channel counts
list_sequences List all .xsq sequence files in the active show, each with generated (written by this server, or hand-made) and modified
inspect_sequence Show song info, duration, effects, and models used in a sequence
profile_sequence Style profile of a sequence against the show layout: elements lit at once, dark share, parents lit with their children, layers and effects per element — use a hand-made sequence as the target style
list_effects List all available xLights effects with descriptions

Audio Analysis

Tool Description
analyze_song Full audio analysis: beats, structure, spectrum, energy — includes a stems summary (per-stem onset/energy counts) when source separation is installed
get_song_structure Detect song sections — verse/chorus/bridge, or intro/build/drop/breakdown/outro for tracks with a structural drum gap; sections carry drums (present/absent/decaying) when a drum stem was analyzed
get_beat_map Get beat timestamps, downbeats, tempo, and onsets — includes beat_source (madmom/librosa) and drum_aligned
get_energy_profile Get loudness curve and bass/mid/high frequency band energy
get_stem_events Per-stem onsets, kicks (drum hits with a kick's low end), energy (per beat or bar), or silences from source separation, windowed and paged; silences are bounded by audible hits, so a drum silence starts when the hits stop

Sequence Generation

Tool Description
create_sequence Generate a baseline .xsq from an .mp3: wash in quiet sections, feature groups taking turns, accents on downbeats (use the sequence_song prompt for hand-made-style sequences)
write_sequence Validate an effect plan (element, layer 0–2 where layer 0 draws on top, effect, times, settings, palette with optional brightness curves, optional blend mode) against the show and song, then write it as an .xsq, with optional Beats/Bars/stem timing tracks (including Kicks); validate_only returns the report without writing
preview_plan Preview the generation plan without writing a file

Sequence Import & Remapping

Tool Description
import_sequence Import a .xsq or .zip sequence package and remap models to your layout

FPP Integration

Tool Description
fpp_status Check FPP connection and playback state
fpp_upload_sequence Upload .fseq and audio to FPP
fpp_list_playlists List all playlists on FPP
fpp_start_playlist Start a playlist (with optional repeat)
fpp_stop Stop current playback

Prompts

Prompt Description
sequence_song Playbook for a hand-made-style sequence: analyse the song, read the show layout, profile a hand-made reference sequence (the most recent one by default), plan section by section, then validate and write with write_sequence. Includes the show folder's .claude/CLAUDE.md when present

How It Works

Effect Selection Logic

create_sequence (auto mode) writes a small baseline from the show's xLights groups, tiered into wash, feature and skip groups:

Section What lights
Intro, outro, breakdown The largest wash group, dimmed Color Wash
Verse, bridge, build, transition Half of the feature groups (split by height, alternating each section)
Chorus, drop, instrumental The same, plus a short On on an accent prop at each downbeat, skipping props inside the lit groups

A show without feature groups lets its props take turns the same way instead; without a wash group, the quiet sections stay dark. Both are reported as warnings, and a show with nothing to light is an error.

Feature-group effects follow the group's majority model type (arches get chases, trees get spirals, …): gentle effects below 0.65 energy, motion effects above. Singing-face models get a background plus a Faces effect driven by the assigned lyric track. While faces are sequenced, groups containing a singing model are left out so nothing lights over the face; singing models are never used as accents. Beats and Bars timing tracks are added, plus Drums, Bass, Instruments and Kicks when stems are available (accents also start on the kick when one falls within 100 ms of the downbeat); a track named like a model or group is skipped, and a clashing lyric track is renamed. For anything richer, use the sequence_song prompt, which plans a hand-made-style sequence and writes it with write_sequence.

create_sequence returns output_path, elements, total_effects, layers_used, palette, palette_unrecognised, timing_tracks, warnings, has_lyrics, singing_models and vocal_assignments.

File Format

Generated .xsq files are standard xLights XML containing:

  • <head> — song metadata, media file path, duration, timing (25ms frames), and the installed xLights version
  • <ColorPalettes> — themed color palettes for effects
  • <EffectDB> — deduplicated effect parameter definitions
  • <DisplayElements> — the models and groups the sequence uses, plus its timing tracks
  • <ElementEffects> — effect placements per model, per layer, with timing

Project Structure

xlights-mcp-server/
├── pyproject.toml
├── README.md
├── src/xlights_mcp/
│   ├── server.py              # MCP server entry point & tool definitions
│   ├── config.py              # Configuration management
│   ├── audio/
│   │   ├── analyzer.py        # Full analysis pipeline orchestrator
│   │   ├── beats.py           # Beat/tempo/onset detection (librosa + madmom)
│   │   ├── structure.py       # Song section detection (verse/chorus/bridge)
│   │   ├── spectrum.py        # Frequency band & energy analysis
│   │   └── separator.py       # Demucs stem separation (optional)
│   ├── xlights/
│   │   ├── show.py            # Show folder parser (networks + models XML)
│   │   ├── xsq_reader.py     # Parse existing .xsq sequences
│   │   ├── xsq_writer.py     # Generate .xsq XML files
│   │   ├── profile.py         # Style profile of a hand-made sequence
│   │   ├── effects.py         # Effect library & model/music mappings
│   │   ├── palettes.py        # Color palette definitions & themes
│   │   └── models.py          # Data models (Controller, LightModel, etc.)
│   ├── prompts/
│   │   ├── __init__.py        # Renders the sequence_song prompt
│   │   └── sequence_song.md   # Playbook template
│   ├── sequencer/
│   │   └── engine.py          # create_sequence: the baseline plan, singing faces, guided preview
│   └── fpp/
│       ├── client.py          # FPP REST API client
│       ├── upload.py          # Sequence upload to FPP
│       └── schedule.py        # Schedule management
└── tests/

Development

Tests run hermetically by default (separation and beat-tracking backends are stubbed), so pytest needs none of the optional extras installed. To also exercise the real Demucs/madmom backends (needs the separation and beats extras installed):

# Windows
.venv/Scripts/python -m pytest -m real_backends

# macOS/Linux
.venv/bin/python -m pytest -m real_backends

Troubleshooting

MCP server not loading

  • Verify your MCP config file is valid JSON (no comments, no trailing commas)
  • Check the --directory path points to the repo root (where pyproject.toml is)
  • Restart your AI tool after config changes
  • Test manually: cd /path/to/xlights-mcp-server && uv run xlights-mcp-server — should start without errors

"No xLights show folders found"

  • Make sure xLights is installed and you've opened it at least once (it creates xlights_rgbeffects.xml in each show folder)
  • If your show folder is in a non-standard location, add it to ~/.xlights-mcp/config.json

"No models found" error

  • Verify the show folder contains xlights_networks.xml and xlights_rgbeffects.xml
  • Use list_shows to check which show is active and whether the path exists

Audio analysis is slow

  • First run downloads librosa data (~10MB); subsequent runs are faster
  • Demucs stem separation takes 30-60s per song on CPU; results are cached
  • Without optional deps, analysis takes ~5s per song

Generated sequence looks wrong in xLights

  • The .xsq is a starting point — tweak effects, timing, and palettes in xLights
  • Use inspect_sequence to review what was generated before opening

FPP connection fails

  • Verify FPP is powered on and on the same network
  • Check the hostname/IP in ~/.xlights-mcp/config.json
  • FPP tools gracefully report connection errors; core generation works fully offline

License

MIT

About

MCP server for generating xLights light show sequences from music analysis

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages