@mthines/reaper-mcp 0.72.0 → 0.73.0-beta.83.1
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/README.md +46 -42
- package/bridge-ui/mcp_bridge.html +18 -18
- package/main.js +219 -38
- package/package.json +1 -1
- package/reaper/mcp_bridge.lua +13 -3
- package/sidecar/server.py +1 -1
package/main.js
CHANGED
|
@@ -136,6 +136,10 @@ var ALLOWED_SPAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
|
136
136
|
"reaper.bridge.handler_ms",
|
|
137
137
|
"reaper.bridge.pickup_ms",
|
|
138
138
|
"reaper.bridge.poll_attempts",
|
|
139
|
+
// Whether the bridge answered at startup and, when not, which setup step is missing
|
|
140
|
+
// (a fixed set: connected, stale, never_started, not_installed, no_reaper — never a path)
|
|
141
|
+
"reaper.bridge.connected",
|
|
142
|
+
"reaper.bridge.state",
|
|
139
143
|
// detect_key / detect_chords: where they read from and how sure they were, never the key or chords
|
|
140
144
|
"reaper.key.source",
|
|
141
145
|
"reaper.key.confidence",
|
|
@@ -628,15 +632,89 @@ async function ensureBridgeDir() {
|
|
|
628
632
|
await mkdir(dir, { recursive: true });
|
|
629
633
|
return dir;
|
|
630
634
|
}
|
|
635
|
+
var BRIDGE_NOT_RUNNING_PREFIX = "Bridge not running:";
|
|
631
636
|
function classifyBridgeError(error7) {
|
|
632
637
|
if (error7?.startsWith("Timeout:")) return "timeout";
|
|
638
|
+
if (error7?.startsWith(BRIDGE_NOT_RUNNING_PREFIX)) return "bridge_not_running";
|
|
633
639
|
if (error7?.startsWith("Handler error:")) return "handler_crash";
|
|
634
640
|
if (error7?.startsWith("Unknown command type")) return "unknown_command";
|
|
635
641
|
if (error7?.startsWith("Internal error:")) return "internal_error";
|
|
636
642
|
return "command_failed";
|
|
637
643
|
}
|
|
638
644
|
function isSystemError(type) {
|
|
639
|
-
return type !== "command_failed";
|
|
645
|
+
return type !== "command_failed" && type !== "bridge_not_running";
|
|
646
|
+
}
|
|
647
|
+
var HEARTBEAT_FRESH_MS = 5e3;
|
|
648
|
+
var BRIDGE_DOWN_AFTER_MS = 6e4;
|
|
649
|
+
async function heartbeatAgeMs() {
|
|
650
|
+
try {
|
|
651
|
+
const info = await stat(join3(getBridgeDir(), "heartbeat.json"));
|
|
652
|
+
return Math.max(0, Date.now() - info.mtimeMs);
|
|
653
|
+
} catch {
|
|
654
|
+
return void 0;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
async function exists(path) {
|
|
658
|
+
try {
|
|
659
|
+
await stat(path);
|
|
660
|
+
return true;
|
|
661
|
+
} catch {
|
|
662
|
+
return false;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
async function getBridgeState() {
|
|
666
|
+
const age = await heartbeatAgeMs();
|
|
667
|
+
if (age !== void 0) return { state: age < HEARTBEAT_FRESH_MS ? "connected" : "stale", heartbeatAgeMs: age };
|
|
668
|
+
const resource = getReaperResourcePath();
|
|
669
|
+
if (await exists(join3(resource, "Scripts", "mcp_bridge.lua"))) return { state: "never_started" };
|
|
670
|
+
if (await exists(join3(resource, "reaper.ini"))) return { state: "not_installed" };
|
|
671
|
+
return { state: "no_reaper" };
|
|
672
|
+
}
|
|
673
|
+
var START_BRIDGE = `Start the bridge: in REAPER, open Actions \u2192 Show action list, select "Script: mcp_bridge.lua" and click Run (the first time, use Load ReaScript\u2026 and pick mcp_bridge.lua from REAPER's Scripts folder). It runs until REAPER closes.`;
|
|
674
|
+
function formatAge(ms) {
|
|
675
|
+
const s = Math.round(ms / 1e3);
|
|
676
|
+
if (s < 120) return `${s} s`;
|
|
677
|
+
const min = Math.round(s / 60);
|
|
678
|
+
if (min < 120) return `${min} min`;
|
|
679
|
+
return `${Math.round(min / 60)} h`;
|
|
680
|
+
}
|
|
681
|
+
function bridgeDownMessage(status, resourcePath = getReaperResourcePath()) {
|
|
682
|
+
switch (status.state) {
|
|
683
|
+
case "connected":
|
|
684
|
+
return "The REAPER bridge is running.";
|
|
685
|
+
case "stale":
|
|
686
|
+
return `${BRIDGE_NOT_RUNNING_PREFIX} REAPER has not answered for ${formatAge(status.heartbeatAgeMs ?? 0)}. If REAPER is open and rendering or showing a dialog, finish or close it and try again: running mcp_bridge.lua while the bridge is only busy stops it. If REAPER is closed, start it and try again. If REAPER is open and idle, the bridge stopped. ${START_BRIDGE} Then try again.`;
|
|
687
|
+
case "never_started":
|
|
688
|
+
return `${BRIDGE_NOT_RUNNING_PREFIX} the bridge script is installed but has never run in this REAPER. ${START_BRIDGE} Then try again.`;
|
|
689
|
+
case "not_installed":
|
|
690
|
+
return `${BRIDGE_NOT_RUNNING_PREFIX} the bridge script is not installed in REAPER (no Scripts/mcp_bridge.lua in ${resourcePath}). Run in a terminal: reaper-mcp setup. ${START_BRIDGE}`;
|
|
691
|
+
case "no_reaper":
|
|
692
|
+
return `${BRIDGE_NOT_RUNNING_PREFIX} no REAPER settings in ${resourcePath}: REAPER is not installed there or has never been started. Start REAPER once (or set REAPER_RESOURCE_PATH to the folder REAPER shows under Options \u2192 Show REAPER resource path in explorer/finder), then run in a terminal: reaper-mcp setup. ${START_BRIDGE}`;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
var inFlight = 0;
|
|
696
|
+
var lastAnswerAt = 0;
|
|
697
|
+
async function bridgeDown() {
|
|
698
|
+
if (inFlight > 0) return void 0;
|
|
699
|
+
if (Date.now() - lastAnswerAt < BRIDGE_DOWN_AFTER_MS) return void 0;
|
|
700
|
+
const status = await getBridgeState();
|
|
701
|
+
if (status.state === "connected") return void 0;
|
|
702
|
+
if (status.state === "stale" && (status.heartbeatAgeMs ?? 0) < BRIDGE_DOWN_AFTER_MS) return void 0;
|
|
703
|
+
if (status.state === "stale" && await otherCommandPending()) return void 0;
|
|
704
|
+
return status;
|
|
705
|
+
}
|
|
706
|
+
var PENDING_COMMAND_MAX_AGE_MS = 15 * 6e4;
|
|
707
|
+
async function otherCommandPending() {
|
|
708
|
+
const dir = getBridgeDir();
|
|
709
|
+
try {
|
|
710
|
+
for (const file of await readdir(dir)) {
|
|
711
|
+
if (!file.startsWith("command_") || !file.endsWith(".json")) continue;
|
|
712
|
+
const info = await stat(join3(dir, file)).catch(() => null);
|
|
713
|
+
if (info && Date.now() - info.mtimeMs < PENDING_COMMAND_MAX_AGE_MS) return true;
|
|
714
|
+
}
|
|
715
|
+
} catch {
|
|
716
|
+
}
|
|
717
|
+
return false;
|
|
640
718
|
}
|
|
641
719
|
var NOOP_TRACER = new ProxyTracerProvider().getTracer("noop");
|
|
642
720
|
var UNTRACED_COMMANDS = /* @__PURE__ */ new Set(["_bridge_diagnostics", "_session", "_log_result"]);
|
|
@@ -670,8 +748,26 @@ async function sendCommand(type, params = {}, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
|
670
748
|
span.end();
|
|
671
749
|
if (!untraced) getCommandDurationHistogram().record((Date.now() - startMs) / 1e3, attrs);
|
|
672
750
|
};
|
|
751
|
+
let counted = false;
|
|
673
752
|
try {
|
|
674
753
|
if (profiling) t["spanSetup"] = now() - t0;
|
|
754
|
+
const down = await bridgeDown();
|
|
755
|
+
if (down) {
|
|
756
|
+
span.setAttribute("reaper.bridge.state", down.state);
|
|
757
|
+
const message = bridgeDownMessage(down);
|
|
758
|
+
if (!untraced) {
|
|
759
|
+
emitLog(
|
|
760
|
+
"warn",
|
|
761
|
+
`Bridge command ${type} not sent: the bridge is not running (${down.state})`,
|
|
762
|
+
{ "rpc.method": type, "error.type": "bridge_not_running", "reaper.bridge.state": down.state },
|
|
763
|
+
{ eventName: "reaper.bridge.command.not_sent" }
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
finish("bridge_not_running");
|
|
767
|
+
return { id: randomUUID2(), success: false, error: message, timestamp: Date.now() };
|
|
768
|
+
}
|
|
769
|
+
inFlight++;
|
|
770
|
+
counted = true;
|
|
675
771
|
const tDir = now();
|
|
676
772
|
const dir = await ensureBridgeDir();
|
|
677
773
|
if (profiling) t["ensureDir"] = now() - tDir;
|
|
@@ -704,6 +800,7 @@ async function sendCommand(type, params = {}, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
|
704
800
|
const tRead = now();
|
|
705
801
|
const data = await readFile(responsePath, "utf-8");
|
|
706
802
|
const response = JSON.parse(data);
|
|
803
|
+
lastAnswerAt = Date.now();
|
|
707
804
|
if (profiling) t["readParse"] = now() - tRead;
|
|
708
805
|
if (profiling) t["pollWait"] = now() - tPoll - (t["readParse"] ?? 0);
|
|
709
806
|
const tCleanup = now();
|
|
@@ -793,19 +890,15 @@ async function sendCommand(type, params = {}, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
|
793
890
|
});
|
|
794
891
|
finish(errorType);
|
|
795
892
|
throw err;
|
|
893
|
+
} finally {
|
|
894
|
+
if (counted) inFlight--;
|
|
796
895
|
}
|
|
797
896
|
}
|
|
798
897
|
);
|
|
799
898
|
}
|
|
800
899
|
async function isBridgeRunning() {
|
|
801
|
-
const
|
|
802
|
-
|
|
803
|
-
try {
|
|
804
|
-
const info = await stat(heartbeatPath);
|
|
805
|
-
return Date.now() - info.mtimeMs < 5e3;
|
|
806
|
-
} catch {
|
|
807
|
-
return false;
|
|
808
|
-
}
|
|
900
|
+
const age = await heartbeatAgeMs();
|
|
901
|
+
return age !== void 0 && age < HEARTBEAT_FRESH_MS;
|
|
809
902
|
}
|
|
810
903
|
async function cleanupStaleFiles(maxAgeMs = 3e4) {
|
|
811
904
|
const dir = getBridgeDir();
|
|
@@ -4360,6 +4453,71 @@ function ensureSnapshotActions(kb) {
|
|
|
4360
4453
|
const body = kb === "" || kb.endsWith("\n") ? kb : kb + eol;
|
|
4361
4454
|
return { kb: body + lines.join(eol) + eol, added };
|
|
4362
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
|
+
}
|
|
4363
4521
|
var MCP_TOOL_NAMES = [
|
|
4364
4522
|
// project
|
|
4365
4523
|
"get_project_info",
|
|
@@ -4659,7 +4817,7 @@ async function checkPython(pythonBin) {
|
|
|
4659
4817
|
} catch {
|
|
4660
4818
|
const notFound = `Python interpreter not found: ${pythonBin}
|
|
4661
4819
|
Install Python 3.10+ from https://python.org or set the PYTHON_BIN environment variable.
|
|
4662
|
-
Example: PYTHON_BIN=/usr/local/bin/python3.11
|
|
4820
|
+
Example: PYTHON_BIN=/usr/local/bin/python3.11 reaper-mcp setup-sidecar`;
|
|
4663
4821
|
throw new Error(notFound);
|
|
4664
4822
|
}
|
|
4665
4823
|
const version = parsePythonVersion(stdout);
|
|
@@ -5016,6 +5174,10 @@ Removed partial venv so the next setup-sidecar run starts clean.`);
|
|
|
5016
5174
|
}
|
|
5017
5175
|
}
|
|
5018
5176
|
|
|
5177
|
+
// apps/reaper-mcp-server/src/sidecar-hint.ts
|
|
5178
|
+
var SETUP_SIDECAR_COMMAND = "reaper-mcp setup-sidecar";
|
|
5179
|
+
var SETUP_SIDECAR_HINT = `Run in a terminal: ${SETUP_SIDECAR_COMMAND}`;
|
|
5180
|
+
|
|
5019
5181
|
// apps/reaper-mcp-server/src/sidecar.ts
|
|
5020
5182
|
var VENV_BIN2 = platform3() === "win32" ? "Scripts" : "bin";
|
|
5021
5183
|
var VENV_PYTHON_NAME2 = platform3() === "win32" ? "python.exe" : "python";
|
|
@@ -5150,7 +5312,7 @@ var SidecarClientImpl = class {
|
|
|
5150
5312
|
async send(method, params, timeoutMs) {
|
|
5151
5313
|
if (!this.isAvailable()) {
|
|
5152
5314
|
throw new Error(
|
|
5153
|
-
|
|
5315
|
+
`Audio understanding sidecar not installed. ${SETUP_SIDECAR_HINT}`
|
|
5154
5316
|
);
|
|
5155
5317
|
}
|
|
5156
5318
|
await this.ensureRunning();
|
|
@@ -5306,13 +5468,13 @@ var SidecarClientImpl = class {
|
|
|
5306
5468
|
}
|
|
5307
5469
|
}).catch((err) => {
|
|
5308
5470
|
for (const [id, { reject }] of this.pending.entries()) {
|
|
5309
|
-
reject(new Error(`Sidecar restart failed: ${err.message}.
|
|
5471
|
+
reject(new Error(`Sidecar restart failed: ${err.message}. ${SETUP_SIDECAR_HINT}`));
|
|
5310
5472
|
this.pending.delete(id);
|
|
5311
5473
|
}
|
|
5312
5474
|
});
|
|
5313
5475
|
} else {
|
|
5314
5476
|
for (const [id, { reject }] of this.pending.entries()) {
|
|
5315
|
-
reject(new Error(
|
|
5477
|
+
reject(new Error(`Python sidecar unavailable after restart attempt. ${SETUP_SIDECAR_HINT}`));
|
|
5316
5478
|
this.pending.delete(id);
|
|
5317
5479
|
}
|
|
5318
5480
|
}
|
|
@@ -5496,11 +5658,11 @@ function stemsSummary(name, data) {
|
|
|
5496
5658
|
// apps/reaper-mcp-server/src/tools/aesthetics.ts
|
|
5497
5659
|
var DEFAULT_SCORING_LUFS = -18;
|
|
5498
5660
|
var DEFAULT_CLIP_SECONDS = 30;
|
|
5499
|
-
var SIDECAR_NOT_INSTALLED_MSG =
|
|
5661
|
+
var SIDECAR_NOT_INSTALLED_MSG = `Audio understanding sidecar not installed. ${SETUP_SIDECAR_HINT}`;
|
|
5500
5662
|
function registerAestheticsTools(server) {
|
|
5501
5663
|
server.tool(
|
|
5502
5664
|
"analyze_track_aesthetics",
|
|
5503
|
-
"Analyze the perceptual aesthetic quality of a track's audio using Meta's Audiobox Aesthetics model (CC-BY 4.0). Bounces the track to a temp WAV file (post-FX, post-fader) and runs 4-axis perceptual quality scoring: Production Quality (PQ), Production Complexity (PC), Content Enjoyment (CE), Content Usefulness (CU). Returns scores 0-10. The clip is normalized to normalizeLufs (default -18 LUFS) before scoring, so level differences between versions do not bias the scores (CE rises with level; PQ barely moves). PQ (and partly CU) judge mix changes; PC and CE mostly follow the arrangement, so only compare the same time range. Measured noise: re-rendering the same 30 s clip moves PQ by ~0.05, a 10 s clip by ~0.4; treat smaller differences as no change. Requires the Python sidecar (run:
|
|
5665
|
+
"Analyze the perceptual aesthetic quality of a track's audio using Meta's Audiobox Aesthetics model (CC-BY 4.0). Bounces the track to a temp WAV file (post-FX, post-fader) and runs 4-axis perceptual quality scoring: Production Quality (PQ), Production Complexity (PC), Content Enjoyment (CE), Content Usefulness (CU). Returns scores 0-10. The clip is normalized to normalizeLufs (default -18 LUFS) before scoring, so level differences between versions do not bias the scores (CE rises with level; PQ barely moves). PQ (and partly CU) judge mix changes; PC and CE mostly follow the arrangement, so only compare the same time range. Measured noise: re-rendering the same 30 s clip moves PQ by ~0.05, a 10 s clip by ~0.4; treat smaller differences as no change. Requires the Python sidecar (run in a terminal: reaper-mcp setup-sidecar).",
|
|
5504
5666
|
{
|
|
5505
5667
|
trackIndex: z27.coerce.number().int().min(-1).describe("Zero-based track index (-1 = master: the whole mix)"),
|
|
5506
5668
|
startTime: z27.coerce.number().min(0).optional().describe("Start time in seconds (default: 0 or use REAPER time selection)"),
|
|
@@ -5582,7 +5744,7 @@ function registerAestheticsTools(server) {
|
|
|
5582
5744
|
// apps/reaper-mcp-server/src/tools/offline.ts
|
|
5583
5745
|
import { z as z28 } from "zod/v4";
|
|
5584
5746
|
import { basename } from "node:path";
|
|
5585
|
-
var SIDECAR_NOT_INSTALLED_MSG2 =
|
|
5747
|
+
var SIDECAR_NOT_INSTALLED_MSG2 = `Audio understanding sidecar not installed. ${SETUP_SIDECAR_HINT}`;
|
|
5586
5748
|
var MAX_OFFLINE_SECONDS = 900;
|
|
5587
5749
|
var DEFAULT_OFFLINE_SECONDS = 30;
|
|
5588
5750
|
var DEFAULT_ALIGNMENT_SECONDS = 10;
|
|
@@ -5828,7 +5990,7 @@ function registerOfflineTools(server) {
|
|
|
5828
5990
|
// apps/reaper-mcp-server/src/tools/transients.ts
|
|
5829
5991
|
import { z as z29 } from "zod/v4";
|
|
5830
5992
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
5831
|
-
var SIDECAR_NOT_INSTALLED_MSG3 =
|
|
5993
|
+
var SIDECAR_NOT_INSTALLED_MSG3 = `Audio understanding sidecar not installed. ${SETUP_SIDECAR_HINT}`;
|
|
5832
5994
|
var DEFAULT_TRACK_SECONDS = 60;
|
|
5833
5995
|
var DEFAULT_LIMIT = 200;
|
|
5834
5996
|
var MAX_AUTOMATION_POINTS = 2e4;
|
|
@@ -6124,7 +6286,7 @@ import { z as z30 } from "zod/v4";
|
|
|
6124
6286
|
import { homedir as homedir6 } from "node:os";
|
|
6125
6287
|
import { basename as basename2, extname, join as join7 } from "node:path";
|
|
6126
6288
|
import { trace as trace5 } from "@opentelemetry/api";
|
|
6127
|
-
var SIDECAR_NOT_INSTALLED_MSG4 =
|
|
6289
|
+
var SIDECAR_NOT_INSTALLED_MSG4 = `Audio understanding sidecar not installed. ${SETUP_SIDECAR_HINT}`;
|
|
6128
6290
|
var DEFAULT_TRACK_SECONDS2 = 180;
|
|
6129
6291
|
var SEPARATION_TRACK_SECONDS = 60;
|
|
6130
6292
|
var MAX_MASKING_SECONDS = 60;
|
|
@@ -6402,7 +6564,7 @@ function registerMixcheckTools(server) {
|
|
|
6402
6564
|
// apps/reaper-mcp-server/src/tools/mixing.ts
|
|
6403
6565
|
import { z as z31 } from "zod/v4";
|
|
6404
6566
|
import { trace as trace6 } from "@opentelemetry/api";
|
|
6405
|
-
var SIDECAR_NOT_INSTALLED_MSG5 =
|
|
6567
|
+
var SIDECAR_NOT_INSTALLED_MSG5 = `Audio understanding sidecar not installed. ${SETUP_SIDECAR_HINT}`;
|
|
6406
6568
|
var MAX_QUANTIZE_SECONDS = 900;
|
|
6407
6569
|
var error4 = (text7) => ({ content: [{ type: "text", text: `Error: ${text7}` }], isError: true });
|
|
6408
6570
|
var ok = (data) => ({ content: [{ type: "text", text: JSON.stringify(data, null, 2) }] });
|
|
@@ -6749,7 +6911,7 @@ function buildPairs(guideHits, doubleHits, g, opts) {
|
|
|
6749
6911
|
}
|
|
6750
6912
|
|
|
6751
6913
|
// apps/reaper-mcp-server/src/tools/align.ts
|
|
6752
|
-
var SIDECAR_NOT_INSTALLED_MSG6 =
|
|
6914
|
+
var SIDECAR_NOT_INSTALLED_MSG6 = `Audio understanding sidecar not installed. ${SETUP_SIDECAR_HINT}`;
|
|
6753
6915
|
var MAX_ALIGN_SECONDS = 900;
|
|
6754
6916
|
var error5 = (text7) => ({ content: [{ type: "text", text: `Error: ${text7}` }], isError: true });
|
|
6755
6917
|
var ok2 = (data) => ({ content: [{ type: "text", text: JSON.stringify(data, null, 2) }] });
|
|
@@ -7619,7 +7781,7 @@ function registerCompositionTools(server) {
|
|
|
7619
7781
|
} else {
|
|
7620
7782
|
const sidecar = getSidecarClient();
|
|
7621
7783
|
if (!sidecar.isAvailable()) {
|
|
7622
|
-
return fail4(
|
|
7784
|
+
return fail4(`Audio key detection needs the Python sidecar. ${SETUP_SIDECAR_HINT}`);
|
|
7623
7785
|
}
|
|
7624
7786
|
if (path != null) {
|
|
7625
7787
|
const c = await sidecar.chroma({ path, ...start > 0 ? { startTime: start } : {}, ...args.endTime != null ? { endTime: args.endTime } : {} });
|
|
@@ -7716,7 +7878,7 @@ function registerCompositionTools(server) {
|
|
|
7716
7878
|
let engine = "template";
|
|
7717
7879
|
let modelMissing = false;
|
|
7718
7880
|
const sidecar = getSidecarClient();
|
|
7719
|
-
const needSidecar = () => fail4(
|
|
7881
|
+
const needSidecar = () => fail4(`Audio chord detection needs the Python sidecar. ${SETUP_SIDECAR_HINT}`);
|
|
7720
7882
|
const useModel = async () => {
|
|
7721
7883
|
if (engineArg === "template") return false;
|
|
7722
7884
|
const status = await Promise.resolve().then(() => sidecar.chordsStatus()).catch(() => ({ installed: false, message: "The chord model is not installed. Run: reaper-mcp setup-sidecar --with-chords" }));
|
|
@@ -9120,13 +9282,13 @@ async function setup() {
|
|
|
9120
9282
|
}
|
|
9121
9283
|
const webPort = await enableWebInterface();
|
|
9122
9284
|
await registerSnapshotActions();
|
|
9285
|
+
installBridgeAutostart(scriptsDir);
|
|
9123
9286
|
console.log("\nSetup complete!\n");
|
|
9124
9287
|
console.log("Next steps:");
|
|
9125
|
-
console.log(" 1.
|
|
9126
|
-
console.log("
|
|
9127
|
-
console.log(`
|
|
9128
|
-
console.log("
|
|
9129
|
-
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)");
|
|
9130
9292
|
if (webPort) {
|
|
9131
9293
|
console.log(`
|
|
9132
9294
|
The bridge opens its status window on start: http://localhost:${webPort}/${BRIDGE_UI_FILE}`);
|
|
@@ -9178,6 +9340,14 @@ async function enableWebInterface() {
|
|
|
9178
9340
|
console.log(` Enabled on port ${result.port} (override with REAPER_WEB_PORT)`);
|
|
9179
9341
|
return result.port;
|
|
9180
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
|
+
}
|
|
9181
9351
|
async function registerSnapshotActions() {
|
|
9182
9352
|
console.log("\nRegistering snapshot actions (quick save, next, previous)...");
|
|
9183
9353
|
const kbPath = join12(getReaperResourcePath(), "reaper-kb.ini");
|
|
@@ -9303,6 +9473,12 @@ async function doctor() {
|
|
|
9303
9473
|
core2.push(
|
|
9304
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" }
|
|
9305
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
|
+
));
|
|
9306
9482
|
const globalClaudeDir = join12(homedir8(), ".claude");
|
|
9307
9483
|
const localSkills = existsSync7(join12(process.cwd(), ".claude", "skills", "mixer", "SKILL.md"));
|
|
9308
9484
|
const globalSkills = existsSync7(join12(globalClaudeDir, "skills", "mixer", "SKILL.md"));
|
|
@@ -9426,24 +9602,27 @@ async function serve() {
|
|
|
9426
9602
|
startupSpan.setAttribute("reaper.bridge.stale_files_cleaned", cleaned);
|
|
9427
9603
|
log(`Cleaned up ${cleaned} stale bridge files`);
|
|
9428
9604
|
}
|
|
9429
|
-
const
|
|
9430
|
-
const
|
|
9605
|
+
const bridge = await tracer.startActiveSpan("check bridge connection", { kind: SpanKind5.INTERNAL }, async (bridgeSpan) => {
|
|
9606
|
+
const status = await getBridgeState();
|
|
9607
|
+
const running = status.state === "connected";
|
|
9431
9608
|
bridgeSpan.setAttribute("reaper.bridge.connected", running);
|
|
9609
|
+
bridgeSpan.setAttribute("reaper.bridge.state", status.state);
|
|
9432
9610
|
if (!running) {
|
|
9433
|
-
emitLog("warn", "Lua bridge not detected at startup \u2014 commands
|
|
9434
|
-
"reaper.bridge.connected": false
|
|
9611
|
+
emitLog("warn", "Lua bridge not detected at startup \u2014 commands are refused until it is started", {
|
|
9612
|
+
"reaper.bridge.connected": false,
|
|
9613
|
+
"reaper.bridge.state": status.state
|
|
9435
9614
|
});
|
|
9436
|
-
log(
|
|
9437
|
-
log(
|
|
9438
|
-
log('Run "reaper-mcp setup" for installation instructions.');
|
|
9615
|
+
log(`WARNING: Lua bridge does not appear to be running in REAPER (${status.state}).`);
|
|
9616
|
+
log(bridgeDownMessage(status));
|
|
9439
9617
|
} else {
|
|
9440
9618
|
bridgeSpan.setStatus({ code: SpanStatusCode4.OK });
|
|
9441
9619
|
log("Lua bridge detected \u2014 connected to REAPER");
|
|
9442
9620
|
}
|
|
9443
9621
|
bridgeSpan.end();
|
|
9444
|
-
return
|
|
9622
|
+
return status;
|
|
9445
9623
|
});
|
|
9446
|
-
startupSpan.setAttribute("reaper.bridge.connected",
|
|
9624
|
+
startupSpan.setAttribute("reaper.bridge.connected", bridge.state === "connected");
|
|
9625
|
+
startupSpan.setAttribute("reaper.bridge.state", bridge.state);
|
|
9447
9626
|
const server = createServer();
|
|
9448
9627
|
for (const ext of await loadExtensions(server)) {
|
|
9449
9628
|
if (ext.status === "loaded") log(`Extension ${ext.name} ${ext.version ?? ""} loaded (${ext.tools.length} tools)`);
|
|
@@ -9514,8 +9693,10 @@ switch (command) {
|
|
|
9514
9693
|
break;
|
|
9515
9694
|
case "status": {
|
|
9516
9695
|
(async () => {
|
|
9517
|
-
const
|
|
9518
|
-
|
|
9696
|
+
const status = await getBridgeState();
|
|
9697
|
+
const running = status.state === "connected";
|
|
9698
|
+
console.log(`Bridge status: ${running ? "CONNECTED" : `NOT DETECTED (${status.state})`}`);
|
|
9699
|
+
if (!running) console.log(bridgeDownMessage(status));
|
|
9519
9700
|
process.exit(running ? 0 : 1);
|
|
9520
9701
|
})();
|
|
9521
9702
|
break;
|
package/package.json
CHANGED
package/reaper/mcp_bridge.lua
CHANGED
|
@@ -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
|
|
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 = {
|
|
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(),
|
package/sidecar/server.py
CHANGED
|
@@ -56,7 +56,7 @@ def _ensure_predictor() -> None:
|
|
|
56
56
|
except ImportError as exc:
|
|
57
57
|
_predictor_error = (
|
|
58
58
|
f"audiobox-aesthetics not installed: {exc}. "
|
|
59
|
-
|
|
59
|
+
"Run in a terminal: reaper-mcp setup-sidecar"
|
|
60
60
|
)
|
|
61
61
|
except Exception as exc: # noqa: BLE001
|
|
62
62
|
_predictor_error = f"Failed to initialize predictor: {exc}"
|