Development
Layout
| Path | What |
|---|---|
src/main.rs | Binary: flags, then the MCP server on stdio. |
src/server/ | The MCP tools (mod.rs). Most forward their arguments to a Lua handler; the larger bodies are in handlers.rs. |
src/args/ | Tool arguments; their doc comments become the JSON schema descriptions. |
src/bridge.rs | File-based IPC client for the Lua bridge. |
src/track_templates.rs | Track template and FX chain manipulation on REAPER state chunks. |
src/audio.rs | WAV reading, loudness (BS.1770), spectrum and comparison. |
src/reaper_host.rs | Windows-only helpers that work without the bridge. |
lua/reaper_mcp_bridge.lua | The loop inside REAPER: reads requests, runs handlers, writes responses and the heartbeat. |
lua/reaper_mcp_handlers.lua, lua/handlers/ | One handler per command, grouped by area (project, tracks, items, fx, envelopes, render); shared helpers in support.lua. Reloadable with reload_bridge. |
tests/lua/fake_reaper.lua | In-memory fake of the ReaScript API for tests. |
docs/ | This book (mdBook). |
Build and check
cargo build
cargo fmt --all
cargo clippy --all-targets -- -D warnings
cargo test --all-targets
CI runs the same on Linux, macOS and Windows, plus a Lua syntax check and ShellCheck. A pull request can be merged only when CI passes.
Tests
- Unit tests next to the code: state chunk edits, argument schemas, JSON rounding.
tests/bridge_*.rs(bridge_ipc,bridge_tracks,bridge_items,bridge_fx,bridge_project; shared harness intests/common/) run the real bridge and handlers in a Lua 5.4 interpreter againsttests/lua/fake_reaper.lua, and talks to them throughBridgeClient, the IPC the server uses. Installlua5.4(or aluathat is 5.4) to run them; without one they are skipped locally, and CI requires them (REAPER_MCP_REQUIRE_LUA=1). The fake raises an error naming any ReaScript function it does not implement, so extend it when a test needs more.tests/audio_analysis.rsandtests/audio_signals.rscheck the analysis against generated signals with known levels;tests/track_templates_chunks.rscovers the FX chain chunk editing.- Consistency checks in
src/server/mod_test.rs: every tool has a unique name, a description and an object schema; every command the server sends has a Lua handler;docs/src/reference.mdmatches the tool definitions.
Adding a tool
- Add the arguments to the matching file in
src/args/with a doc comment on every field. - Add the tool to
src/server/mod.rswith a description that says what it changes and what it returns. - Add the handler to the matching file in
lua/handlers/ashandlers.<name> = function(args). Validate arguments first, then change the project insideundo("…", function() … end). - Add a test in the matching
tests/bridge_*.rsand the ReaScript functions it needs to the fake. - Regenerate the reference:
REAPER_MCP_UPDATE_DOCS=1 cargo test. - If the bridge calls new ReaScript functions, update the counts and the text in the
REAPER API coverage table and its copy in README.md;
python3 scripts/check-api-coverage.pyprints the counts and fails in CI while they differ. Update the roadmap when a gap closes.
To try a handler change in a running REAPER without restarting it, copy the Lua files with the
install script and call reload_bridge.
Documentation
cargo install mdbook
mdbook serve docs
The book is published to GitHub Pages when docs/ changes on main.
Pull request titles
Pull requests are merged with Squash and merge: the title becomes the commit message on main,
so it must be a Conventional Commit. feat: and fix:
appear in the changelog and choose the next version; docs:, test:, refactor:, ci: and
chore: do not. See Releases.
End-to-end with real REAPER
The bridge tests use a fake ReaScript API. To check the tools against a real REAPER on Linux:
mkdir -p ~/opt/reaper-test && tar -xJf reaper*_linux_x86_64.tar.xz -C ~/opt/reaper-test
touch ~/opt/reaper-test/reaper_linux_x86_64/REAPER/reaper.ini # portable: leaves ~/.config/REAPER alone
scripts/e2e-reaper.sh [--samples] ~/opt/reaper-test/reaper_linux_x86_64/REAPER
The script builds the server, installs the bridge from the checkout into that REAPER, starts it with an empty project on its own virtual X display (Xvnc or Xvfb) and runs the scenarios over MCP:
scripts/e2e/scenario.pytries the tools one area at a time on a few tracks.scripts/e2e/project_scenario.pybuilds a realistic 17-track project the way an agent would: audio frommake_audio.py(drums, bass, guitars and a vocal-like part, generated, so nothing is stored in the repository), folders under a MIX BUS, reverb and delay returns fed by sends, a ReaSynth part, song sections as regions. It then checks the structure, normalizes, renders the mix, group stems, variants and sections, compares the mix with a reference, exports and applies mix templates and FX chains, and saves and reopens the project.scripts/e2e/tools_scenario.pycovers the tools the others do not reach: FX parameters, choices, presets, pins and envelopes, sends, a multi-output instrument (ReaSynDr), item and track moves, media offline, project settings, actions and reloading the bridge.scripts/e2e/dialogs_scenario.pywrites two small projects that make REAPER open “Project Settings” (notes shown on load) and “Project Load Warning” (unknown token), opens each with and withoutREAPER_MCP_CLOSE_DIALOGS=1, and checksclosed_dialogs, the timeout hint,show_on_loadand the notes’ line ends. No download needed. Onlyscripts/e2e-reaper.ps1runs it so far; on Linux the same dialogs are exercised by--samples.scripts/e2e/multi_scenario.pystarts a second REAPER (-newinst) on its own IPC directory, checks that each server reaches only its own instance, and runs two server processes on one REAPER at once.- With
--samples,scripts/e2e/samples_scenario.pyopens eight of the old sample projects Cockos publishes (recorded audio, REAPER 0.x to 2.x), reads every track with the read-only tools, checks the track and item counts against the.rppfiles, renders and analyses each mix. The projects are downloaded once into~/.cache/reaper-mcp-e2e/samples; they are copyrighted by their authors and never stored in this repository.
Some projects make REAPER open a modal window while loading (“Project Load Warning” for unknown
project tokens, “Project Settings” for a project that shows its notes on load). The samples scenario
runs the server with REAPER_MCP_CLOSE_DIALOGS=1 and checks that it closed them, so --samples
needs xdotool. Each check prints one line, and
the run fails when a value is wrong. It uses only REAPER’s bundled plugins and works in evaluation
mode. Run it before a release and after changing a handler; extend a scenario when a tool changes.
On Windows
Copy-Item 'C:\Program Files\REAPER (x64)' C:\opt\reaper-test -Recurse
New-Item C:\opt\reaper-test\reaper.ini -ItemType File # portable: leaves %APPDATA%\REAPER alone
scripts\e2e-reaper.ps1 [-Samples] [-KeepWork] -ReaperDir C:\opt\reaper-test
The script does the same on Windows: it builds the server, installs the bridge into the copy
(install-bridge.ps1 -Startup), starts REAPER and runs the same scenarios. Needs cargo and Python 3
(python, python3 or py -3). Things it handles that a hand-made run trips over:
- REAPER is started with
-newinst -cfgfile <dir>\reaper.ini. Without-newinsta running REAPER takes over the command line (a new tab in your session); without-cfgfilea copy made by the installer falls back to%APPDATA%\REAPERand loads the bridge installed there. - A fresh profile opens first-run dialogs (audio device, new version, About). The script answers them
with “No” (or closes them) and waits for the plug-in scan to finish; closing the scan window makes
add_fxfail. - The work directory is
%TEMP%\reaper-mcp-e2e <non-ASCII> <id>, so paths with spaces and non-ASCII characters are exercised on every run. - The REAPER it started is closed through its window (a “Save changes?” prompt gets “No”) and never killed; if it stays open the script says so.
tools_scenario.pyopens a track FX window, checksinspect_reaper_windows, closes it withclose_reaper_fx_windows, and runsrestart_bridgewhen it is the only REAPER process and a bridge is installed in%APPDATA%\REAPER(the tool always restarts the first REAPER it finds and loads that install, so otherwise the step is skipped, and when it runs it writes its startup wrapper there).-Samplesruns the Cockos sample projects withREAPER_MCP_CLOSE_DIALOGS=1(noxdotoolneeded); the zips are cached in%LOCALAPPDATA%\reaper-mcp-e2e\samples.
Every tool must run in a scenario: python3 scripts/check-e2e-coverage.py (in CI) fails when a tool is
neither called by a scenario nor listed in that script with the reason it cannot be run (today none).
A new tool therefore comes with its scenario steps.