@mthines/reaper-mcp 0.73.0 → 0.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/main.js CHANGED
@@ -4453,6 +4453,71 @@ function ensureSnapshotActions(kb) {
4453
4453
  const body = kb === "" || kb.endsWith("\n") ? kb : kb + eol;
4454
4454
  return { kb: body + lines.join(eol) + eol, added };
4455
4455
  }
4456
+ var AUTOSTART_MARKER = "reaper-mcp: start the bridge with REAPER";
4457
+ var AUTOSTART_BEGIN = `-- ${AUTOSTART_MARKER} (begin)`;
4458
+ var AUTOSTART_END = `-- ${AUTOSTART_MARKER} (end)`;
4459
+ var AUTOSTART_BLOCK = [
4460
+ AUTOSTART_BEGIN,
4461
+ "-- Written by `reaper-mcp setup`. Turn it off in the bridge window: Settings \u2192 Start with REAPER.",
4462
+ "do",
4463
+ ' local bridge = reaper.GetResourcePath() .. "/Scripts/mcp_bridge.lua"',
4464
+ ' if reaper.GetExtState("MCPBridge", "cfg_autostart") ~= "0" and reaper.file_exists(bridge) then',
4465
+ " local id = reaper.AddRemoveReaScript(true, 0, bridge, true)",
4466
+ " if id and id > 0 then reaper.Main_OnCommand(id, 0) end",
4467
+ " end",
4468
+ "end",
4469
+ AUTOSTART_END
4470
+ ];
4471
+ function ensureBridgeAutostart(startup) {
4472
+ const eol = startup.includes("\r\n") ? "\r\n" : "\n";
4473
+ const block = AUTOSTART_BLOCK.join(eol);
4474
+ const lines = startup.split(/\r?\n/);
4475
+ const begin = lines.indexOf(AUTOSTART_BEGIN);
4476
+ const end = begin === -1 ? -1 : lines.indexOf(AUTOSTART_END, begin);
4477
+ let text7;
4478
+ if (begin !== -1 && end !== -1) {
4479
+ text7 = [...lines.slice(0, begin), ...AUTOSTART_BLOCK, ...lines.slice(end + 1)].join(eol);
4480
+ } else if (startup.trim() === "") {
4481
+ text7 = block + eol;
4482
+ } else {
4483
+ text7 = block + eol + eol + startup;
4484
+ }
4485
+ return { text: text7, changed: text7 !== startup };
4486
+ }
4487
+ function readExtState(ini, section, key) {
4488
+ let inSection = false;
4489
+ for (const line of ini.split(/\r?\n/)) {
4490
+ const header = /^\s*\[(.*)\]\s*$/.exec(line);
4491
+ if (header) {
4492
+ inSection = header[1] === section;
4493
+ } else if (inSection) {
4494
+ const eq = line.indexOf("=");
4495
+ if (eq !== -1 && line.slice(0, eq).trim() === key) return line.slice(eq + 1).trim();
4496
+ }
4497
+ }
4498
+ return void 0;
4499
+ }
4500
+ function autostartCheck(startup, extstate, reaperRunning) {
4501
+ const label = "Start with REAPER";
4502
+ if (startup === null || !startup.includes(AUTOSTART_MARKER)) {
4503
+ return {
4504
+ label,
4505
+ status: "warn",
4506
+ detail: "Not in REAPER's Scripts/__startup.lua: run mcp_bridge.lua by hand in each REAPER session",
4507
+ fix: "reaper-mcp setup"
4508
+ };
4509
+ }
4510
+ const saved = reaperRunning ? " (as REAPER last saved it)" : "";
4511
+ if (extstate !== null && readExtState(extstate, "MCPBridge", "cfg_autostart") === "0") {
4512
+ return {
4513
+ label,
4514
+ status: "info",
4515
+ detail: `Off in the bridge window${saved}: run mcp_bridge.lua by hand in each REAPER session`,
4516
+ fix: "turn it back on in the bridge window: Settings \u2192 Start with REAPER"
4517
+ };
4518
+ }
4519
+ return { label, status: "ok", detail: `On \xB7 REAPER's startup script runs the bridge at launch${saved}` };
4520
+ }
4456
4521
  var MCP_TOOL_NAMES = [
4457
4522
  // project
4458
4523
  "get_project_info",
@@ -9215,15 +9280,15 @@ async function setup() {
9215
9280
  } else {
9216
9281
  console.log(` Not found: ${join12(wwwSrc, BRIDGE_UI_FILE)} (build bridge-ui first)`);
9217
9282
  }
9283
+ installBridgeAutostart(scriptsDir);
9218
9284
  const webPort = await enableWebInterface();
9219
9285
  await registerSnapshotActions();
9220
9286
  console.log("\nSetup complete!\n");
9221
9287
  console.log("Next steps:");
9222
- console.log(" 1. Open REAPER");
9223
- console.log(" 2. Actions > Show action list > Load ReaScript");
9224
- console.log(` 3. Select: ${join12(scriptsDir, "mcp_bridge.lua")}`);
9225
- console.log(" 4. Run the script (it will keep running in background via defer loop)");
9226
- console.log(" 5. Add reaper-mcp to your Claude Code config (see: reaper-mcp doctor)");
9288
+ console.log(" 1. Start REAPER: the bridge starts with it. If REAPER is already open, restart it,");
9289
+ console.log(" or run the bridge once by hand: Actions > Show action list > Load ReaScript,");
9290
+ console.log(` select ${join12(scriptsDir, "mcp_bridge.lua")} and click Run.`);
9291
+ console.log(" 2. Add reaper-mcp to your Claude Code config (see: reaper-mcp doctor)");
9227
9292
  if (webPort) {
9228
9293
  console.log(`
9229
9294
  The bridge opens its status window on start: http://localhost:${webPort}/${BRIDGE_UI_FILE}`);
@@ -9275,6 +9340,14 @@ async function enableWebInterface() {
9275
9340
  console.log(` Enabled on port ${result.port} (override with REAPER_WEB_PORT)`);
9276
9341
  return result.port;
9277
9342
  }
9343
+ function installBridgeAutostart(scriptsDir) {
9344
+ console.log("\nStarting the bridge with REAPER...");
9345
+ const path = join12(scriptsDir, "__startup.lua");
9346
+ const { text: text7, changed } = ensureBridgeAutostart(existsSync7(path) ? readFileSync5(path, "utf-8") : "");
9347
+ if (changed) writeFileSync5(path, text7, "utf-8");
9348
+ console.log(changed ? " Added to Scripts/__startup.lua (REAPER runs it at launch)" : " Already in Scripts/__startup.lua");
9349
+ console.log(" Turn it off in the bridge window: Settings > Start with REAPER.");
9350
+ }
9278
9351
  async function registerSnapshotActions() {
9279
9352
  console.log("\nRegistering snapshot actions (quick save, next, previous)...");
9280
9353
  const kbPath = join12(getReaperResourcePath(), "reaper-kb.ini");
@@ -9316,7 +9389,7 @@ async function init() {
9316
9389
  console.log("\nIf you haven't yet, install the bridge:");
9317
9390
  }
9318
9391
  console.log(" reaper-mcp setup # Lua bridge + JSFX \u2192 REAPER");
9319
- console.log("then load mcp_bridge.lua in REAPER.");
9392
+ console.log("then start (or restart) REAPER: the bridge starts with it.");
9320
9393
  if (!findCloneRoot(__dirname2)) console.log("\nWant it to remember plugins and your corrections? Connect LoreKit (free): https://lorekit.io. /learn-plugin will walk you through it.");
9321
9394
  console.log('\nTry: /mixer "Please gain stage my tracks" \xB7 /critique "Roast my mix"');
9322
9395
  }
@@ -9400,6 +9473,12 @@ async function doctor() {
9400
9473
  core2.push(
9401
9474
  bridgeRunning ? { label: "Lua bridge", status: "ok", detail: "Connected" } : { label: "Lua bridge", status: "fail", detail: "Not detected", fix: "reaper-mcp setup, then run mcp_bridge.lua in REAPER" }
9402
9475
  );
9476
+ const readIfExists = (path) => existsSync7(path) ? readFileSync5(path, "utf-8") : null;
9477
+ core2.push(autostartCheck(
9478
+ readIfExists(join12(getReaperScriptsPath(), "__startup.lua")),
9479
+ readIfExists(join12(getReaperResourcePath(), "reaper-extstate.ini")),
9480
+ await isReaperRunning()
9481
+ ));
9403
9482
  const globalClaudeDir = join12(homedir8(), ".claude");
9404
9483
  const localSkills = existsSync7(join12(process.cwd(), ".claude", "skills", "mixer", "SKILL.md"));
9405
9484
  const globalSkills = existsSync7(join12(globalClaudeDir, "skills", "mixer", "SKILL.md"));
@@ -9651,11 +9730,11 @@ Usage:
9651
9730
  Quick Start (from npm):
9652
9731
  npm install -g @mthines/reaper-mcp
9653
9732
  reaper-mcp setup && reaper-mcp init # bridge into REAPER, tools + skills into Claude Code
9654
- # then load mcp_bridge.lua in REAPER (Actions > Load ReaScript > Run)
9733
+ # then start (or restart) REAPER: the bridge starts with it
9655
9734
 
9656
9735
  Quick Start (from your clone):
9657
9736
  ./scripts/install.sh # build, link CLI, bridge, symlink skills + knowledge, configure
9658
- # then load mcp_bridge.lua in REAPER (Actions > Load ReaScript > Run)
9737
+ # then start (or restart) REAPER: the bridge starts with it
9659
9738
 
9660
9739
  Then in Claude Code:
9661
9740
  /mixer "Please gain stage my tracks" \xB7 /critique "Roast my mix"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mthines/reaper-mcp",
3
- "version": "0.73.0",
3
+ "version": "0.74.0",
4
4
  "type": "module",
5
5
  "description": "MCP server for controlling REAPER DAW — real-time mixing, FX control, and frequency analysis for AI agents",
6
6
  "license": "MIT",
@@ -4668,6 +4668,7 @@ end
4668
4668
 
4669
4669
  -- Settings written by the status page through REAPER's web interface (/_/SET/EXTSTATE...).
4670
4670
  -- cfg_paused is in-memory only (resets with REAPER); the others persist in reaper-extstate.ini.
4671
+ -- cfg_autostart is read at REAPER's launch by the startup block setup writes into Scripts/__startup.lua.
4671
4672
  local function cfg(key)
4672
4673
  return reaper.GetExtState(STATUS_SECTION, key) == "1"
4673
4674
  end
@@ -4692,7 +4693,7 @@ local _, script_path, _, script_cmd_id = reaper.get_action_context()
4692
4693
  local script_source = script_path and read_file(script_path)
4693
4694
  local HEALTH_INTERVAL = 10
4694
4695
  local last_health_check = -HEALTH_INTERVAL
4695
- local health = { sws = false, jsfx = true, outdated = false }
4696
+ local health = { sws = false, jsfx = true, outdated = false, autostart = false }
4696
4697
  local JSFX_FILES = { "mcp_analyzer.jsfx", "mcp_lufs_meter.jsfx", "mcp_correlation_meter.jsfx", "mcp_crest_factor.jsfx", "mcp_midi_emitter.jsfx" }
4697
4698
 
4698
4699
  local function check_health(now)
@@ -4710,8 +4711,13 @@ local function check_health(now)
4710
4711
  missingJsfx = #missing > 0 and missing or nil,
4711
4712
  -- The installed script changed under us (setup ran): this running copy is stale until restarted
4712
4713
  outdated = script_source ~= nil and installed ~= nil and installed ~= script_source,
4714
+ -- REAPER's startup script holds the block `reaper-mcp setup` writes (AUTOSTART_BLOCK in cli.ts), which
4715
+ -- starts the bridge with REAPER unless the page's cfg_autostart is "0"
4716
+ autostart = ((read_file(reaper.GetResourcePath() .. "/Scripts/__startup.lua") or "")
4717
+ :find("reaper-mcp: start the bridge with REAPER", 1, true)) ~= nil,
4713
4718
  }
4714
- if next_health.sws ~= health.sws or next_health.jsfx ~= health.jsfx or next_health.outdated ~= health.outdated then
4719
+ if next_health.sws ~= health.sws or next_health.jsfx ~= health.jsfx or next_health.outdated ~= health.outdated
4720
+ or next_health.autostart ~= health.autostart then
4715
4721
  status_dirty = true
4716
4722
  end
4717
4723
  health = next_health
@@ -5294,7 +5300,11 @@ local function publish_status(now, force)
5294
5300
  deferMs = defer_n > 0 and math.floor(defer_sum / defer_n * 100000 + 0.5) / 100 or 0,
5295
5301
  recent = status.recent,
5296
5302
  sessions = session_list(),
5297
- settings = { paused = cfg("cfg_paused"), readonly = cfg("cfg_readonly"), openOnStart = open_on_start(), dev = dev_mode() },
5303
+ settings = {
5304
+ paused = cfg("cfg_paused"), readonly = cfg("cfg_readonly"), openOnStart = open_on_start(), dev = dev_mode(),
5305
+ -- Start with REAPER: on unless turned off ("0"); read by the startup block, not by this script
5306
+ autostart = reaper.GetExtState(STATUS_SECTION, "cfg_autostart") ~= "0",
5307
+ },
5298
5308
  health = health,
5299
5309
  web = web_watch.status,
5300
5310
  control = control_status(),