@mthines/reaper-mcp 0.98.0 → 0.99.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/main.js CHANGED
@@ -7,7 +7,13 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
7
7
 
8
8
  // apps/reaper-mcp-server/src/server.ts
9
9
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
10
- import { SpanKind as SpanKind4, SpanStatusCode as SpanStatusCode3 } from "@opentelemetry/api";
10
+
11
+ // apps/reaper-mcp-server/src/bridge.ts
12
+ import { randomUUID as randomUUID2 } from "node:crypto";
13
+ import { appendFile, readFile, writeFile, readdir, unlink, mkdir, stat } from "node:fs/promises";
14
+ import { join as join3 } from "node:path";
15
+ import { homedir as homedir3, platform } from "node:os";
16
+ import { ProxyTracerProvider, SpanKind as SpanKind2, SpanStatusCode } from "@opentelemetry/api";
11
17
 
12
18
  // apps/reaper-mcp-server/src/telemetry.ts
13
19
  import { trace, metrics, SpanKind } from "@opentelemetry/api";
@@ -779,13 +785,6 @@ function registerBridgeGauges(isBridgeUp) {
779
785
  });
780
786
  }
781
787
 
782
- // apps/reaper-mcp-server/src/bridge.ts
783
- import { randomUUID as randomUUID2 } from "node:crypto";
784
- import { appendFile, readFile, writeFile, readdir, unlink, mkdir, stat } from "node:fs/promises";
785
- import { join as join3 } from "node:path";
786
- import { homedir as homedir3, platform } from "node:os";
787
- import { ProxyTracerProvider, SpanKind as SpanKind2, SpanStatusCode } from "@opentelemetry/api";
788
-
789
788
  // apps/reaper-mcp-server/src/session.ts
790
789
  var session = {
791
790
  id: process.env["CLAUDE_CODE_SESSION_ID"] || `pid-${process.pid}`,
@@ -840,7 +839,7 @@ function withPageLink(result, links) {
840
839
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
841
840
  var store2 = new AsyncLocalStorage2();
842
841
  function trackCallOutcome(fn) {
843
- const outcome = { logged: false, regression: false };
842
+ const outcome = { logged: false, regression: false, pageLogged: false };
844
843
  return store2.run(outcome, async () => ({ result: await fn(), outcome }));
845
844
  }
846
845
  function noteLoggedFailure(regression) {
@@ -849,6 +848,10 @@ function noteLoggedFailure(regression) {
849
848
  outcome.logged = true;
850
849
  if (regression) outcome.regression = true;
851
850
  }
851
+ function notePageLogged() {
852
+ const outcome = store2.getStore();
853
+ if (outcome) outcome.pageLogged = true;
854
+ }
852
855
 
853
856
  // apps/reaper-mcp-server/src/bridge.ts
854
857
  var POLL_INTERVAL_MS = 10;
@@ -1285,6 +1288,200 @@ function stopPollers() {
1285
1288
  }
1286
1289
  }
1287
1290
 
1291
+ // apps/reaper-mcp-server/src/tool-log.ts
1292
+ function logToolResult(command2, params, startedAt, r, error7) {
1293
+ if (error7) notePageLogged();
1294
+ void sendCommand("_log_result", {
1295
+ command: command2,
1296
+ ms: Date.now() - startedAt,
1297
+ ok: error7 ? 0 : 1,
1298
+ p: JSON.stringify(params).slice(0, 400),
1299
+ // Nested values travel as a JSON string: the bridge's fallback parser only reads flat params
1300
+ ...r ? { r: JSON.stringify(r) } : {},
1301
+ ...error7 ? { e: error7.slice(0, 300) } : {}
1302
+ }, 2e3).catch(() => {
1303
+ });
1304
+ }
1305
+ var num = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
1306
+ var BANDS = ["sub", "bass", "lowMid", "mid", "upperMid", "presence", "brilliance"];
1307
+ var MAX_SECTIONS = 48;
1308
+ var obj = (v) => v && typeof v === "object" ? v : {};
1309
+ function offlineSummary(name, result) {
1310
+ const loud = obj(result["loudness"]);
1311
+ const spec = obj(result["spectrum"]);
1312
+ const ref = result["reference"] ? obj(result["reference"]) : null;
1313
+ const sections3 = Array.isArray(loud["sections"]) ? loud["sections"] : [];
1314
+ const resonances = Array.isArray(spec["resonances"]) ? spec["resonances"] : [];
1315
+ const bandsOf = (b) => BANDS.map((k) => num(obj(b)[k]) ?? null);
1316
+ return {
1317
+ name,
1318
+ lufs: num(loud["integratedLufs"]),
1319
+ lra: num(loud["loudnessRangeLu"]),
1320
+ tp: num(loud["truePeakDbtp"]),
1321
+ peak: num(loud["samplePeakDbfs"]),
1322
+ crest: num(loud["crestFactorDb"]),
1323
+ dur: num(loud["durationSeconds"]),
1324
+ sections: sections3.slice(0, MAX_SECTIONS).flatMap((s) => {
1325
+ const [a, b, l] = [num(s["start"]), num(s["end"]), num(s["lufs"])];
1326
+ return a !== void 0 && b !== void 0 && l !== void 0 ? [[a, b, l]] : [];
1327
+ }),
1328
+ bands: bandsOf(spec["bandBalanceDb"]),
1329
+ res: resonances.slice(0, 5).flatMap((h) => num(h["hz"]) !== void 0 && num(h["excessDb"]) !== void 0 ? [[h["hz"], h["excessDb"]]] : []),
1330
+ sib: num(obj(spec["sibilance"])["spikeCount"]),
1331
+ ...ref ? { ref: { lufs: num(ref["referenceIntegratedLufs"]), delta: num(ref["loudnessDeltaLu"]), bands: bandsOf(ref["bandDeltaDb"]) } } : {}
1332
+ };
1333
+ }
1334
+ function alignmentSummary(data) {
1335
+ return {
1336
+ ref: data["referenceName"],
1337
+ name: data["trackName"],
1338
+ delayMs: num(data["delayMs"]),
1339
+ samples: num(data["delaySamples"]),
1340
+ corr: num(data["correlation"]),
1341
+ inv: data["polarityInverted"] === true ? 1 : 0,
1342
+ cur: num(data["currentPlayOffsetMs"]),
1343
+ offset: num(data["suggestedPlayOffsetMs"]),
1344
+ phase: num(data["suggestedPhase"]),
1345
+ ...data["warning"] ? { warn: 1 } : {}
1346
+ };
1347
+ }
1348
+ var VERIFY_CHECKS = ["null", "discontinuity", "pitch", "tone", "transients", "dropout"];
1349
+ function verifyRow(key, c) {
1350
+ const verdict = typeof c["verdict"] === "string" ? c["verdict"] : "unknown";
1351
+ const f = (v, digits, unit) => num(v) === void 0 ? "" : `${num(v).toFixed(digits)}${unit}`;
1352
+ switch (key) {
1353
+ case "null": {
1354
+ const parts = [
1355
+ num(c["delayMs"]) ? `delay ${f(c["delayMs"], 2, " ms")}` : "",
1356
+ num(c["gainDb"]) ? `gain ${f(c["gainDb"], 1, " dB")}` : "",
1357
+ c["polarityInverted"] === true ? "polarity inverted" : "",
1358
+ typeof c["reason"] === "string" ? c["reason"] : ""
1359
+ ].filter(Boolean);
1360
+ return [key, verdict, f(c["residualDb"], 1, " dB"), parts.join(", ")];
1361
+ }
1362
+ case "discontinuity": {
1363
+ const at = num(c["atSeconds"]);
1364
+ return [key, verdict, f(c["score"], 1, "\xD7"), at === void 0 ? "" : `at ${at.toFixed(2)} s${num(c["channel"]) !== void 0 ? `, channel ${num(c["channel"]) + 1}` : ""}`];
1365
+ }
1366
+ case "pitch":
1367
+ return [
1368
+ key,
1369
+ verdict,
1370
+ f(c["driftCents"], 0, " cents"),
1371
+ typeof c["reason"] === "string" ? c["reason"] : c["varispeed"] === true ? `plain speed change (expected ${f(c["expectedCents"], 0, " cents")})` : f(c["referenceHz"], 0, " Hz reference")
1372
+ ];
1373
+ case "tone":
1374
+ return [key, verdict, f(c["distanceDb"], 2, " dB"), typeof c["reason"] === "string" ? c["reason"] : ""];
1375
+ case "dropout":
1376
+ return [key, verdict, f(c["deepestDipDb"], 1, " dB"), typeof c["reason"] === "string" ? c["reason"] : "deepest dip under the original"];
1377
+ default:
1378
+ return [key, verdict, f(c["fluxLogRatio"], 2, ""), typeof c["reason"] === "string" ? c["reason"] : ""];
1379
+ }
1380
+ }
1381
+ function verifySummary(name, ref, result) {
1382
+ const checks = obj(result["checks"]);
1383
+ return {
1384
+ name,
1385
+ ...ref ? { ref } : {},
1386
+ verdict: result["verdict"],
1387
+ expect: result["expect"],
1388
+ checks: VERIFY_CHECKS.filter((k) => checks[k]).map((k) => verifyRow(k, obj(checks[k])))
1389
+ };
1390
+ }
1391
+ function aestheticsSummary(data) {
1392
+ return {
1393
+ name: data["trackName"],
1394
+ pq: num(data["productionQuality"]),
1395
+ pc: num(data["productionComplexity"]),
1396
+ ce: num(data["contentEnjoyment"]),
1397
+ cu: num(data["contentUsefulness"]),
1398
+ lufs: num(data["normalizedToLufs"]),
1399
+ dur: num(data["durationSeconds"])
1400
+ };
1401
+ }
1402
+ var nums = (v) => Array.isArray(v) ? v.map((x) => typeof x === "number" && Number.isFinite(x) ? x : -70) : [];
1403
+ var span3 = (v) => {
1404
+ const s = obj(v);
1405
+ const [a, b, l] = [num(s["start"]), num(s["end"]), num(s["lufs"] ?? s["maxLufs"])];
1406
+ return a !== void 0 && b !== void 0 ? [a, b, l ?? null] : null;
1407
+ };
1408
+ var MAX_CURVE_POINTS = 240;
1409
+ var MAX_MASKING_PAIRS = 10;
1410
+ function curveSummary(name, data) {
1411
+ const curve = obj(data["shortTerm"] ?? data["momentary"]);
1412
+ return {
1413
+ name,
1414
+ lufs: num(data["integratedLufs"]),
1415
+ tp: num(data["truePeakDbtp"]),
1416
+ lra: num(data["loudnessRangeLu"]),
1417
+ plr: num(data["plrDb"]),
1418
+ maxM: num(data["maxMomentaryLufs"]),
1419
+ target: num(data["targetLufs"]),
1420
+ overS: num(data["overTargetSeconds"]),
1421
+ start: num(data["startTime"]) ?? 0,
1422
+ step: num(curve["step"]),
1423
+ term: data["shortTerm"] ? "s" : "m",
1424
+ curve: nums(curve["lufs"]).slice(0, MAX_CURVE_POINTS),
1425
+ loud: span3(data["loudest"]),
1426
+ quiet: span3(data["quietest"]),
1427
+ over: (Array.isArray(data["overTarget"]) ? data["overTarget"] : []).slice(0, 20).flatMap((s) => {
1428
+ const t = span3(s);
1429
+ return t ? [t] : [];
1430
+ })
1431
+ };
1432
+ }
1433
+ function stereoBandsSummary(name, data) {
1434
+ const bands = Array.isArray(data["bands"]) ? data["bands"] : [];
1435
+ return {
1436
+ name,
1437
+ bands: bands.map((b) => [b["band"], num(b["correlation"]) ?? null, num(b["worst"]) ?? null, num(b["negativeShare"]) ?? null, num(b["sideToMidDb"]) ?? null]),
1438
+ flags: (Array.isArray(data["flags"]) ? data["flags"] : []).slice(0, 5).map(String),
1439
+ dur: num(data["durationSeconds"])
1440
+ };
1441
+ }
1442
+ function maskingSummary(result) {
1443
+ const pairs = Array.isArray(result["pairs"]) ? result["pairs"] : [];
1444
+ const conflicts = Array.isArray(result["conflicts"]) ? result["conflicts"] : [];
1445
+ return {
1446
+ tracks: Array.isArray(result["tracks"]) ? result["tracks"] : [],
1447
+ hz: nums(result["bandsHz"]),
1448
+ pairs: [...pairs].sort((x, y) => (num(y["overall"]) ?? 0) - (num(x["overall"]) ?? 0)).slice(0, MAX_MASKING_PAIRS).map((p) => [p["a"], p["b"], num(p["overall"]) ?? 0, nums(p["scores"])]),
1449
+ conflicts: conflicts.slice(0, 5).map((c) => [c["a"], c["b"], num(c["hz"]) ?? null, num(c["score"]) ?? null, c["suggestion"]])
1450
+ };
1451
+ }
1452
+ function stemsSummary(name, data) {
1453
+ const stems = Array.isArray(data["stems"]) ? data["stems"] : [];
1454
+ const inserted = obj(data["inserted"]);
1455
+ return {
1456
+ name,
1457
+ model: data["model"],
1458
+ device: data["device"],
1459
+ secs: num(data["seconds"]),
1460
+ proc: num(data["processingSeconds"]),
1461
+ stems: stems.map((s) => [s["stem"], num(s["lufs"]) ?? null, num(s["peakDbfs"]) ?? null]),
1462
+ ...Array.isArray(inserted["tracks"]) ? { inserted: inserted["tracks"].length, folder: inserted["folderName"], ...inserted["muted"] === true ? { muted: 1 } : {} } : {}
1463
+ };
1464
+ }
1465
+
1466
+ // apps/reaper-mcp-server/src/sidecar-hint.ts
1467
+ var SETUP_SIDECAR_COMMAND = "reaper-mcp setup-sidecar";
1468
+ var SETUP_SIDECAR_HINT = `Run in a terminal: ${SETUP_SIDECAR_COMMAND}`;
1469
+ function sidecarNotInstalledMessage(command2 = SETUP_SIDECAR_COMMAND) {
1470
+ return `Audio understanding sidecar not installed. This tool needs the optional Python sidecar; REAPER and the bridge are fine. Tell the user to run this in a terminal, then retry: ${command2}. Do not retry before then or try to install it yourself; tools that don't analyse audio keep working.`;
1471
+ }
1472
+ var SIDECAR_NOT_INSTALLED_MSG = sidecarNotInstalledMessage();
1473
+ var MISSING_LOG_PREFIX = "Python sidecar not installed. Run in a terminal:";
1474
+ function sidecarMissingLog(text8) {
1475
+ const command2 = text8.match(/reaper-mcp setup-sidecar(?: --[\w-]+)*/)?.[0] ?? SETUP_SIDECAR_COMMAND;
1476
+ return `${MISSING_LOG_PREFIX} ${command2}`;
1477
+ }
1478
+ function isSidecarMissing(text8) {
1479
+ return /sidecar not installed|needs the Python sidecar|(?:audiobox-aesthetics|Stem separation|chord model|FluidSynth native library)[^.]*(?:is )?not installed/i.test(text8);
1480
+ }
1481
+
1482
+ // apps/reaper-mcp-server/src/server.ts
1483
+ import { SpanKind as SpanKind4, SpanStatusCode as SpanStatusCode3 } from "@opentelemetry/api";
1484
+
1288
1485
  // apps/reaper-mcp-server/src/notices.ts
1289
1486
  var NOTICE_HEADING = "Note from reaper-mcp for the user (pass this on; it is not part of the result):";
1290
1487
  var pending = [];
@@ -5524,10 +5721,6 @@ Removed partial venv so the next setup-sidecar run starts clean.`);
5524
5721
  }
5525
5722
  }
5526
5723
 
5527
- // apps/reaper-mcp-server/src/sidecar-hint.ts
5528
- var SETUP_SIDECAR_COMMAND = "reaper-mcp setup-sidecar";
5529
- var SETUP_SIDECAR_HINT = `Run in a terminal: ${SETUP_SIDECAR_COMMAND}`;
5530
-
5531
5724
  // apps/reaper-mcp-server/src/sidecar.ts
5532
5725
  var VENV_BIN2 = platform3() === "win32" ? "Scripts" : "bin";
5533
5726
  var VENV_PYTHON_NAME2 = platform3() === "win32" ? "python.exe" : "python";
@@ -5861,184 +6054,9 @@ function getSidecarClient() {
5861
6054
  return _singleton;
5862
6055
  }
5863
6056
 
5864
- // apps/reaper-mcp-server/src/tool-log.ts
5865
- function logToolResult(command2, params, startedAt, r, error7) {
5866
- void sendCommand("_log_result", {
5867
- command: command2,
5868
- ms: Date.now() - startedAt,
5869
- ok: error7 ? 0 : 1,
5870
- p: JSON.stringify(params).slice(0, 400),
5871
- // Nested values travel as a JSON string: the bridge's fallback parser only reads flat params
5872
- ...r ? { r: JSON.stringify(r) } : {},
5873
- ...error7 ? { e: error7.slice(0, 300) } : {}
5874
- }, 2e3).catch(() => {
5875
- });
5876
- }
5877
- var num = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
5878
- var BANDS = ["sub", "bass", "lowMid", "mid", "upperMid", "presence", "brilliance"];
5879
- var MAX_SECTIONS = 48;
5880
- var obj = (v) => v && typeof v === "object" ? v : {};
5881
- function offlineSummary(name, result) {
5882
- const loud = obj(result["loudness"]);
5883
- const spec = obj(result["spectrum"]);
5884
- const ref = result["reference"] ? obj(result["reference"]) : null;
5885
- const sections3 = Array.isArray(loud["sections"]) ? loud["sections"] : [];
5886
- const resonances = Array.isArray(spec["resonances"]) ? spec["resonances"] : [];
5887
- const bandsOf = (b) => BANDS.map((k) => num(obj(b)[k]) ?? null);
5888
- return {
5889
- name,
5890
- lufs: num(loud["integratedLufs"]),
5891
- lra: num(loud["loudnessRangeLu"]),
5892
- tp: num(loud["truePeakDbtp"]),
5893
- peak: num(loud["samplePeakDbfs"]),
5894
- crest: num(loud["crestFactorDb"]),
5895
- dur: num(loud["durationSeconds"]),
5896
- sections: sections3.slice(0, MAX_SECTIONS).flatMap((s) => {
5897
- const [a, b, l] = [num(s["start"]), num(s["end"]), num(s["lufs"])];
5898
- return a !== void 0 && b !== void 0 && l !== void 0 ? [[a, b, l]] : [];
5899
- }),
5900
- bands: bandsOf(spec["bandBalanceDb"]),
5901
- res: resonances.slice(0, 5).flatMap((h) => num(h["hz"]) !== void 0 && num(h["excessDb"]) !== void 0 ? [[h["hz"], h["excessDb"]]] : []),
5902
- sib: num(obj(spec["sibilance"])["spikeCount"]),
5903
- ...ref ? { ref: { lufs: num(ref["referenceIntegratedLufs"]), delta: num(ref["loudnessDeltaLu"]), bands: bandsOf(ref["bandDeltaDb"]) } } : {}
5904
- };
5905
- }
5906
- function alignmentSummary(data) {
5907
- return {
5908
- ref: data["referenceName"],
5909
- name: data["trackName"],
5910
- delayMs: num(data["delayMs"]),
5911
- samples: num(data["delaySamples"]),
5912
- corr: num(data["correlation"]),
5913
- inv: data["polarityInverted"] === true ? 1 : 0,
5914
- cur: num(data["currentPlayOffsetMs"]),
5915
- offset: num(data["suggestedPlayOffsetMs"]),
5916
- phase: num(data["suggestedPhase"]),
5917
- ...data["warning"] ? { warn: 1 } : {}
5918
- };
5919
- }
5920
- var VERIFY_CHECKS = ["null", "discontinuity", "pitch", "tone", "transients", "dropout"];
5921
- function verifyRow(key, c) {
5922
- const verdict = typeof c["verdict"] === "string" ? c["verdict"] : "unknown";
5923
- const f = (v, digits, unit) => num(v) === void 0 ? "" : `${num(v).toFixed(digits)}${unit}`;
5924
- switch (key) {
5925
- case "null": {
5926
- const parts = [
5927
- num(c["delayMs"]) ? `delay ${f(c["delayMs"], 2, " ms")}` : "",
5928
- num(c["gainDb"]) ? `gain ${f(c["gainDb"], 1, " dB")}` : "",
5929
- c["polarityInverted"] === true ? "polarity inverted" : "",
5930
- typeof c["reason"] === "string" ? c["reason"] : ""
5931
- ].filter(Boolean);
5932
- return [key, verdict, f(c["residualDb"], 1, " dB"), parts.join(", ")];
5933
- }
5934
- case "discontinuity": {
5935
- const at = num(c["atSeconds"]);
5936
- return [key, verdict, f(c["score"], 1, "\xD7"), at === void 0 ? "" : `at ${at.toFixed(2)} s${num(c["channel"]) !== void 0 ? `, channel ${num(c["channel"]) + 1}` : ""}`];
5937
- }
5938
- case "pitch":
5939
- return [
5940
- key,
5941
- verdict,
5942
- f(c["driftCents"], 0, " cents"),
5943
- typeof c["reason"] === "string" ? c["reason"] : c["varispeed"] === true ? `plain speed change (expected ${f(c["expectedCents"], 0, " cents")})` : f(c["referenceHz"], 0, " Hz reference")
5944
- ];
5945
- case "tone":
5946
- return [key, verdict, f(c["distanceDb"], 2, " dB"), typeof c["reason"] === "string" ? c["reason"] : ""];
5947
- case "dropout":
5948
- return [key, verdict, f(c["deepestDipDb"], 1, " dB"), typeof c["reason"] === "string" ? c["reason"] : "deepest dip under the original"];
5949
- default:
5950
- return [key, verdict, f(c["fluxLogRatio"], 2, ""), typeof c["reason"] === "string" ? c["reason"] : ""];
5951
- }
5952
- }
5953
- function verifySummary(name, ref, result) {
5954
- const checks = obj(result["checks"]);
5955
- return {
5956
- name,
5957
- ...ref ? { ref } : {},
5958
- verdict: result["verdict"],
5959
- expect: result["expect"],
5960
- checks: VERIFY_CHECKS.filter((k) => checks[k]).map((k) => verifyRow(k, obj(checks[k])))
5961
- };
5962
- }
5963
- function aestheticsSummary(data) {
5964
- return {
5965
- name: data["trackName"],
5966
- pq: num(data["productionQuality"]),
5967
- pc: num(data["productionComplexity"]),
5968
- ce: num(data["contentEnjoyment"]),
5969
- cu: num(data["contentUsefulness"]),
5970
- lufs: num(data["normalizedToLufs"]),
5971
- dur: num(data["durationSeconds"])
5972
- };
5973
- }
5974
- var nums = (v) => Array.isArray(v) ? v.map((x) => typeof x === "number" && Number.isFinite(x) ? x : -70) : [];
5975
- var span3 = (v) => {
5976
- const s = obj(v);
5977
- const [a, b, l] = [num(s["start"]), num(s["end"]), num(s["lufs"] ?? s["maxLufs"])];
5978
- return a !== void 0 && b !== void 0 ? [a, b, l ?? null] : null;
5979
- };
5980
- var MAX_CURVE_POINTS = 240;
5981
- var MAX_MASKING_PAIRS = 10;
5982
- function curveSummary(name, data) {
5983
- const curve = obj(data["shortTerm"] ?? data["momentary"]);
5984
- return {
5985
- name,
5986
- lufs: num(data["integratedLufs"]),
5987
- tp: num(data["truePeakDbtp"]),
5988
- lra: num(data["loudnessRangeLu"]),
5989
- plr: num(data["plrDb"]),
5990
- maxM: num(data["maxMomentaryLufs"]),
5991
- target: num(data["targetLufs"]),
5992
- overS: num(data["overTargetSeconds"]),
5993
- start: num(data["startTime"]) ?? 0,
5994
- step: num(curve["step"]),
5995
- term: data["shortTerm"] ? "s" : "m",
5996
- curve: nums(curve["lufs"]).slice(0, MAX_CURVE_POINTS),
5997
- loud: span3(data["loudest"]),
5998
- quiet: span3(data["quietest"]),
5999
- over: (Array.isArray(data["overTarget"]) ? data["overTarget"] : []).slice(0, 20).flatMap((s) => {
6000
- const t = span3(s);
6001
- return t ? [t] : [];
6002
- })
6003
- };
6004
- }
6005
- function stereoBandsSummary(name, data) {
6006
- const bands = Array.isArray(data["bands"]) ? data["bands"] : [];
6007
- return {
6008
- name,
6009
- bands: bands.map((b) => [b["band"], num(b["correlation"]) ?? null, num(b["worst"]) ?? null, num(b["negativeShare"]) ?? null, num(b["sideToMidDb"]) ?? null]),
6010
- flags: (Array.isArray(data["flags"]) ? data["flags"] : []).slice(0, 5).map(String),
6011
- dur: num(data["durationSeconds"])
6012
- };
6013
- }
6014
- function maskingSummary(result) {
6015
- const pairs = Array.isArray(result["pairs"]) ? result["pairs"] : [];
6016
- const conflicts = Array.isArray(result["conflicts"]) ? result["conflicts"] : [];
6017
- return {
6018
- tracks: Array.isArray(result["tracks"]) ? result["tracks"] : [],
6019
- hz: nums(result["bandsHz"]),
6020
- pairs: [...pairs].sort((x, y) => (num(y["overall"]) ?? 0) - (num(x["overall"]) ?? 0)).slice(0, MAX_MASKING_PAIRS).map((p) => [p["a"], p["b"], num(p["overall"]) ?? 0, nums(p["scores"])]),
6021
- conflicts: conflicts.slice(0, 5).map((c) => [c["a"], c["b"], num(c["hz"]) ?? null, num(c["score"]) ?? null, c["suggestion"]])
6022
- };
6023
- }
6024
- function stemsSummary(name, data) {
6025
- const stems = Array.isArray(data["stems"]) ? data["stems"] : [];
6026
- const inserted = obj(data["inserted"]);
6027
- return {
6028
- name,
6029
- model: data["model"],
6030
- device: data["device"],
6031
- secs: num(data["seconds"]),
6032
- proc: num(data["processingSeconds"]),
6033
- stems: stems.map((s) => [s["stem"], num(s["lufs"]) ?? null, num(s["peakDbfs"]) ?? null]),
6034
- ...Array.isArray(inserted["tracks"]) ? { inserted: inserted["tracks"].length, folder: inserted["folderName"], ...inserted["muted"] === true ? { muted: 1 } : {} } : {}
6035
- };
6036
- }
6037
-
6038
6057
  // apps/reaper-mcp-server/src/tools/aesthetics.ts
6039
6058
  var DEFAULT_SCORING_LUFS = -18;
6040
6059
  var DEFAULT_CLIP_SECONDS = 30;
6041
- var SIDECAR_NOT_INSTALLED_MSG = `Audio understanding sidecar not installed. ${SETUP_SIDECAR_HINT}`;
6042
6060
  function registerAestheticsTools(server) {
6043
6061
  server.tool(
6044
6062
  "analyze_track_aesthetics",
@@ -6124,7 +6142,6 @@ function registerAestheticsTools(server) {
6124
6142
  // apps/reaper-mcp-server/src/tools/offline.ts
6125
6143
  import { z as z28 } from "zod/v4";
6126
6144
  import { basename } from "node:path";
6127
- var SIDECAR_NOT_INSTALLED_MSG2 = `Audio understanding sidecar not installed. ${SETUP_SIDECAR_HINT}`;
6128
6145
  var MAX_OFFLINE_SECONDS = 900;
6129
6146
  var DEFAULT_OFFLINE_SECONDS = 30;
6130
6147
  var DEFAULT_ALIGNMENT_SECONDS = 10;
@@ -6175,7 +6192,7 @@ function registerOfflineTools(server) {
6175
6192
  const { trackIndex: trackIndex5, startTime, endTime, durationSeconds, sectionSeconds, referencePath, referenceStartTime, referenceEndTime } = args;
6176
6193
  const startedAt = Date.now();
6177
6194
  const sidecar = getSidecarClient();
6178
- if (!sidecar.isAvailable()) return error(SIDECAR_NOT_INSTALLED_MSG2);
6195
+ if (!sidecar.isAvailable()) return error(SIDECAR_NOT_INSTALLED_MSG);
6179
6196
  const start = startTime ?? 0;
6180
6197
  const end = endTime ?? start + (durationSeconds ?? DEFAULT_OFFLINE_SECONDS);
6181
6198
  if (end <= start) return error("endTime must be greater than startTime");
@@ -6224,7 +6241,7 @@ function registerOfflineTools(server) {
6224
6241
  const { path, startTime, endTime, sectionSeconds, referencePath, referenceStartTime, referenceEndTime } = args;
6225
6242
  const startedAt = Date.now();
6226
6243
  const sidecar = getSidecarClient();
6227
- if (!sidecar.isAvailable()) return error(SIDECAR_NOT_INSTALLED_MSG2);
6244
+ if (!sidecar.isAvailable()) return error(SIDECAR_NOT_INSTALLED_MSG);
6228
6245
  if (startTime != null && endTime != null && endTime <= startTime) {
6229
6246
  return error("endTime must be greater than startTime");
6230
6247
  }
@@ -6260,7 +6277,7 @@ function registerOfflineTools(server) {
6260
6277
  const { referenceTrack, trackIndex: trackIndex5, startTime, durationSeconds, maxLagMs } = args;
6261
6278
  const startedAt = Date.now();
6262
6279
  const sidecar = getSidecarClient();
6263
- if (!sidecar.isAvailable()) return error(SIDECAR_NOT_INSTALLED_MSG2);
6280
+ if (!sidecar.isAvailable()) return error(SIDECAR_NOT_INSTALLED_MSG);
6264
6281
  if (referenceTrack === trackIndex5) return error("referenceTrack and trackIndex must differ");
6265
6282
  const end = startTime + (durationSeconds ?? DEFAULT_ALIGNMENT_SECONDS);
6266
6283
  const rendered = [];
@@ -6327,7 +6344,7 @@ function registerOfflineTools(server) {
6327
6344
  return error(message);
6328
6345
  };
6329
6346
  const sidecar = getSidecarClient();
6330
- if (!sidecar.isAvailable()) return error(SIDECAR_NOT_INSTALLED_MSG2);
6347
+ if (!sidecar.isAvailable()) return error(SIDECAR_NOT_INSTALLED_MSG);
6331
6348
  if (referenceTrack == null === (referencePath == null)) {
6332
6349
  return refuse("Give exactly one of referenceTrack (a track with the audio from before the edit) or referencePath (a file)");
6333
6350
  }
@@ -6369,7 +6386,6 @@ function registerOfflineTools(server) {
6369
6386
 
6370
6387
  // apps/reaper-mcp-server/src/tools/transients.ts
6371
6388
  import { z as z29 } from "zod/v4";
6372
- var SIDECAR_NOT_INSTALLED_MSG3 = `Audio understanding sidecar not installed. ${SETUP_SIDECAR_HINT}`;
6373
6389
  var DEFAULT_TRACK_SECONDS = 60;
6374
6390
  var DEFAULT_LIMIT = 200;
6375
6391
  var MAX_AUTOMATION_POINTS = 2e4;
@@ -6439,7 +6455,7 @@ var sourceSchema = {
6439
6455
  };
6440
6456
  async function detect(args) {
6441
6457
  const sidecar = getSidecarClient();
6442
- if (!sidecar.isAvailable()) return SIDECAR_NOT_INSTALLED_MSG3;
6458
+ if (!sidecar.isAvailable()) return SIDECAR_NOT_INSTALLED_MSG;
6443
6459
  const { trackIndex: trackIndex5, path } = args;
6444
6460
  if (trackIndex5 == null === (path == null)) return "Give exactly one of trackIndex or path";
6445
6461
  const options = {
@@ -6663,7 +6679,6 @@ import { z as z30 } from "zod/v4";
6663
6679
  import { homedir as homedir6 } from "node:os";
6664
6680
  import { basename as basename2, extname, join as join7 } from "node:path";
6665
6681
  import { trace as trace5 } from "@opentelemetry/api";
6666
- var SIDECAR_NOT_INSTALLED_MSG4 = `Audio understanding sidecar not installed. ${SETUP_SIDECAR_HINT}`;
6667
6682
  var DEFAULT_TRACK_SECONDS2 = 180;
6668
6683
  var SEPARATION_TRACK_SECONDS = 60;
6669
6684
  var MAX_MASKING_SECONDS = 60;
@@ -6735,7 +6750,7 @@ function registerMixcheckTools(server) {
6735
6750
  async (args) => {
6736
6751
  const startedAt = Date.now();
6737
6752
  const sidecar = getSidecarClient();
6738
- if (!sidecar.isAvailable()) return error3(SIDECAR_NOT_INSTALLED_MSG4);
6753
+ if (!sidecar.isAvailable()) return error3(SIDECAR_NOT_INSTALLED_MSG);
6739
6754
  let src;
6740
6755
  try {
6741
6756
  src = await resolveSource(args, MAX_OFFLINE_SECONDS);
@@ -6776,7 +6791,7 @@ function registerMixcheckTools(server) {
6776
6791
  async (args) => {
6777
6792
  const startedAt = Date.now();
6778
6793
  const sidecar = getSidecarClient();
6779
- if (!sidecar.isAvailable()) return error3(SIDECAR_NOT_INSTALLED_MSG4);
6794
+ if (!sidecar.isAvailable()) return error3(SIDECAR_NOT_INSTALLED_MSG);
6780
6795
  let src;
6781
6796
  try {
6782
6797
  src = await resolveSource(args, MAX_OFFLINE_SECONDS);
@@ -6815,7 +6830,7 @@ function registerMixcheckTools(server) {
6815
6830
  const { tracks: tracks2, startTime, durationSeconds } = args;
6816
6831
  const startedAt = Date.now();
6817
6832
  const sidecar = getSidecarClient();
6818
- if (!sidecar.isAvailable()) return error3(SIDECAR_NOT_INSTALLED_MSG4);
6833
+ if (!sidecar.isAvailable()) return error3(SIDECAR_NOT_INSTALLED_MSG);
6819
6834
  if (new Set(tracks2).size !== tracks2.length) return error3("tracks must not repeat a track");
6820
6835
  const end = startTime + (durationSeconds ?? DEFAULT_MASKING_SECONDS);
6821
6836
  const rendered = [];
@@ -6867,7 +6882,7 @@ function registerMixcheckTools(server) {
6867
6882
  async (args) => {
6868
6883
  const startedAt = Date.now();
6869
6884
  const sidecar = getSidecarClient();
6870
- if (!sidecar.isAvailable()) return error3(SIDECAR_NOT_INSTALLED_MSG4);
6885
+ if (!sidecar.isAvailable()) return error3(SIDECAR_NOT_INSTALLED_MSG);
6871
6886
  if (args.model === "htdemucs" && args.stems?.some((s) => s === "guitar" || s === "piano")) {
6872
6887
  return error3("htdemucs has no guitar or piano stem: use model htdemucs_6s");
6873
6888
  }
@@ -6941,7 +6956,6 @@ function registerMixcheckTools(server) {
6941
6956
  // apps/reaper-mcp-server/src/tools/mixing.ts
6942
6957
  import { z as z31 } from "zod/v4";
6943
6958
  import { trace as trace6 } from "@opentelemetry/api";
6944
- var SIDECAR_NOT_INSTALLED_MSG5 = `Audio understanding sidecar not installed. ${SETUP_SIDECAR_HINT}`;
6945
6959
  var MAX_QUANTIZE_SECONDS = 900;
6946
6960
  var error4 = (text8) => ({ content: [{ type: "text", text: `Error: ${text8}` }], isError: true });
6947
6961
  var ok = (data) => ({ content: [{ type: "text", text: JSON.stringify(data, null, 2) }] });
@@ -7155,7 +7169,7 @@ function registerMixingTools(server) {
7155
7169
  },
7156
7170
  async ({ trackIndex: ti, itemIndex: itemIndex2, grid, strength, window, swing, sensitivity, minGapMs, minStrength }) => {
7157
7171
  const sidecar = getSidecarClient();
7158
- if (!sidecar.isAvailable()) return error4(SIDECAR_NOT_INSTALLED_MSG5);
7172
+ if (!sidecar.isAvailable()) return error4(SIDECAR_NOT_INSTALLED_MSG);
7159
7173
  const props = await sendCommand("get_media_item_properties", { trackIndex: ti, itemIndex: itemIndex2 });
7160
7174
  if (!props.success) return error4(props.error ?? "item not found");
7161
7175
  const item = props.data;
@@ -7288,7 +7302,6 @@ function buildPairs(guideHits, doubleHits, g, opts) {
7288
7302
  }
7289
7303
 
7290
7304
  // apps/reaper-mcp-server/src/tools/align.ts
7291
- var SIDECAR_NOT_INSTALLED_MSG6 = `Audio understanding sidecar not installed. ${SETUP_SIDECAR_HINT}`;
7292
7305
  var MAX_ALIGN_SECONDS = 900;
7293
7306
  var error5 = (text8) => ({ content: [{ type: "text", text: `Error: ${text8}` }], isError: true });
7294
7307
  var ok2 = (data) => ({ content: [{ type: "text", text: JSON.stringify(data, null, 2) }] });
@@ -7345,7 +7358,7 @@ function registerAlignTools(server) {
7345
7358
  minStrength: z32.coerce.number().min(0).max(1).optional().default(0.2).describe("Ignore hits weaker than this (0..1 of the loudest)")
7346
7359
  },
7347
7360
  async ({ guide, doubles, strength, maxShiftMs, protectConsonants, consonantMs, dryRun, sensitivity, minGapMs, minStrength }) => {
7348
- if (!getSidecarClient().isAvailable()) return error5(SIDECAR_NOT_INSTALLED_MSG6);
7361
+ if (!getSidecarClient().isAvailable()) return error5(SIDECAR_NOT_INSTALLED_MSG);
7349
7362
  const det = { sensitivity, minGapMs, minStrength };
7350
7363
  const guideRead = await readItem(guide, "The guide");
7351
7364
  if ("error" in guideRead) return error5(guideRead.error);
@@ -8156,7 +8169,7 @@ function registerCompositionTools(server) {
8156
8169
  } else {
8157
8170
  const sidecar = getSidecarClient();
8158
8171
  if (!sidecar.isAvailable()) {
8159
- return fail4(`Audio key detection needs the Python sidecar. ${SETUP_SIDECAR_HINT}`);
8172
+ return fail4(SIDECAR_NOT_INSTALLED_MSG);
8160
8173
  }
8161
8174
  if (path != null) {
8162
8175
  const c = await sidecar.chroma({ path, ...start > 0 ? { startTime: start } : {}, ...args.endTime != null ? { endTime: args.endTime } : {} });
@@ -8252,7 +8265,7 @@ function registerCompositionTools(server) {
8252
8265
  let engine = "template";
8253
8266
  let modelMissing = false;
8254
8267
  const sidecar = getSidecarClient();
8255
- const needSidecar = () => fail4(`Audio chord detection needs the Python sidecar. ${SETUP_SIDECAR_HINT}`);
8268
+ const needSidecar = () => fail4(SIDECAR_NOT_INSTALLED_MSG);
8256
8269
  const useModel = async () => {
8257
8270
  if (engineArg === "template") return false;
8258
8271
  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" }));
@@ -8572,7 +8585,7 @@ function registerVoiceSketchTools(server) {
8572
8585
  if (args.endTime !== void 0 && args.endTime - (args.startTime ?? 0) > 120) return fail4("Select at most 120 seconds per call");
8573
8586
  if (args.pitchMin >= args.pitchMax) return fail4("pitchMin must be below pitchMax");
8574
8587
  const sidecar = getSidecarClient();
8575
- if (!sidecar.isAvailable()) return fail4("Audio sidecar not installed. Run reaper-mcp setup-sidecar --without-aesthetics");
8588
+ if (!sidecar.isAvailable()) return fail4(sidecarNotInstalledMessage(`${SETUP_SIDECAR_COMMAND} --without-aesthetics`));
8576
8589
  try {
8577
8590
  const { outputPath, soundfontPath, arrange, bars, key: keyOverride, offset, limit, ...params } = args;
8578
8591
  const result = await sidecar.transcribeVoiceSketch(params);
@@ -9683,7 +9696,7 @@ function registerPluginBuildTools(server) {
9683
9696
  var MAX_STATUS_MESSAGE = 256;
9684
9697
  var TOOL_ERROR_MESSAGE = "reaper.tool.error.message";
9685
9698
  function toolErrorCause(text8) {
9686
- if (/sidecar not installed|needs the Python sidecar/i.test(text8)) return "sidecar_not_installed";
9699
+ if (isSidecarMissing(text8)) return "sidecar_not_installed";
9687
9700
  const type = classifyBridgeError(text8.replace(/^Error:\s*/, ""));
9688
9701
  return type === "bridge_not_running" || type === "bridge_outdated" ? type : void 0;
9689
9702
  }
@@ -9726,6 +9739,9 @@ function instrumentToolHandlers(server) {
9726
9739
  span.setAttribute(TOOL_ERROR_MESSAGE, message);
9727
9740
  const cause = toolErrorCause(errorText);
9728
9741
  if (cause) span.setAttribute("reaper.tool.error.cause", cause);
9742
+ if (cause === "sidecar_not_installed" && !outcome.pageLogged) {
9743
+ logToolResult(toolName, {}, startMs, null, sidecarMissingLog(errorText));
9744
+ }
9729
9745
  if (regression) span.setStatus({ code: SpanStatusCode3.ERROR, message });
9730
9746
  if (!outcome.logged) {
9731
9747
  emitLog(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mthines/reaper-mcp",
3
- "version": "0.98.0",
3
+ "version": "0.99.1",
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",