@mthines/reaper-mcp 0.82.0 → 0.82.1-beta.113.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.
@@ -80,7 +80,7 @@ Cut before you add. If a control could be a sensible fixed value, make it one. P
80
80
  example in `examples/` (`mutate-verb.jsfx` random and granular plus reverb, `tape-sat.jsfx`
81
81
  nonlinear plus tilt EQ, `width-bass-mono.jsfx` linear stereo plus meter, `multiband-compressor.jsfx` frequency graph with
82
82
  crossover handles in Hz, per-band gain reduction and a transfer curve via `ui_freqgraph`,
83
- `ui_fhandle`, `ui_grmeter`, `ui_transfer`; `ui_keyboard` shows MIDI notes) and read it. Each has its
83
+ `ui_fhandle`, `ui_fthresh`, `ui_grmeter`, `ui_transfer`; `ui_fband` gives bands one level each and `ui_keyboard` shows and plays MIDI notes; no shipped example uses those two, see `reference/toolkit.md`) and read it. Each has its
84
84
  suggested presets beside it (`<name>.presets.json`): the shape `write_jsfx` takes.
85
85
 
86
86
  ### Step 2: Write the source
@@ -94,6 +94,22 @@ example and change what the spec changes. The shape is always:
94
94
  `ui_mem`; compute coefficients in `update()`, called from `@init`, `@slider` and
95
95
  `@block: ui_changed() ? update();`.
96
96
  - `@gfx` draws the core row(s), then `ui_section("Advanced") ? ( ... )` for the rest.
97
+ - **Bands on a frequency graph are always directly editable, unless the user says otherwise.** A plugin
98
+ with bands (a crossover, a multiband or split, an EQ) draws `ui_freqgraph` with a `ui_fhandle` per
99
+ band edge, and then **a per-band control on the graph itself**: `ui_fthresh(thr, ratio, gain, n)` for
100
+ dynamics (hover a band and drag up or down for its threshold, Shift-drag for its gain, wheel for its
101
+ ratio) or `ui_fband(first, n, fmt)` for one level per band (drag up or down, Shift = fine). Both
102
+ select the band on a click, and one `ui_bandknob(first, n, "Label", fmt)` per band parameter edits
103
+ the selected band. Never ship bands whose only controls are plain knobs: the multiband example is
104
+ the model.
105
+ - **A keyboard is for playing as well as showing, and it sits along the bottom.** `ui_keyboard(21, 108,
106
+ "Keys")` (the full range, or 36-96 for a small window; make the window wide enough, about 700 px for
107
+ 88 keys) as the **last** core row, below the knobs, short and full width like Vital's and Odin's. A
108
+ click or a drag across the keys plays. The keys fill the bottom of their cell, so the keyboard row must be the
109
+ last of the `ui_begin` core rows and the count must match the rows you draw (`ui_tall(2)` on the knob row
110
+ above it makes the keys a short strip right above the Advanced bar): read it in `@block` with `while (ui_kpoll()) ( ui_kv > 0 ?
111
+ <note on ui_kn, ui_kv> : <note off ui_kn> );` next to the MIDI-in loop (a synth turns them into
112
+ voices, a MIDI effect `midisend`s them). Notes from MIDI light the keys with `ui_kkey(note, vel)`.
97
113
  - Do not write the toolkit: `write_jsfx` inlines it.
98
114
  - Never assign `ui_adv_open` (or any `ui_` state) in plugin code: REAPER re-runs `@init` when
99
115
  playback starts, so the Advanced drawer would snap shut on Play (lint `ui-state-reset`).
@@ -1,5 +1,5 @@
1
1
  desc:Multiband Compressor
2
- // accent: orange
2
+ // accent: blue
3
3
  import mcp_ui.jsfx-inc
4
4
 
5
5
  // Three bands with Linkwitz-Riley 4th-order crossovers (the bands sum flat), one compressor per band.
@@ -44,17 +44,18 @@ Every widget is one block, label above, control, value below, sized the same acr
44
44
  | `ui_gshow(on)` / `ui_gfeed2(buf, n)` | before / after: with `ui_gshow(slider)` on, the graph also draws the input as a second, lighter line labelled Input / Output; feed it with `ui_gfeed2` only while shown (a second FFT costs). Put a `ui_toggle` for it in Advanced | a `<0,1,1{Off,On}>` slider |
45
45
  | `ui_fhandle(idx, "Label")` | a draggable band edge on the graph, bound to slider `idx` in Hz; drag, wheel, double-click for a value box, modifier-click resets; stays between its neighbours; automates like a knob | a Hz slider, e.g. `<40,800,1>`; call it after `ui_freqgraph`, in left-to-right order |
46
46
  | `ui_fthresh(thr_first, ratio_first, gain_first, n)` | a threshold line across each of `n` bands (the handles + 1) on the graph; hover a band and drag up/down to move its threshold, **Shift**-drag its gain, wheel = its ratio, click selects it | `n` threshold sliders from `thr_first` (dB, -60..0), `n` ratio sliders from `ratio_first`, `n` gain sliders from `gain_first`; call it after the handles |
47
+ | `ui_fband(first_idx, n, fmt)` | one level line per band on the graph, for bands with a single amount (an EQ's gain, a split's level): hover a band and drag up or down (the slider's full range across the graph height), **Shift**-drag for fine steps, wheel = a small step, click selects it, double-click types a value, modifier-click resets; `fmt` as for knobs (1 = dB) | `n` sliders from `first_idx`; call it after the handles; pair it with `ui_bandknob` |
47
48
  | `ui_bandknob(first_idx, n, "Label", fmt)` | a knob on the selected band's slider (`first_idx + ui_fsel`), labelled with the band (Low / Mid / High, else Band N) | `n` sliders from `first_idx`; counts as one widget |
48
49
  | `ui_grmeter(n, "Label")` | `n` (1-8) gain-reduction bars hanging from the top, amber from 6 dB, red from 12; a click selects the band | `ui_gr(k, db)` per band from `@block` (db 0 or more) |
49
50
  | `ui_transfer(thr_idx, ratio_idx, knee_db)` | a compressor transfer curve that follows the threshold and ratio sliders (the selected band's, `thr_idx + ui_fsel`, with a graph), with a live level dot | `ui_glevel(db)` from `@block` |
50
- | `ui_keyboard(lo, hi, "Label")` | piano keys `lo`..`hi` (MIDI notes), lit while held | `ui_kkey(note, vel)` on note on, `ui_kkey(note, 0)` on note off |
51
+ | `ui_keyboard(lo, hi, "Label")` | piano keys `lo`..`hi` (MIDI notes, 21-108 is the full 88), short and full width: put it as the last core row, below the knobs. **Playable**: press a key to play it (higher up the key = softer), drag across keys for a glissando, release to stop | `ui_kkey(note, vel)` on note on, `ui_kkey(note, 0)` on note off, for notes the plugin hears; the notes the user plays arrive in `@block` through `while (ui_kpoll()) ( ... )`: each 1 means `ui_kn` is a note and `ui_kv` its velocity (0 = off) |
51
52
  | `ui_tall(span)` | the next `ui_row` is `span` times as tall (a graph needs height); knobs in it keep their size | none |
52
53
 
53
54
  Use `ui_boot(2)` in a plugin with these feeds: it redraws only when a feed, a control or the window
54
55
  changed, so silence costs nothing (`ui_boot(1)` redraws every frame, `ui_boot(0)` only on change).
55
56
  Feeds are rounded to a visible step before they count as change. A graph widget counts as one
56
57
  widget for the core limit. The selected band is `ui_fsel` (0-based), which the plugin may read.
57
- Memory map: 0..1023 core, 1024+ graph data (`ui_fg` trace, `ui_ge` band edges, `ui_grm`, `ui_kb`),
58
+ Memory map: 0..1023 core, 1024+ graph data (`ui_fg` trace, `ui_ge` band edges, `ui_grm`, `ui_kb`, `ui_kq` the played-key queue),
58
59
  `ui_mem` (2048) is where your buffers start. `examples/multiband-compressor.jsfx` uses them all.
59
60
 
60
61
  `fmt` for knobs: `0` number (`0.00`), `1` dB, `2` percent of 0..1, `3` Hz or kHz, `4` ms, `5` integer.
@@ -72,7 +73,7 @@ when the user turns on the FX window's **+ > Send all keyboard input to plug-in*
72
73
  the plugin; then it closes the value box, the About dialog, then the drawer (and the window
73
74
  closes with its close button, as every key now goes to the plugin).
74
75
 
75
- **Header knobs.** A plugin with a Mix and/or an Output slider calls `ui_header(mix_idx, out_idx)` in `@gfx` before `ui_begin` (0 for one it does not have): two small knobs in the top right, Output rightmost, with the usual gestures, the value shown while hovered. Do not draw those sliders as widgets too (they leave the core view and its widget count). The plugin name and the first row get a clear gap below the name, a little more with header knobs.
76
+ **Header bars.** A plugin with a Mix and/or an Output slider calls `ui_header(mix_idx, out_idx)` in `@gfx` before `ui_begin` (0 for one it does not have): two slim horizontal bars in the top right (like Vital's), Output rightmost, dragged left/right with the usual gestures, the value shown while hovered. Do not draw those sliders as widgets too (they leave the core view and its widget count). The header band is one line: the plugin name and the bars are vertically centred on it, with an equal gap above and below, and the first row starts after it (the same with or without Mix / Output).
76
77
 
77
78
  Every plugin also gets, with no code of its own: its name in small spaced capitals at the top-left
78
79
  (hidden in a very narrow window), and a small "reaper-mcp" credit at the bottom right
package/main.js CHANGED
@@ -660,6 +660,20 @@ function withPageLink(result, links) {
660
660
  return { ...reply5, content: [...reply5.content, { type: "text", text: `Bridge page (before/after view): ${last}` }] };
661
661
  }
662
662
 
663
+ // apps/reaper-mcp-server/src/call-outcome.ts
664
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
665
+ var store2 = new AsyncLocalStorage2();
666
+ function trackCallOutcome(fn) {
667
+ const outcome = { logged: false, regression: false };
668
+ return store2.run(outcome, async () => ({ result: await fn(), outcome }));
669
+ }
670
+ function noteLoggedFailure(regression) {
671
+ const outcome = store2.getStore();
672
+ if (!outcome) return;
673
+ outcome.logged = true;
674
+ if (regression) outcome.regression = true;
675
+ }
676
+
663
677
  // apps/reaper-mcp-server/src/bridge.ts
664
678
  var POLL_INTERVAL_MS = 10;
665
679
  var BRIDGE_RPC_SYSTEM = "reaper_bridge";
@@ -825,6 +839,7 @@ async function sendCommand(type, params = {}, timeoutMs = DEFAULT_TIMEOUT_MS) {
825
839
  { "rpc.method": type, "error.type": "bridge_not_running", "reaper.bridge.state": down.state },
826
840
  { eventName: "reaper.bridge.command.not_sent" }
827
841
  );
842
+ noteLoggedFailure(false);
828
843
  }
829
844
  finish("bridge_not_running");
830
845
  return { id: randomUUID2(), success: false, error: message, timestamp: Date.now() };
@@ -908,6 +923,7 @@ async function sendCommand(type, params = {}, timeoutMs = DEFAULT_TIMEOUT_MS) {
908
923
  },
909
924
  { eventName: "reaper.bridge.command.failed" }
910
925
  );
926
+ noteLoggedFailure(systemError);
911
927
  }
912
928
  const tMetrics = now();
913
929
  finish(errorType);
@@ -941,6 +957,7 @@ async function sendCommand(type, params = {}, timeoutMs = DEFAULT_TIMEOUT_MS) {
941
957
  { "rpc.method": type, "reaper.bridge.command.id": id, "error.type": "timeout", "reaper.bridge.timeout_ms": timeoutMs },
942
958
  { eventName: "reaper.bridge.command.timeout" }
943
959
  );
960
+ noteLoggedFailure(true);
944
961
  finish("timeout");
945
962
  return {
946
963
  id,
@@ -956,6 +973,7 @@ async function sendCommand(type, params = {}, timeoutMs = DEFAULT_TIMEOUT_MS) {
956
973
  "error.type": errorType,
957
974
  ...exceptionAttributes(err)
958
975
  });
976
+ noteLoggedFailure(true);
959
977
  finish(errorType);
960
978
  throw err;
961
979
  } finally {
@@ -4240,13 +4258,21 @@ function registerExtensionCategory(extension, description, tools) {
4240
4258
  TOOL_CATEGORIES[name] = { name, description, tools };
4241
4259
  return name;
4242
4260
  }
4261
+ var visibleCategories = null;
4262
+ function setVisibleCategories(names) {
4263
+ visibleCategories = names;
4264
+ }
4265
+ function visible() {
4266
+ if (!visibleCategories) return TOOL_CATEGORIES;
4267
+ return Object.fromEntries(Object.entries(TOOL_CATEGORIES).filter(([n]) => visibleCategories?.has(n)));
4268
+ }
4243
4269
  function registerCategoryTools(server) {
4244
4270
  server.tool(
4245
4271
  "list_tool_categories",
4246
- `List all available tool categories with descriptions and tool names. Use this to discover what tools are available without loading every tool schema. Categories: ${Object.keys(TOOL_CATEGORIES).join(", ")}.`,
4272
+ `List all available tool categories with descriptions and tool names. Use this to discover what tools are available without loading every tool schema. Categories: ${Object.keys(visible()).join(", ")}.`,
4247
4273
  {},
4248
4274
  async () => {
4249
- const categories = Object.values(TOOL_CATEGORIES).map((cat) => ({
4275
+ const categories = Object.values(visible()).map((cat) => ({
4250
4276
  name: cat.name,
4251
4277
  description: cat.description,
4252
4278
  toolCount: cat.tools.length,
@@ -4267,9 +4293,9 @@ function registerCategoryTools(server) {
4267
4293
  category: z26.string().describe('Category name (e.g. "tracks", "fx", "midi", "media", "transport", "markers", "envelopes", "analysis", "discovery")')
4268
4294
  },
4269
4295
  async ({ category }) => {
4270
- const cat = TOOL_CATEGORIES[category];
4296
+ const cat = visible()[category];
4271
4297
  if (!cat) {
4272
- const available = Object.keys(TOOL_CATEGORIES).join(", ");
4298
+ const available = Object.keys(visible()).join(", ");
4273
4299
  return {
4274
4300
  content: [{
4275
4301
  type: "text",
@@ -4299,9 +4325,9 @@ function registerCategoryTools(server) {
4299
4325
  category: z26.string().describe('Category name (e.g. "tracks", "fx", "midi", "media", "transport", "markers", "envelopes", "analysis", "discovery")')
4300
4326
  },
4301
4327
  async ({ category }) => {
4302
- const cat = TOOL_CATEGORIES[category];
4328
+ const cat = visible()[category];
4303
4329
  if (!cat) {
4304
- const available = Object.keys(TOOL_CATEGORIES).join(", ");
4330
+ const available = Object.keys(visible()).join(", ");
4305
4331
  return {
4306
4332
  content: [{
4307
4333
  type: "text",
@@ -4324,6 +4350,45 @@ function registerCategoryTools(server) {
4324
4350
  );
4325
4351
  }
4326
4352
 
4353
+ // apps/reaper-mcp-server/src/profile.ts
4354
+ var PROFILES = {
4355
+ /** Smoke test and basic control. */
4356
+ minimal: ["project", "tracks", "fx", "transport", "discovery", "selection"],
4357
+ /** Mixing and mastering: measure, set levels and FX, route, automate, snapshot, render. */
4358
+ mixing: ["project", "tracks", "fx", "fx_files", "transport", "discovery", "selection", "routing", "plan", "analysis", "snapshots", "envelopes", "actions", "knowledge", "recording"],
4359
+ /** Writing and editing music and arrangements (no takes or actions). Adding categories or an extension, e.g. `mixing,composition`, can push a profile past 128. */
4360
+ music: ["project", "tracks", "fx", "transport", "discovery", "selection", "midi", "media", "arrange", "markers", "tempo", "envelopes", "plan"],
4361
+ /** Inspect and measure; the tracks and project categories still hold a few writers, so this is not read-only. */
4362
+ analysis: ["project", "tracks", "transport", "discovery", "selection", "routing", "markers", "tempo", "analysis", "knowledge"]
4363
+ };
4364
+ function resolveProfile(value = process.env["REAPER_MCP_PROFILE"]) {
4365
+ const parts = (value ?? "").split(",").map((p) => p.trim()).filter(Boolean);
4366
+ if (parts.length === 0 || parts.includes("full")) return { name: "full", categories: null, extensions: [] };
4367
+ const categories = /* @__PURE__ */ new Set();
4368
+ const extensions = [];
4369
+ for (const part of parts) {
4370
+ const profile = PROFILES[part];
4371
+ if (profile) profile.forEach((c) => categories.add(c));
4372
+ else {
4373
+ categories.add(part);
4374
+ if (!(part in TOOL_CATEGORIES)) extensions.push(part);
4375
+ }
4376
+ }
4377
+ return { name: parts.join(","), categories, extensions };
4378
+ }
4379
+ function blockedTools(categories) {
4380
+ if (!categories) return /* @__PURE__ */ new Set();
4381
+ const all = /* @__PURE__ */ new Set();
4382
+ const kept = /* @__PURE__ */ new Set();
4383
+ for (const cat of Object.values(TOOL_CATEGORIES)) {
4384
+ for (const t of cat.tools) {
4385
+ all.add(t);
4386
+ if (categories.has(cat.name)) kept.add(t);
4387
+ }
4388
+ }
4389
+ return new Set([...all].filter((t) => !kept.has(t)));
4390
+ }
4391
+
4327
4392
  // apps/reaper-mcp-server/src/tools/aesthetics.ts
4328
4393
  import { z as z27 } from "zod/v4";
4329
4394
  import { randomUUID as randomUUID4 } from "node:crypto";
@@ -5270,6 +5335,27 @@ var VENV_PYTHON = join6(SIDECAR_VENV_PATH2, VENV_BIN2, VENV_PYTHON_NAME2);
5270
5335
  var _rawTimeout = Number(process.env["REAPER_MCP_SIDECAR_TIMEOUT_MS"]);
5271
5336
  var ANALYZE_TIMEOUT_MS = Number.isFinite(_rawTimeout) && _rawTimeout > 0 ? _rawTimeout : 6e4;
5272
5337
  var QUEUE_WAIT_MS = 5 * 6e4;
5338
+ var SidecarRpcError = class extends Error {
5339
+ // No `name` override: a tool that lets this escape reports `error.type` from the name, which stays `Error`.
5340
+ constructor(message, code) {
5341
+ super(message);
5342
+ this.code = code;
5343
+ }
5344
+ };
5345
+ var INVALID_PARAMS = -32602;
5346
+ var REJECTED_INPUT = /^(Audio file not found|Audio too short|Sample rates differ)\b/;
5347
+ var NOT_INSTALLED = /^Audio understanding sidecar not installed|\b(audiobox-aesthetics not installed|Stem separation is not installed|FluidSynth native library is not installed)\b/;
5348
+ function classifySidecarError(err) {
5349
+ const message = err instanceof Error ? err.message : String(err);
5350
+ if (message.startsWith("Sidecar timeout")) return "timeout";
5351
+ if (message.startsWith("Sidecar busy")) return "busy";
5352
+ if (NOT_INSTALLED.test(message)) return "not_installed";
5353
+ if (err instanceof SidecarRpcError && err.code === INVALID_PARAMS || REJECTED_INPUT.test(message)) return "sidecar_rejected";
5354
+ return "sidecar_error";
5355
+ }
5356
+ function isSidecarRegression(type) {
5357
+ return type === "timeout" || type === "sidecar_error";
5358
+ }
5273
5359
  var SidecarClientImpl = class {
5274
5360
  process = null;
5275
5361
  pending = /* @__PURE__ */ new Map();
@@ -5357,14 +5443,16 @@ var SidecarClientImpl = class {
5357
5443
  return result;
5358
5444
  } catch (err) {
5359
5445
  const message = err instanceof Error ? err.message : String(err);
5360
- const errorType = message.startsWith("Sidecar timeout") ? "timeout" : message.startsWith("Sidecar busy") ? "busy" : message.startsWith("Audio understanding sidecar not installed") ? "not_installed" : "sidecar_error";
5446
+ const errorType = classifySidecarError(err);
5447
+ const regression = isSidecarRegression(errorType);
5361
5448
  metricAttrs["error.type"] = errorType;
5362
5449
  span.setAttribute("error.type", errorType);
5363
- span.setStatus({ code: SpanStatusCode2.ERROR, message: redactHome(message) });
5364
- emitLog(errorType === "not_installed" || errorType === "busy" ? "warn" : "error", `Sidecar ${method} failed: ${message}`, {
5450
+ if (regression) span.setStatus({ code: SpanStatusCode2.ERROR, message: redactHome(message) });
5451
+ emitLog(regression ? "error" : "warn", `Sidecar ${method} failed: ${message}`, {
5365
5452
  "rpc.method": method,
5366
5453
  "error.type": errorType
5367
- });
5454
+ }, { eventName: "reaper.sidecar.request.failed" });
5455
+ noteLoggedFailure(regression);
5368
5456
  throw err;
5369
5457
  } finally {
5370
5458
  span.end();
@@ -5529,7 +5617,7 @@ var SidecarClientImpl = class {
5529
5617
  }
5530
5618
  this.pending.delete(response.id);
5531
5619
  if (response.error) {
5532
- pending.reject(new Error(response.error.message));
5620
+ pending.reject(new SidecarRpcError(response.error.message, response.error.code));
5533
5621
  } else if (response.result) {
5534
5622
  pending.resolve(response.result);
5535
5623
  } else {
@@ -8780,10 +8868,14 @@ var UI_API = {
8780
8868
  ui_keyboard: 3,
8781
8869
  ui_fthresh: 4,
8782
8870
  ui_header: 2,
8783
- ui_hknob: 4,
8871
+ ui_hbar: 4,
8872
+ ui_pill: 4,
8784
8873
  ui_gfeed2: 2,
8785
8874
  ui_gshow: 1,
8786
- ui_bandknob: 4
8875
+ ui_bandknob: 4,
8876
+ ui_fband: 3,
8877
+ ui_kput: 2,
8878
+ ui_kpoll: 0
8787
8879
  };
8788
8880
  var MAX_CORE_WIDGETS = 5;
8789
8881
  var MAX_ADVANCED_WIDGETS = 8;
@@ -8825,6 +8917,7 @@ function sections2(code) {
8825
8917
  }
8826
8918
  var WIDGET = /\bui_(knob|toggle|choice|fhandle)\s*\(\s*(\d+)/g;
8827
8919
  var BANDKNOB = /\bui_bandknob\s*\(\s*(\d+)\s*,\s*(\d+)/g;
8920
+ var FBAND = /\bui_fband\s*\(\s*(\d+)\s*,\s*(\d+)/g;
8828
8921
  var FTHRESH = /\bui_fthresh\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/g;
8829
8922
  var HEADER = /\bui_header\s*\(\s*(\d+)\s*,\s*(\d+)/g;
8830
8923
  var TRANSFER = /\bui_transfer\s*\(\s*(\d+)\s*,\s*(\d+)/g;
@@ -8914,6 +9007,7 @@ function lintJsfx(source) {
8914
9007
  const ranges = [];
8915
9008
  for (const m of gfx.text.matchAll(HEADER)) for (const v of [m[1], m[2]]) if (Number(v) > 0) ranges.push(["ui_header", Number(v), 1]);
8916
9009
  for (const m of gfx.text.matchAll(BANDKNOB)) ranges.push(["ui_bandknob", Number(m[1]), Number(m[2])]);
9010
+ for (const m of gfx.text.matchAll(FBAND)) ranges.push(["ui_fband", Number(m[1]), Number(m[2])]);
8917
9011
  for (const m of gfx.text.matchAll(FTHRESH)) ranges.push(["ui_fthresh", Number(m[1]), Number(m[4])], ["ui_fthresh", Number(m[2]), Number(m[4])], ["ui_fthresh", Number(m[3]), Number(m[4])]);
8918
9012
  for (const [fn, first, count] of ranges) {
8919
9013
  for (let idx = first; idx < first + count; idx++) {
@@ -9357,17 +9451,24 @@ function instrumentToolHandlers(server) {
9357
9451
  },
9358
9452
  async (span) => {
9359
9453
  try {
9360
- const collected = await collectPageLinks(() => originalCb(...cbArgs));
9454
+ const { result: collected, outcome } = await trackCallOutcome(() => collectPageLinks(() => originalCb(...cbArgs)));
9361
9455
  const result = withPageLink(collected.result, collected.links);
9362
9456
  const res = result;
9363
9457
  if (res?.isError) {
9364
9458
  const errorText = res.content?.[0]?.text ?? "Tool error";
9365
9459
  const message = redactHome(errorText).slice(0, MAX_STATUS_MESSAGE);
9460
+ const regression = outcome.regression || isSystemError(classifyBridgeError(errorText.replace(/^Error:\s*/, "")));
9366
9461
  metricAttrs["error.type"] = "tool_error";
9367
9462
  span.setAttribute("error.type", "tool_error");
9368
9463
  span.setAttribute(TOOL_ERROR_MESSAGE, message);
9369
- if (isSystemError(classifyBridgeError(errorText.replace(/^Error:\s*/, "")))) {
9370
- span.setStatus({ code: SpanStatusCode3.ERROR, message });
9464
+ if (regression) span.setStatus({ code: SpanStatusCode3.ERROR, message });
9465
+ if (!outcome.logged) {
9466
+ emitLog(
9467
+ regression ? "error" : "warn",
9468
+ `Tool ${toolName} failed: ${message}`,
9469
+ { "gen_ai.tool.name": toolName, "error.type": "tool_error" },
9470
+ { eventName: "reaper.tool.failed" }
9471
+ );
9371
9472
  }
9372
9473
  }
9373
9474
  return result;
@@ -9394,12 +9495,20 @@ function instrumentToolHandlers(server) {
9394
9495
  return originalTool(...args);
9395
9496
  };
9396
9497
  }
9397
- function createServer() {
9498
+ function applyProfile(server, profile) {
9499
+ setVisibleCategories(profile.categories);
9500
+ const blocked = blockedTools(profile.categories);
9501
+ if (blocked.size === 0) return;
9502
+ const register = server.tool.bind(server);
9503
+ server.tool = (...args) => blocked.has(args[0]) ? void 0 : register(...args);
9504
+ }
9505
+ function createServer(profile = resolveProfile()) {
9398
9506
  const server = new McpServer({
9399
9507
  name: "reaper-mcp",
9400
9508
  version: "0.1.0"
9401
9509
  });
9402
9510
  instrumentToolHandlers(server);
9511
+ applyProfile(server, profile);
9403
9512
  registerProjectTools(server);
9404
9513
  registerTrackTools(server);
9405
9514
  registerFxTools(server);
@@ -9728,9 +9837,13 @@ async function loadOne(server, ext) {
9728
9837
  return skipped(err instanceof Error ? err.message : String(err));
9729
9838
  }
9730
9839
  }
9731
- async function loadExtensions(server, root = getExtensionsDir()) {
9840
+ async function loadExtensions(server, root = getExtensionsDir(), include) {
9732
9841
  const statuses = [];
9733
9842
  for (const ext of await discoverExtensions(root)) {
9843
+ if (include && !include(ext.manifest?.name ?? ext.folder)) {
9844
+ statuses.push({ name: ext.manifest?.name ?? ext.folder, status: "skipped", reason: "not in the REAPER_MCP_PROFILE", tools: [] });
9845
+ continue;
9846
+ }
9734
9847
  if (!ext.manifest) {
9735
9848
  statuses.push({ name: ext.folder, status: "skipped", reason: ext.errors.join("; "), tools: [] });
9736
9849
  } else {
@@ -10613,11 +10726,20 @@ async function serve() {
10613
10726
  });
10614
10727
  startupSpan.setAttribute("reaper.bridge.connected", bridge.state === "connected");
10615
10728
  startupSpan.setAttribute("reaper.bridge.state", bridge.state);
10616
- const server = createServer();
10617
- for (const ext of await loadExtensions(server)) {
10729
+ const profile = resolveProfile();
10730
+ const server = createServer(profile);
10731
+ const selected = profile.categories;
10732
+ const loadedExtensions = await loadExtensions(server, void 0, selected ? (name) => selected.has(name) : void 0);
10733
+ for (const ext of loadedExtensions) {
10618
10734
  if (ext.status === "loaded") log(`Extension ${ext.name} ${ext.version ?? ""} loaded (${ext.tools.length} tools)`);
10619
10735
  else log(`Extension ${ext.name} skipped: ${ext.reason}`);
10620
10736
  }
10737
+ if (selected) {
10738
+ log(`Tool profile "${profile.name}": ${Object.keys(server._registeredTools).length} tools`);
10739
+ for (const name of profile.extensions) {
10740
+ if (!loadedExtensions.some((e) => e.name === name && e.status === "loaded")) log(`REAPER_MCP_PROFILE names "${name}", which is neither a profile, a tool category nor a loaded extension`);
10741
+ }
10742
+ }
10621
10743
  const transport = new StdioServerTransport();
10622
10744
  await server.connect(transport);
10623
10745
  server.server.oninitialized = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mthines/reaper-mcp",
3
- "version": "0.82.0",
3
+ "version": "0.82.1-beta.113.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",