mixxx-mcp-bridge
by visterion
README.md
# mixxx-mcp-bridge
> An MCP server that lets Claude (or any MCP client) DJ in [Mixxx](https://mixxx.org) 2.5 on
> Linux: load tracks, match tempos, crossfade over N bars, work loops, hotcues and effects, and
> read the state back so that every change is confirmed (old -> new). A long-lived bridge owns
> the MIDI ports, so MCP clients can come and go while Mixxx keeps its controller.
[](LICENSE)
[](https://www.python.org)
[](https://mixxx.org)
[](https://modelcontextprotocol.io)

## Why
The upstream [`cloudygetty-ai/mixxx-mcp`](https://github.com/cloudygetty-ai/mixxx-mcp) has the
right idea but does not work on Mixxx 2.5:
- **The write path is broken.** The controller mapping binds bare `<key>` names, the script
declares `const MixxxMCP` (invisible to Mixxx's script engine) and calls `setTimeout`, which
does not exist there, so commands never reach the controls.
- **State read-back is impossible.** The script posts state with `XMLHttpRequest` to a local
HTTP server, but Mixxx's controller engine (a plain `QJSEngine`) has no `XMLHttpRequest`.
- **Control change numbers collide.** The hotcue CC formula overlaps the deck 3 and 4 and the
master/crossfader CCs; `exit_loop`, nudge and beatjump act on the wrong deck or do nothing, and
fractional loop sizes are sent as 0.
This project keeps the idea and replaces the plumbing. State flows back over MIDI SysEx, commands
go out as a collision-free CC map, and a small bridge process keeps the MIDI ports alive.
### Features
- **State read-back via SysEx.** The controller script subscribes to 122 Mixxx controls and
reports every change at full double precision; every write tool answers with `old` -> `new` and
`confirmed`, taken from Mixxx's own feedback.
- **Load a track by path.** Mixxx has no control that loads a file by path, so `load_track` walks
the library view, identifies the selected row through the preview deck and the Mixxx process'
open files in `/proc`, and verifies the load (see [Limits](#limits)).
- **Beat-matched crossfade over N bars.** `crossfade` syncs or matches the tempo, starts the
incoming deck and ramps the crossfader over `bars x 4` beats at the playing deck's BPM.
- **Long-lived bridge.** Mixxx 2.5 opens MIDI controllers only at start-up, but MCP servers start
and stop with every client session. The bridge owns the virtual ports for the whole desktop
session; several MCP clients can talk to it at once.
- **No hanging.** Tools answer "bridge not running" or "Mixxx controller not connected" instead of
waiting.
## Architecture
```text
MCP client --stdio--> main.py / src/server.py (thin client, one per client session)
| JSON lines over $XDG_RUNTIME_DIR/mixxx-mcp-bridge.sock (0600)
v
src/bridge.py (long-lived user service)
| OUT "mixxx-mcp" -- CC commands (src/controls.py) --> Mixxx controller
| IN "mixxx-mcp" <-- SysEx state (src/protocol.py) -- script
v
state cache (value + timestamp per group/key)
```
- **Commands (Python -> Mixxx):** MIDI Control Change only, from the single map in
`src/controls.py`. Continuous values are 14-bit MSB/LSB pairs.
- **State (Mixxx -> Python):** SysEx text frames `F0 7D <ascii> F7` with `S|group|key|value`
records, a hello on controller init, heartbeats every 2 s and a bye on shutdown.
- **Pairing:** Mixxx joins an input and an output with the same port name into one controller, so
both bridge ports are named exactly `mixxx-mcp`.
The design and the evidence behind it are in
[`documentation/arc42/`](documentation/arc42/index.md).
## Tool catalog
| Tool | Notes |
|------|-------|
| `bridge_status()` | connected (or why not), age of the last feedback and heartbeat |
| `get_deck_state(deck)` / `get_mixer_state()` / `get_all_state()` | from the bridge cache |
| `refresh_state()` | asks the controller script to re-send everything |
| `play(deck)` / `stop(deck)` | writes report `old` -> `new` and `confirmed` |
| `cue(deck)` | trigger: reports that it was sent, no `old` -> `new` |
| `sync(deck, enabled=None)` | set, or toggle when omitted |
| `set_volume(deck, value, ramp_ms=500)` | fader 0..1, smooth ramp (at most 5 % of the range per 25 ms step) |
| `set_crossfader(value, ramp_ms=500)` | -1..1, smooth ramp |
| `set_pregain(deck, value)` | linear gain 0..3.98 (Mixxx's -12..+12 dB range) |
| `set_master_gain(value)` | linear gain 0..5.01 (Mixxx's -14..+14 dB range) |
| `set_eq(deck, low, mid, high)` | 0..4, 1 = neutral |
| `set_tempo(deck, bpm=None, rate_ratio=None)` | never writes `rate` (`rate_dir` is -1, which inverts it) |
| `nudge_tempo(deck, direction, size)` | per deck; up = faster |
| `set_loop(deck, beats)` | 1/32 ... 64, e.g. `0.25` or `"1/4"`; resizes an active loop |
| `exit_loop(deck)` | sets `loop_enabled = 0`; no-op without a loop |
| `halve_loop(deck)` / `double_loop(deck)` | |
| `beatjump(deck, beats)` | per deck, signed; leaves the GUI beatjump size alone |
| `set_hotcue` / `goto_hotcue` / `clear_hotcue(deck, slot)` | slots 1-8 |
| `toggle_effect(unit, effect, enabled)` / `set_effect_mix(unit, value)` | units 1-4 |
| `send_control(group, key, value)` | only controls in the CC map |
| `load_track(deck, path)` | a file in the music folder (`MIXXX_MCP_MUSIC_ROOT`, default `~/Music`; absolute or relative path; search queries are not supported); see below |
| `crossfade(from_deck, to_deck, bars=16, sync=True, start_to_deck=True, fade_volumes=False, force=False)` | see below |
No volume caps by design: values are validated only against Mixxx's own control ranges; fader and
crossfader moves ramp because that is musical.
**load_track.** The tool walks the library GUI: sidebar to *Tracks*, clear the search, sort by
location, load the selected row into the preview deck and see which file Mixxx opened
(`/proc/<pid>/fd` and `maps`) to learn where the selection is, move with `SelectTrackKnob`, probe
again until the preview shows the target, then `[ChannelN] LoadSelectedTrack` and confirm
(`track_loaded`, library duration within 0.05 s, a new handle on the file). It usually takes about
1 s, a few seconds when corrections are needed, and up to about 10 s when the track is also loaded
in another deck. `verified_by` in the result is
`new_handle` or the weaker `selection_probe`.
**crossfade.** Refuses unless `from_deck` plays, `to_deck` has a track, both BPMs are known and
within 10 % (`force=true` overrides) and the decks sit on opposite crossfader sides
(`fade_volumes=true` works without the crossfader). Then: tempo (`sync=true`/`"lock"` enables sync
on `to_deck`, `"tempo"` sets its `rate_ratio`, `false` leaves it alone), start `to_deck`, and ramp
the crossfader over `bars x 4 x 60 / bpm` seconds. The call blocks for the fade (at most 120 s);
cancelling it stops the fader where it is. It returns `old` -> `new` for every control it touched
and the timing used (computed and measured). `from_deck` keeps playing.
Other groups worth knowing for `send_control` are listed in the
[Mixxx controls reference](https://manual.mixxx.org/latest/en/chapters/appendix/mixxx_controls.html):
`[Channel1]`-`[Channel4]` (decks), `[Master]` (crossfader, gain), `[EffectRack1_EffectUnit1]`-`4`
(effect units), `[Playlist]` and `[Library]` (navigation).
## Configuration
| Variable | Read by | Default | Meaning |
|----------|---------|---------|---------|
| `MIXXX_MCP_MUSIC_ROOT` | MCP server (`main.py`) | `~/Music` | the music folder `load_track` is confined to; must be (inside) a Mixxx library folder |
| `MIXXX_MCP_SETTINGS_PATH` | MCP server | `~/.mixxx` | the Mixxx profile (`--settings-path`); identifies the right Mixxx process and its library database |
| `MIXXX_MCP_BRIDGE_SOCKET` | bridge and MCP server | `$XDG_RUNTIME_DIR/mixxx-mcp-bridge.sock`, else `/run/user/<uid>/mixxx-mcp-bridge.sock` | the bridge's Unix socket; the `load_track` lock lives next to it |
The bridge also takes `--socket`, `--port-name` (default `mixxx-mcp`) and `--log-level`
(`python -m src.bridge --help`). The bridge never reads the music folder, so it does not need
`MIXXX_MCP_MUSIC_ROOT`.
## Running
Requirements: Linux with the ALSA sequencer (`/dev/snd/seq`), Mixxx 2.5.x (tested on 2.5.6),
Python 3.12 or newer, systemd (for the user unit; you can also run the bridge by hand). Your user
must be able to open `/dev/snd/seq`: a desktop login gets that through the seat ACL, on a headless
or SSH-only machine add yourself to the `audio` group. Without it the bridge cannot create its
ports.
### Install
```bash
git clone https://github.com/visterion/mixxx-mcp-bridge ~/mixxx-mcp-bridge
cd ~/mixxx-mcp-bridge
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
# controller script and mapping
mkdir -p ~/.mixxx/controllers
install -m 0644 mixxx-mcp.js mixxx-mcp.midi.xml ~/.mixxx/controllers/
# the bridge as a systemd user unit
mkdir -p ~/.config/systemd/user
cp systemd/mixxx-mcp-bridge.service ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable --now mixxx-mcp-bridge
```
On Debian and Ubuntu, `python3 -m venv` needs the `python3-venv` package. If pip has to compile
`python-rtmidi`, it needs a C++ compiler and the ALSA development headers (`libasound2-dev`).
The unit assumes the clone lives in `~/mixxx-mcp-bridge`; edit `WorkingDirectory` and `ExecStart`
in the unit if it lives elsewhere.
Enable the controller in Mixxx once, either in the GUI (Preferences -> Controllers -> `mixxx-mcp`
-> mapping `mixxx-mcp`, tick *Enabled*, Apply) or, **while Mixxx is stopped**, in
`~/.mixxx/mixxx.cfg`:
```ini
[Controller]
mixxx-mcp 1
[ControllerPreset]
mixxx-mcp /home/you/.mixxx/controllers/mixxx-mcp.midi.xml
```
The mapping path must be absolute: replace `/home/you` with your home directory.
The device only appears when the bridge's ports exist at Mixxx start-up. Add your music folder to
the Mixxx library (Preferences -> Library); only tracks in the library can be loaded, and new files
need *Library -> Rescan*.
### Start order
1. **Bridge** - `systemctl --user start mixxx-mcp-bridge` (or `.venv/bin/python -m src.bridge`).
2. **Mixxx** - start it, or restart it, *after* the bridge, and again after every bridge restart:
Mixxx has no MIDI hot-plug, and the old ALSA addresses are gone after a bridge restart. A
working controller logs `[mixxx-mcp] init: 122/122 controls watched` with `--controller-debug`.
3. **MCP client** - connects to the bridge on each tool call.
`bridge_status` shows whether the controller has sent feedback.
### Register with Claude Code
```bash
claude mcp add mixxx -e MIXXX_MCP_MUSIC_ROOT=$HOME/Music -- \
~/mixxx-mcp-bridge/.venv/bin/python ~/mixxx-mcp-bridge/main.py
```
Any other MCP client works the same way: run `.venv/bin/python main.py` over stdio and pass
`MIXXX_MCP_MUSIC_ROOT` in the environment.
## Testing
```bash
.venv/bin/python -m unittest discover -s tests -t . # unit, fake-MIDI and real-ALSA tests
```
- The real-ALSA tests use ports named `mixxx-mcp-test-<pid>` and are skipped when `/dev/snd/seq`
is missing.
- `tests/test_js_map_matches_python.py` runs the controller script in a real `QJSEngine` from the
system `libQt6Qml` (the library Mixxx links) with fake `engine`/`midi` objects (`tests/js/`).
`tests/js/build.sh` builds the runner; it needs `g++` and the Qt 6 QtCore/QtQml/QtNetwork
headers. Point `QT6_INCLUDE_DIR` at them if they are not in `/usr/include/qt6` or
`/usr/include/x86_64-linux-gnu/qt6` (and `QT6_LIB_DIR` for the libraries). Without them the test
is skipped and says why.
- The headless end-to-end test against a real Mixxx is skipped unless `MIXXX_E2E=1`:
```bash
MIXXX_E2E=1 MIXXX_MCP_MUSIC_ROOT=~/Music \
MIXXX_E2E_TRACK1=artist/one.mp3 MIXXX_E2E_TRACK2=artist/two.wav \
.venv/bin/python -m unittest tests.e2e.test_mixxx_e2e -v
```
`MIXXX_E2E_TRACK1`/`2` (paths relative to the music folder) are required; pick two files whose
tempos differ by a few percent, ideally one MP3 and one WAV. It needs `Xvfb`, `mixxx`, `pactl`
and `unshare`, and it needs root: Mixxx starts in a private mount namespace (`unshare -m`)
where the music folder is read-only, and the test is skipped with a reason when the user may
not create one. It runs with your current environment (`XDG_RUNTIME_DIR` must point at your audio
server), and uses a private scratch directory: a fresh `mkdtemp` directory (mode 0700, removed
after a passing run) unless `MIXXX_E2E_BASE` names one. A configured base must be a real
directory (not a symlink) that you own with mode 0700; it is created if missing, and the test is
skipped otherwise. The test starts Xvfb on `:97`, a temporary null sink, a fresh Mixxx profile
(the music folder is mounted read-only for that Mixxx only), the bridge on the port
`mixxx-mcp-e2e`, then Mixxx; loads two tracks, beatjumps, plays, crossfades 2 bars with sync and
reads the state back; and removes all of it again.
## Limits
- **Linux only today.** Windows is planned. It would need loopMIDI for the virtual ports, a
non-Unix-socket transport between the MCP server and the bridge, and a different way to verify
`load_track`, which now reads `/proc`.
- `load_track` visibly moves what you see in the library (sidebar, search, sort, selection), and
each probe queues the probed track for analysis; results say so. A click in the library during
the walk can break it; the tool detects that and retries or fails, it never loads an
unverified row.
- `load_track` refuses a playing deck (Mixxx would refuse silently), and needs the MCP server on
the same host as Mixxx, as a user that can read `/proc/<mixxx pid>` and the library database.
- `crossfade` blocks for the whole fade, up to 120 s. A 16-bar crossfade at 93 BPM takes about
41 s; check that your MCP client's tool timeout allows it.
- Trigger tools (`cue`, `nudge_tempo`, the hotcue tools, `halve_loop`, `double_loop`) return no
`old` -> `new`; they only report that the trigger was sent.
- `set_loop`, `exit_loop`, `halve_loop`, `double_loop`, the hotcue tools and `nudge_tempo` have not
been exercised live with a loaded track yet; tests cover their CC encoding and routing only.
- Ramps from two clients on the same control interleave (there is no per-control lock). `load_track`
walks are serialized by a lock.
- There are no volume caps, so mind your master level.
## Security
- The bridge listens on a local Unix socket only (mode `0600`, next to a `0600` lock file). There
is no network listener, and the MCP server speaks stdio and prints nothing else on stdout.
- `load_track` is confined to the music folder: paths are resolved with `realpath`, links that
point out of it are refused, and the file must exist and have an audio extension.
- `send_control` accepts only controls that are in the CC map.
- The `load_track` lock file is opened with `O_NOFOLLOW` and refused unless it is a regular file
owned by the server's user and not writable by group or others.
## Documentation
Architecture notes (arc42-light): [`documentation/arc42/index.md`](documentation/arc42/index.md).
## Credits
This project started from [`cloudygetty-ai/mixxx-mcp`](https://github.com/cloudygetty-ai/mixxx-mcp)
(MIT) and keeps its tool surface. serrebidev independently found the same write-path and CC
collision bugs in upstream pull requests #1 and #2
(<https://github.com/cloudygetty-ai/mixxx-mcp/pull/1>); their fixes confirmed the diagnosis.
## Tech stack
Python 3.12, the official MCP SDK (`mcp` 1.30, FastMCP over stdio), `python-rtmidi` (ALSA
sequencer), a Mixxx controller script (JavaScript for Mixxx's `QJSEngine` plus a MIDI mapping
XML), a systemd user unit, `unittest`.
## License
[MIT](LICENSE), (c) 2026 cloudygetty-ai (original mixxx-mcp) and visterion (mixxx-mcp-bridge).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessOutdated data