agentleFS
mthinesmthines/reaper-mcp/reaper/CLAUDE.md

reaper-mcp / reaper

CLAUDE.md42 starsChanged 5 days agoMITView on GitHub

Files installed INTO the REAPER DAW by the setup command. These run inside REAPER's scripting environment.

The file

We split this CLAUDE.md into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Always wrap file reads in pcall for resilience

    line 61
  2. Distinctive:

    Run in REAPER's audio thread (not scripting thread)

    line 65
  3. Distinctive:

    Must pass audio through unmodified (transparent inserts)

    line 68
  4. Very specific:

    Check REAPER's real behaviour live before trusting the fake: some calls ignore arguments without an error (e.g.

    line 76

≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

REAPER Scripts

Files installed INTO the REAPER DAW by the setup command. These run inside REAPER's scripting environment.

Files

FileLanguagePurpose
mcp_bridge.luaLuaPersistent bridge: polls for JSON commands, executes ReaScript API, writes responses
mcp_tracks_lib.luaLuaTrack structure and routing
mcp_plan_lib.luaLuarun_plan executor, JSON decoder, chunk helpers
mcp_actions_lib.luaLuaAction search/run proxy, selection setters
mcp_project_lib.luaLuaProject ops, render settings, tempo map, markers
mcp_items_lib.luaLuaItems, takes, take FX, FX chains, track templates, stem tracks (insert_stems)
mcp_recording_lib.luaLuaRecord inputs, monitoring and modes, punch, fixed lanes, comping
mcp_arrange_lib.luaLuaCopy items, insert/remove time, copy a section, normalize/reverse/glue
mcp_envelopes_lib.luaLuaEnvelopes, points (dB through the envelope's scaling), pooled automation items
mcp_mixing_lib.luaLuaAutomation mode, FX modulation and pins, monitoring FX, freeze, apply FX, stretch markers and audio quantize
mcp_render_lib.luaLuaTrack renders for the analysis tools: cache, multi-track stem pass, macOS focus hand-back
mcp_midi_lib.luaLuaQuantize, transform, MIDI file import, pitch-class profile for detect_key, bar/beat grid + per-segment profiles for detect_chords
mcp_edit_views_lib.luaLuaStatus page results and before/after edit views
mcp_snapshot_lib.luaLuaShared library for snapshot action scripts (path helpers, JSON, restore logic)
mcp_prefs_lib.luaLuaKeeps the page's read-only (lk_ro_) LoreKit token in ~/.config/reaper-mcp/lorekit.json (mode 600) and the feature-flag overrides in flags.json (ExtState flag_overrides / flags_req, the same file the CLI and server read) so every way of opening the page shares them; bridge holds it in ext.prefs (the bridge is at Lua's 200-locals limit: add no top-level local)
mcp_snapshots_ui_lib.luaLuaStatus page Snapshots view: lists the folder, runs page restore/save requests through the bridge's dispatcher
mcp_snapshot_next.luaLuaAction: restore next snapshot (bind to key for A/B testing)
mcp_snapshot_prev.luaLuaAction: restore previous snapshot (bind to key for A/B testing)
mcp_snapshot_quick_save.luaLuaAction: save snapshot with auto-name, no dialog
mcp_analyzer.jsfxJSFX/EEL2Real-time FFT spectrum analyzer, writes to gmem[]
mcp_lufs_meter.jsfxJSFX/EEL2LUFS loudness metering
mcp_correlation_meter.jsfxJSFX/EEL2Stereo correlation and width analysis
mcp_crest_factor.jsfxJSFX/EEL2Crest factor (peak-to-RMS) measurement
mcp_gain_trace.jsfxJSFX/EEL2Pre/post gain trace for pumping/ducking: pair it around a chain (Mode pre/post, same Slot), read p5/p1/std after playback. No 1e9-style literals (EEL2 rejects them; jsfx-lint.test.ts checks)
mcp_ui.jsfx-incJSFX/EEL2The @gfx toolkit generated plugins inline (write_jsfx pastes it into their @init). Canonical source: edit here, never in a generated plugin. Globals are ui_-prefixed; sliders must be unnamed; no 1e9-style literals
install.shShellManual install helper

Lua Bridge (mcp_bridge.lua)

How It Works

  1. Runs as a persistent reaper.defer() loop (polls every ~30ms)
  2. Reads command_{uuid}.json from bridge directory
  3. Dispatches to handler function in the handlers table
  4. Writes response_{uuid}.json with results
  5. Writes heartbeat.json every 1s for liveness detection (removed on exit). At start, a fresh heartbeat in the folder means another bridge serves it: the new one waits up to 6 s (a restarting bridge stops writing it) and then stands down with a console message, because two bridges on one folder would split the commands between two REAPERs. A second REAPER needs its own resource folder (reaper-mcp instance create). The whole startup lives in run_bridge() since the main chunk is at the 200-locals limit
  6. Publishes a status feed to ExtState MCPBridge/status for the web status page (apps/bridge-ui)

Adding a Handler

handlers["command_type"] = function(params)
  local result = reaper.SomeApiCall(params.paramName)
  return { field = result }
end

The command type string must exactly match CommandType in libs/protocol/src/commands.ts.

Key Constraints

  • REAPER Lua is sandboxed: no sockets, no HTTP, no stdin/stdout — file-based IPC only
  • JSON parsing: uses CF_Json_Parse if available (REAPER 7+), falls back to custom Lua parser
  • Track indices are 0-based (same as ReaScript)
  • Volume values: bridge converts between dB (MCP protocol) and linear (ReaScript internally)
  • Always wrap file reads in pcall for resilience

JSFX Meters

  • Run in REAPER's audio thread (not scripting thread)
  • Communicate with Lua via gmem[] shared memory
  • Each JSFX uses a unique gmem namespace (e.g., MCPAnalyzer, MCPLufsMeter)
  • Must pass audio through unmodified (transparent inserts)
  • Auto-inserted by corresponding MCP tools (read_track_spectrum, read_track_lufs, etc.)

Testing

  • Lua runs in tests through wasmoon (Lua 5.4 in WebAssembly) against a fake reaper API: the *_lib.lua files are pure (they take the API as an argument) and are tested in *-lib.test.ts; the whole bridge runs in bridge-*.test.ts. Put new logic in a lib, not in mcp_bridge.lua (its main chunk is at Lua's 200-locals limit)
  • Check REAPER's real behaviour live before trusting the fake: some calls ignore arguments without an error (e.g. SetEnvelopePointEx with a flagged automation item index), and the fake should model what you saw
  • Server-side tests stub sendCommand() in bridge.ts

Installation

Files are copied to {REAPER_RESOURCE_PATH}/Scripts/ by:

  • node dist/apps/reaper-mcp-server/main.js setup (programmatic)
  • install.sh (manual)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.