deep-roon-mcp 0.5.11 → 0.5.13

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 CHANGED
@@ -22,7 +22,7 @@ server of its own and sends nothing anywhere else. What you ask goes to your MCP
22
22
 
23
23
  ## Status
24
24
 
25
- Version 0.5: sixty-four tools (fifty-eight with a read-only library; sixty-eight with playlist editing on). Qobuz, TIDAL or both — whatever is signed in on your Core.
25
+ Version 0.5: sixty-eight tools (sixty with a read-only library; seventy-two with playlist editing on). Qobuz, TIDAL or both — whatever is signed in on your Core.
26
26
 
27
27
  **Reading** — changes nothing in Roon:
28
28
 
@@ -40,7 +40,7 @@ Version 0.5: sixty-four tools (fifty-eight with a read-only library; sixty-eight
40
40
  | `roon_zones` | Roon's zones and groups |
41
41
  | `roon_now_playing` | What plays in each zone, with the volume |
42
42
  | `roon_waveform` | The waveform of what plays in a zone, as Roon draws it in its seek bar (local files, and streams once played) |
43
- | `roon_queue` | A zone's queue, numbered (1 is what plays) |
43
+ | `roon_queue` | A zone's queue, numbered (1 is what plays), each row with its `item` id |
44
44
  | `roon_cover` | The cover of what plays, as an image |
45
45
  | `roon_history` | Roon's play history, newest first |
46
46
  | `roon_top` | Most played albums, artists or tracks over your whole history |
@@ -57,6 +57,8 @@ Version 0.5: sixty-four tools (fifty-eight with a read-only library; sixty-eight
57
57
  | `roon_tidal_playlists` | TIDAL's playlists: its editorial shelves, by genre or mood, and your own TIDAL mixes |
58
58
  | `roon_favorites` | Albums with a heart in Roon, or your Qobuz or TIDAL favourites |
59
59
  | `roon_listen_later` | Your Listen Later list |
60
+ | `roon_tags` | Your tags: name, key, smart or not |
61
+ | `roon_album_tags` | The tags of one album |
60
62
  | `roon_versions` | Other versions of an album: remasters, hi-res, in your library and streaming |
61
63
  | `roon_similar` | More like this, for an album or an artist |
62
64
  | `roon_signal_path` | Roon's signal path for what plays: is it bit-perfect, what happens on the way |
@@ -74,7 +76,7 @@ Version 0.5: sixty-four tools (fifty-eight with a read-only library; sixty-eight
74
76
  | `roon_seek` | A position in the playing track |
75
77
  | `roon_volume` | A zone's volume, mute |
76
78
  | `roon_settings` | Shuffle, repeat, Roon Radio |
77
- | `roon_queue_jump`, `roon_queue_remove`, `roon_queue_move` | Jump to an item of the queue, take items out, move one before or after another |
79
+ | `roon_queue_jump`, `roon_queue_remove`, `roon_queue_move` | Jump to an item of the queue, take items out, move one before or after another — by the `item` from `roon_queue`, so a track that ended in between doesn't shift the target |
78
80
  | `roon_queue_clear` | Clear what comes after the playing track (or everything) |
79
81
  | `roon_transfer` | Move what plays, with its queue, to another zone |
80
82
  | `roon_group`, `roon_ungroup` | Group zones, and undo it |
@@ -87,11 +89,11 @@ Version 0.5: sixty-four tools (fifty-eight with a read-only library; sixty-eight
87
89
 
88
90
  **Changing your library or sound** — only on your request; each one reads the result back and says if Roon didn't follow.
89
91
 
90
- > **A word of care.** These six tools write into your Core's library and settings through Roon's *internal* protocol —
92
+ > **A word of care.** These eight tools write into your Core's library and settings through Roon's *internal* protocol —
91
93
  > the same wiring Roon's own apps use, but not an API Roon Labs supports for others. Deep Roon is careful with it (one
92
- > change at a time, read back, nothing in bulk), but a Roon update can change that wiring under it. **Keep a recent backup
94
+ > change at a time, read back; only tagging takes a list of albums, and asks for `confirm`), but a Roon update can change that wiring under it. **Keep a recent backup
93
95
  > of your Roon database** (Roon › Settings › Backups) before you let an assistant change things — and if you only want to
94
- > ask and listen, switch on **Read-only library** below: then these six tools aren't there at all.
96
+ > ask and listen, switch on **Read-only library** below: then these eight tools aren't there at all.
95
97
 
96
98
 
97
99
  | Tool | What it does |
@@ -99,6 +101,8 @@ Version 0.5: sixty-four tools (fifty-eight with a read-only library; sixty-eight
99
101
  | `roon_favorite` | A heart on an album or track, or off |
100
102
  | `roon_listen_later_set` | On or off the Listen Later list |
101
103
  | `roon_library_add` | A Qobuz or TIDAL album into your library |
104
+ | `roon_tag_albums` | Albums into a tag (or out of it); `create` makes the tag — you see the list first, then `confirm` |
105
+ | `roon_tag_delete` | A tag away (its albums stay), with `confirm` |
102
106
  | `roon_playlist_create` | A new playlist from tracks |
103
107
  | `roon_dsp_set` | MUSE on or off, one part on or off, or a preset |
104
108
  | `roon_radio_favorite` | A station into My Live Radio, or out of it |
@@ -5407,8 +5407,8 @@ var require_multipleOf = __commonJS({
5407
5407
  const { gen, data, schemaCode, it } = cxt;
5408
5408
  const prec = it.opts.multipleOfPrecision;
5409
5409
  const res = gen.let("res");
5410
- const invalid2 = prec ? (0, codegen_1._)`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` : (0, codegen_1._)`${res} !== parseInt(${res})`;
5411
- cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid2}))`);
5410
+ const invalid3 = prec ? (0, codegen_1._)`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` : (0, codegen_1._)`${res} !== parseInt(${res})`;
5411
+ cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid3}))`);
5412
5412
  }
5413
5413
  };
5414
5414
  exports2.default = def;
@@ -15489,7 +15489,7 @@ var require_lib2 = __commonJS({
15489
15489
  var version2;
15490
15490
  var init_package = __esm({
15491
15491
  "package.json"() {
15492
- version2 = "0.5.11";
15492
+ version2 = "0.5.13";
15493
15493
  }
15494
15494
  });
15495
15495
 
@@ -16574,20 +16574,20 @@ async function trackFiles(a) {
16574
16574
  const paden = /* @__PURE__ */ __name((x) => items(c, field2(x, "DuplicateTracks")).map((d) => field2(d, "FilePath")).filter((p) => typeof p === "string" && !!p), "paden");
16575
16575
  const tracks2 = infos.map((x) => {
16576
16576
  const t = obj(c, field2(x, "Track"));
16577
- const row = { key: String(field2(t, "TrackId") ?? "") };
16577
+ const row2 = { key: String(field2(t, "TrackId") ?? "") };
16578
16578
  const title = field2(t, "Title");
16579
- if (title) row.title = title;
16579
+ if (title) row2.title = title;
16580
16580
  const al = field2(obj(c, field2(t, "Album")), "Title");
16581
- if (al) row.album = al;
16581
+ if (al) row2.album = al;
16582
16582
  const n2 = field2(t, "TrackNumber");
16583
- if (n2 != null) row.n = n2;
16583
+ if (n2 != null) row2.n = n2;
16584
16584
  const path2 = field2(x, "FilePath");
16585
- if (typeof path2 === "string" && path2) row.path = path2;
16585
+ if (typeof path2 === "string" && path2) row2.path = path2;
16586
16586
  const format = field2(t, "Format");
16587
- if (format) row.format = format;
16587
+ if (format) row2.format = format;
16588
16588
  const dup = paden(x);
16589
- if (dup.length) row.duplicates = dup;
16590
- return row;
16589
+ if (dup.length) row2.duplicates = dup;
16590
+ return row2;
16591
16591
  });
16592
16592
  const gevraagd = a.tracks?.length ?? 0, ontbreekt = gevraagd ? gevraagd - tracks2.length : 0;
16593
16593
  const zonder = tracks2.filter((t) => !t.path).length + Math.max(0, ontbreekt);
@@ -16671,7 +16671,7 @@ function albumTypeOf(x) {
16671
16671
  const alias = { mainrelease: "main", album: "main", extendedplay: "ep", ost: "soundtrack" };
16672
16672
  return ALBUM_TYPES.indexOf(alias[k] ?? k);
16673
16673
  }
16674
- async function virtualQuery(c, kind, members2, limit3, offset2, row) {
16674
+ async function virtualQuery(c, kind, members2, limit3, offset2, row2) {
16675
16675
  const schema = structSchema(`Sooloos.Broker.Api.${kind}QueryCriteria`) ?? [];
16676
16676
  const missing = members2.find((f) => !schema.some((m) => m.shortName === f.name));
16677
16677
  if (missing) throw new RoonError(`The filter ${missing.name} doesn't exist for ${kind.toLowerCase()}s in this Roon version`, "invalid");
@@ -16704,7 +16704,7 @@ async function virtualQuery(c, kind, members2, limit3, offset2, row) {
16704
16704
  if (found.length >= expected && found.every(loaded)) break;
16705
16705
  await wait(60);
16706
16706
  }
16707
- return { total, offset: page * size, rows: found.filter(loaded).map(row) };
16707
+ return { total, offset: page * size, rows: found.filter(loaded).map(row2) };
16708
16708
  } finally {
16709
16709
  try {
16710
16710
  c.remoting.callMethodNoReply(qoid, formatMethodSignature(type, "ReleasePage", pageParams), buildArgs([Arg.int(page)]));
@@ -50055,18 +50055,28 @@ function queueRow(c, oid) {
50055
50055
  return r;
50056
50056
  }
50057
50057
  __name(queueRow, "queueRow");
50058
- async function queueItemAt(c, zoneName, n) {
50058
+ function pick2(refs, at2, n, item, zone3) {
50059
+ if (item !== void 0) {
50060
+ const i = refs.findIndex((o) => String(o) === item);
50061
+ if (i < at2) throw new RoonError(`That item is no longer in the queue of ${zone3} (it played or was removed) \u2014 read roon_queue again`, "invalid");
50062
+ return refs[i];
50063
+ }
50064
+ const oid = refs[at2 + n - 1];
50065
+ if (oid === void 0) throw new RoonError(`The queue of ${zone3} has no item ${n} (${Math.max(0, refs.length - at2)} from here)`, "invalid");
50066
+ return oid;
50067
+ }
50068
+ __name(pick2, "pick");
50069
+ async function queueItemAt(c, zoneName, n, item) {
50059
50070
  const { z: z2, q } = queueOf(c, zoneName);
50060
50071
  const refs = await queueItems(c, q);
50061
50072
  const at2 = Math.max(0, field2(c.graph.getObject(q.oid), "CurrentItemIndex") ?? 0);
50062
- const oid = refs[at2 + n - 1];
50063
- if (oid === void 0) throw new RoonError(`The queue of ${z2.name} has no item ${n} (${Math.max(0, refs.length - at2)} from here)`, "invalid");
50073
+ const oid = pick2(refs, at2, n, item, z2.name);
50064
50074
  return { z: z2, q, oid, refs, at: at2 };
50065
50075
  }
50066
50076
  __name(queueItemAt, "queueItemAt");
50067
- async function queueJump(zoneName, n) {
50077
+ async function queueJump(zoneName, n, item) {
50068
50078
  const r = await withCore(async (c) => {
50069
- const { z: z2, q, oid } = await queueItemAt(c, zoneName, n);
50079
+ const { z: z2, q, oid } = await queueItemAt(c, zoneName, n, item);
50070
50080
  c.remoting.callMethodNoReply(q.oid, formatMethodSignature("Queue", "PlayFromHere", [{ type: "TransportItem", name: "item" }]), buildArgs([Arg.ref(oid)]));
50071
50081
  log(`queue_jump: ${z2.name} \u2192 item ${n}`);
50072
50082
  return { zone: z2.name, n };
@@ -50074,12 +50084,12 @@ async function queueJump(zoneName, n) {
50074
50084
  return { ok: true, ...r, ...await started2(r.zone, PRIORITY["now"]) };
50075
50085
  }
50076
50086
  __name(queueJump, "queueJump");
50077
- async function queueRemove(zoneName, ns) {
50087
+ async function queueRemove(zoneName, ns, items2) {
50078
50088
  return withCore(async (c) => {
50079
50089
  const { z: z2, q } = queueOf(c, zoneName);
50080
50090
  const refs = await queueItems(c, q);
50081
50091
  const at2 = Math.max(0, field2(c.graph.getObject(q.oid), "CurrentItemIndex") ?? 0);
50082
- const oids = [...new Set(ns)].map((n) => refs[at2 + n - 1]).filter((o) => o !== void 0);
50092
+ const oids = items2?.length ? [...new Set(items2.map((it) => pick2(refs, at2, 0, it, z2.name)))].filter((o) => o !== refs[at2]) : [...new Set(ns)].map((n) => refs[at2 + n - 1]).filter((o) => o !== void 0);
50083
50093
  if (!oids.length) throw new RoonError("No such items in the queue", "invalid");
50084
50094
  c.remoting.callMethodNoReply(q.oid, formatMethodSignature("Queue", "RemoveItems", [{ type: "IEnumerable<TransportItem>", name: "items" }]), buildArgs([Arg.collection(oids.map((o) => buildArgs([Arg.ref(o)])))]));
50085
50095
  log(`queue_remove: ${z2.name} \u2212 ${oids.length} item(s)`);
@@ -50090,11 +50100,11 @@ async function queueRemove(zoneName, ns) {
50090
50100
  }
50091
50101
  __name(queueRemove, "queueRemove");
50092
50102
  var INSERTION = { before: 3, after: 2 };
50093
- async function queueMove(zoneName, n, to, where) {
50103
+ async function queueMove(zoneName, n, to, where, item, toItem) {
50094
50104
  return withCore(async (c) => {
50095
- const { z: z2, q, oid, refs, at: at2 } = await queueItemAt(c, zoneName, n);
50096
- const rel = refs[at2 + to - 1];
50097
- if (rel === void 0 || to === n) throw new RoonError(`The queue of ${z2.name} has no item ${to} to move next to`, "invalid");
50105
+ const { z: z2, q, oid, refs, at: at2 } = await queueItemAt(c, zoneName, n, item);
50106
+ const rel = toItem !== void 0 ? pick2(refs, at2, to, toItem, z2.name) : refs[at2 + to - 1];
50107
+ if (rel === void 0 || rel === oid) throw new RoonError(`The queue of ${z2.name} has no item ${to} to move next to`, "invalid");
50098
50108
  const point = INSERTION[where];
50099
50109
  const res = await c.call(
50100
50110
  "Queue",
@@ -50108,7 +50118,7 @@ async function queueMove(zoneName, n, to, where) {
50108
50118
  await wait(300);
50109
50119
  const after = await queueItems(c, q);
50110
50120
  const now = after.indexOf(oid) - at2 + 1;
50111
- return { ok: true, zone: z2.name, moved: n, now_at: now > 0 ? now : void 0 };
50121
+ return { ok: true, zone: z2.name, moved: refs.indexOf(oid) - at2 + 1, now_at: now > 0 ? now : void 0 };
50112
50122
  });
50113
50123
  }
50114
50124
  __name(queueMove, "queueMove");
@@ -50120,7 +50130,7 @@ async function queue2(zoneName, limit3) {
50120
50130
  const view = refs.slice(at2, at2 + Math.min(Math.max(1, limit3), 200));
50121
50131
  const end = Date.now() + 2500;
50122
50132
  while (Date.now() < end && view.some((oid) => queueRow(c, oid).title === null)) await wait(50);
50123
- return { zone: z2.name, left: Math.max(0, refs.length - at2), rows: view.map((oid, i) => ({ n: i + 1, now: i === 0 || void 0, ...queueRow(c, oid) })) };
50133
+ return { zone: z2.name, left: Math.max(0, refs.length - at2), rows: view.map((oid, i) => ({ n: i + 1, now: i === 0 || void 0, item: String(oid), ...queueRow(c, oid) })) };
50124
50134
  });
50125
50135
  }
50126
50136
  __name(queue2, "queue");
@@ -50238,15 +50248,15 @@ __name(standby, "standby");
50238
50248
  async function cover(zoneName) {
50239
50249
  const t = await findTarget();
50240
50250
  const info = await withCore(async (c) => {
50241
- const pick2 = zoneName ? findZone(c, zoneName) : null;
50251
+ const pick3 = zoneName ? findZone(c, zoneName) : null;
50242
50252
  const zones4 = c.graph.findByType("Zone");
50243
- const z2 = pick2 ? c.graph.getObject(pick2.oid) : zones4.find((x) => (field2(x, "State") ?? 0) === 0 && items(c, field2(obj(c, field2(x, "NowPlaying")), "Tracks")).length) ?? zones4.find((x) => field2(x, "State") === 2 && items(c, field2(obj(c, field2(x, "NowPlaying")), "Tracks")).length);
50253
+ const z2 = pick3 ? c.graph.getObject(pick3.oid) : zones4.find((x) => (field2(x, "State") ?? 0) === 0 && items(c, field2(obj(c, field2(x, "NowPlaying")), "Tracks")).length) ?? zones4.find((x) => field2(x, "State") === 2 && items(c, field2(obj(c, field2(x, "NowPlaying")), "Tracks")).length);
50244
50254
  if (!z2) throw new RoonError(zoneName ? `Nothing plays on ${zoneName}` : "Nothing plays in Roon right now", "not_found");
50245
50255
  const tr = obj(c, field2(items(c, field2(obj(c, field2(z2, "NowPlaying")), "Tracks"))[0], "Track"));
50246
50256
  const al = obj(c, field2(tr, "Album"));
50247
50257
  const url2 = String(field2(obj(c, field2(al, "Image")), "Url") ?? field2(obj(c, field2(tr, "Image")), "Url") ?? "");
50248
50258
  const key = /^broker:\/\/\/image\/([^.]+)\./.exec(url2)?.[1];
50249
- return { key, title: field2(tr, "Title"), album: field2(al, "Title"), artist: clean(field2(al, "PerformedBy")), zone: pick2?.name ?? zoneNames(c).get(String(z2.oid)) };
50259
+ return { key, title: field2(tr, "Title"), album: field2(al, "Title"), artist: clean(field2(al, "PerformedBy")), zone: pick3?.name ?? zoneNames(c).get(String(z2.oid)) };
50250
50260
  });
50251
50261
  const off = info.zone ? officialZone(info.zone) : void 0;
50252
50262
  const urls = [
@@ -50841,22 +50851,33 @@ function registerControlTools(server, internal = true) {
50841
50851
  }, ({ zone: zn, limit: limit3 }) => run(() => queue2(zn, limit3 ?? 50)));
50842
50852
  reg("roon_queue_jump", {
50843
50853
  title: "Jump in the queue",
50844
- description: "Play an item of the zone's queue now (`n` as roon_queue numbers them: 1 is what plays, 2 the next \u2026); what came before it is done. Only on an explicit request.",
50845
- inputSchema: { zone, n: external_exports.number().int().min(1) },
50854
+ description: "Play an item of the zone's queue now (`n` as roon_queue numbers them: 1 is what plays, 2 the next \u2026); what came before it is done. Pass the row's `item` from roon_queue too: positions shift when a track ends, the item doesn't. Only on an explicit request.",
50855
+ inputSchema: { zone, n: external_exports.number().int().min(1), item: external_exports.string().optional().describe("The row's `item` from roon_queue \u2014 finds that item even if the positions moved on, and refuses if it is gone.") },
50846
50856
  annotations: PLAYS
50847
- }, ({ zone: zn, n }) => run(() => queueJump(zn, n)));
50857
+ }, ({ zone: zn, n, item }) => run(() => queueJump(zn, n, item)));
50848
50858
  reg("roon_queue_remove", {
50849
50859
  title: "Remove from the queue",
50850
- description: "Take items out of the zone's queue, by their numbers from roon_queue (`ns`, e.g. [3, 4]). Only on an explicit request.",
50851
- inputSchema: { zone, ns: external_exports.array(external_exports.number().int().min(2)).min(1).max(100).describe("Positions from roon_queue (2 and up: 1 is what plays).") },
50860
+ description: "Take items out of the zone's queue, by their numbers from roon_queue (`ns`, e.g. [3, 4]) \u2014 and preferably their `items` too: positions shift when a track ends, the items don't. Only on an explicit request.",
50861
+ inputSchema: {
50862
+ zone,
50863
+ ns: external_exports.array(external_exports.number().int().min(2)).min(1).max(100).describe("Positions from roon_queue (2 and up: 1 is what plays)."),
50864
+ items: external_exports.array(external_exports.string()).max(100).optional().describe("The rows' `item` from roon_queue: exactly these are removed, and nothing if one is gone.")
50865
+ },
50852
50866
  annotations: CHANGES_QUEUE
50853
- }, ({ zone: zn, ns }) => run(() => queueRemove(zn, ns)));
50867
+ }, ({ zone: zn, ns, items: items2 }) => run(() => queueRemove(zn, ns, items2)));
50854
50868
  reg("roon_queue_move", {
50855
50869
  title: "Move in the queue",
50856
- description: "Move an item of the zone's queue next to another: `n` goes `before` or `after` item `to` (numbers from roon_queue; 1 is what plays). Only on an explicit request.",
50857
- inputSchema: { zone, n: external_exports.number().int().min(2), to: external_exports.number().int().min(2), where: external_exports.enum(["before", "after"]).optional().describe("before (default) or after item `to`.") },
50870
+ description: "Move an item of the zone's queue next to another: `n` goes `before` or `after` item `to` (numbers from roon_queue; 1 is what plays). Pass `item` and `to_item` from roon_queue too: positions shift when a track ends, items don't. Only on an explicit request.",
50871
+ inputSchema: {
50872
+ zone,
50873
+ n: external_exports.number().int().min(2),
50874
+ to: external_exports.number().int().min(2),
50875
+ where: external_exports.enum(["before", "after"]).optional().describe("before (default) or after item `to`."),
50876
+ item: external_exports.string().optional().describe("The `item` of row n from roon_queue."),
50877
+ to_item: external_exports.string().optional().describe("The `item` of row `to` from roon_queue.")
50878
+ },
50858
50879
  annotations: CHANGES_QUEUE
50859
- }, ({ zone: zn, n, to, where }) => run(() => queueMove(zn, n, to, where ?? "before")));
50880
+ }, ({ zone: zn, n, to, where, item, to_item }) => run(() => queueMove(zn, n, to, where ?? "before", item, to_item)));
50860
50881
  reg("roon_queue_clear", {
50861
50882
  title: "Clear the queue",
50862
50883
  description: "Clear the queue of a Roon zone. By default the track that plays keeps playing and everything after it is removed; `everything: true` also removes the playing track (the zone falls silent). Only on an explicit request.",
@@ -51566,11 +51587,11 @@ var STATE3 = { 0: "playing", 1: "loading", 2: "paused", 3: "stopped" };
51566
51587
  async function signalPath(zoneName) {
51567
51588
  return withCore(async (c) => {
51568
51589
  const names2 = zoneNames(c);
51569
- let pick2 = zoneName ? String(findZone(c, zoneName).oid) : null;
51570
- if (pick2) {
51590
+ let pick3 = zoneName ? String(findZone(c, zoneName).oid) : null;
51591
+ if (pick3) {
51571
51592
  const hasPath = /* @__PURE__ */ __name((oid) => items(c, field2(obj(c, field2(c.graph.getObject(BigInt(oid)), "SignalPath")), "Elements")).length > 0, "hasPath");
51572
- if (!hasPath(pick2)) {
51573
- const target2 = names2.get(pick2);
51593
+ if (!hasPath(pick3)) {
51594
+ const target2 = names2.get(pick3);
51574
51595
  const same = /* @__PURE__ */ new Set();
51575
51596
  for (const e of c.graph.findByType("Endpoint")) {
51576
51597
  const z2 = field2(e, "Zone");
@@ -51579,11 +51600,11 @@ async function signalPath(zoneName) {
51579
51600
  const better = [...same].find(hasPath);
51580
51601
  if (better) {
51581
51602
  names2.set(better, target2);
51582
- pick2 = better;
51603
+ pick3 = better;
51583
51604
  }
51584
51605
  }
51585
51606
  }
51586
- return { zones: c.graph.findByType("Zone").filter((z2) => names2.has(String(z2.oid)) && (!pick2 || String(z2.oid) === pick2)).map((z2) => {
51607
+ return { zones: c.graph.findByType("Zone").filter((z2) => names2.has(String(z2.oid)) && (!pick3 || String(z2.oid) === pick3)).map((z2) => {
51587
51608
  const name = names2.get(String(z2.oid));
51588
51609
  const sp = obj(c, field2(z2, "SignalPath"));
51589
51610
  const r = { zone: name, state: officialZone(name)?.state ?? STATE3[field2(z2, "State") ?? 0], quality: QUALITY[field2(sp, "Quality") ?? 0] ?? String(field2(sp, "Quality")) };
@@ -51652,12 +51673,12 @@ function dspParts(c, d) {
51652
51673
  __name(dspParts, "dspParts");
51653
51674
  async function dsp(zoneName) {
51654
51675
  return withCore(async (c) => {
51655
- const pick2 = zoneName ? findZone(c, zoneName).oid : null;
51676
+ const pick3 = zoneName ? findZone(c, zoneName).oid : null;
51656
51677
  const names2 = zoneNames(c);
51657
51678
  const zones4 = [];
51658
51679
  for (const e of currentEndpoints(c)) {
51659
51680
  const z2 = field2(e, "Zone");
51660
- if (!isRef2(z2) || typeof field2(e, "Name") !== "string" || pick2 !== null && String(z2.$ref) !== String(pick2)) continue;
51681
+ if (!isRef2(z2) || typeof field2(e, "Name") !== "string" || pick3 !== null && String(z2.$ref) !== String(pick3)) continue;
51661
51682
  const d = await dspOf(c, e);
51662
51683
  const r = { zone: names2.get(String(z2.$ref)) ?? field2(e, "Name") };
51663
51684
  if (field2(e, "Name") !== r.zone) r.output = field2(e, "Name");
@@ -51787,6 +51808,168 @@ async function deviceReset(opts) {
51787
51808
  }
51788
51809
  __name(deviceReset, "deviceReset");
51789
51810
 
51811
+ // src/roon/tags.ts
51812
+ init_intern();
51813
+ init_serializer();
51814
+ init_writer();
51815
+ init_session();
51816
+ init_graph();
51817
+ init_library();
51818
+ var invalid = /* @__PURE__ */ __name((s) => {
51819
+ throw new RoonError(s, "invalid");
51820
+ }, "invalid");
51821
+ var tagKey = /* @__PURE__ */ __name((t) => {
51822
+ const id = field2(t, "TagId");
51823
+ return Buffer.isBuffer(id) ? id.toString("hex") : String(id ?? "");
51824
+ }, "tagKey");
51825
+ var isExplicit = /* @__PURE__ */ __name((t) => /ExplicitTag(Lite)?$/.test(t?.typeName ?? ""), "isExplicit");
51826
+ var row = /* @__PURE__ */ __name((t) => ({
51827
+ key: tagKey(t),
51828
+ name: field2(t, "Name") ?? "",
51829
+ kind: isExplicit(t) ? "tag" : "smart tag",
51830
+ ...typeof field2(t, "ItemCount") === "number" ? { items: field2(t, "ItemCount") } : {},
51831
+ ...field2(t, "IsReadOnly") === true ? { read_only: true } : {}
51832
+ }), "row");
51833
+ var refList3 = /* @__PURE__ */ __name((oids) => {
51834
+ const w = new BinaryWriter().flexInt(oids.length);
51835
+ for (const x of oids) w.long(x);
51836
+ const b = w.toBuffer();
51837
+ return new BinaryWriter().integer(b.length).bytes(b).toBuffer();
51838
+ }, "refList");
51839
+ async function allTags(c) {
51840
+ const res = await c.call(
51841
+ "Library",
51842
+ "GetAllTagLites",
51843
+ [{ type: "Profile", name: "profile" }, { type: "ResultCallback<DataList<TagLite>>", name: "cb_result" }],
51844
+ buildArgs([Arg.ref(profileObject(c).oid)]),
51845
+ c.serviceOid("Library")
51846
+ );
51847
+ if (!res.success) throw new RoonError(`Roon refused the list of tags (${res.status})`);
51848
+ const list = items(c, decoded3(c, res.payload));
51849
+ await untilLoaded(c, list.map((t) => ({ $ref: t.oid })), 2500);
51850
+ return list;
51851
+ }
51852
+ __name(allTags, "allTags");
51853
+ async function tags() {
51854
+ return withCore(async (c) => {
51855
+ const all = await allTags(c);
51856
+ return { count: all.length, tags: all.map(row).sort((a, b) => String(a.name).localeCompare(String(b.name))) };
51857
+ });
51858
+ }
51859
+ __name(tags, "tags");
51860
+ async function tagsOfAlbum(c, al) {
51861
+ const v = field2(al, "Tags");
51862
+ const list = isRef2(v) ? items(c, v) : (v?.$items ?? []).map((x) => obj(c, x)).filter(Boolean);
51863
+ await untilLoaded(c, list.map((t) => ({ $ref: t.oid })), 1500);
51864
+ return list.map((t) => String(field2(t, "Name") ?? "")).filter(Boolean);
51865
+ }
51866
+ __name(tagsOfAlbum, "tagsOfAlbum");
51867
+ async function albumTags(key) {
51868
+ return withCore(async (c) => {
51869
+ const al = await findAlbum(c, key);
51870
+ return { key, title: field2(al, "Title"), tags: await tagsOfAlbum(c, al) };
51871
+ });
51872
+ }
51873
+ __name(albumTags, "albumTags");
51874
+ async function tagAlbums(name, keys, opts) {
51875
+ if (!opts.confirm) invalid("Tagging changes the library: pass confirm: true, after the user agreed to these albums and this tag.");
51876
+ const wanted2 = name.trim();
51877
+ if (!wanted2) invalid("A tag name, please.");
51878
+ const unique = [...new Set(keys.map((k) => k.trim()).filter(Boolean))];
51879
+ if (!unique.length) invalid("No album keys.");
51880
+ if (unique.length > 500) invalid("At most 500 albums at a time.");
51881
+ return withCore(async (c) => {
51882
+ const albums = [];
51883
+ for (const k of unique) albums.push(await findAlbum(c, k));
51884
+ const lib = c.serviceOid("Library");
51885
+ let all = await allTags(c);
51886
+ let tag = all.find((t) => String(field2(t, "Name") ?? "").toLowerCase() === wanted2.toLowerCase());
51887
+ let created = false;
51888
+ if (!tag) {
51889
+ if (opts.remove) invalid(`There is no tag called "${wanted2}".`);
51890
+ if (!opts.create) invalid(`There is no tag called "${wanted2}" yet \u2014 pass create: true to make it.`);
51891
+ const params = c.structArg("Sooloos.Broker.Api.CreateTagParameters", [
51892
+ { name: "Name", propType: 20, value: new BinaryWriter().string(wanted2).toBuffer() },
51893
+ { name: "Profile", propType: 23, value: new BinaryWriter().long(profileObject(c).oid).toBuffer() }
51894
+ ]);
51895
+ const res2 = await c.call(
51896
+ "Library",
51897
+ "CreateTag",
51898
+ [{ type: "CreateTagParameters", name: "parameters" }, { type: "ResultCallback<CreateTagResult>", name: "cb_result" }],
51899
+ params,
51900
+ lib
51901
+ );
51902
+ if (!res2.success) throw new RoonError(`Roon refused to create the tag (${res2.status})`);
51903
+ for (let i = 0; i < 20 && !tag; i++) {
51904
+ await wait(150);
51905
+ all = await allTags(c);
51906
+ tag = all.find((t) => String(field2(t, "Name") ?? "").toLowerCase() === wanted2.toLowerCase());
51907
+ }
51908
+ if (!tag) throw new RoonError(`Roon said the tag was created, but "${wanted2}" isn't in the list`);
51909
+ created = true;
51910
+ }
51911
+ if (!isExplicit(tag)) invalid(`"${field2(tag, "Name")}" is a smart tag: Roon fills it from its rules, it can't be edited by hand.`);
51912
+ if (field2(tag, "IsReadOnly") === true) invalid(`"${field2(tag, "Name")}" is read-only.`);
51913
+ const explicit = c.structArg("Sooloos.Broker.Api.EditExplicitTagParameters", [
51914
+ { name: opts.remove ? "RemoveAlbums" : "AddAlbums", propType: 23, value: refList3(albums.map((a) => a.oid)) }
51915
+ ]);
51916
+ const edit = c.structArg("Sooloos.Broker.Api.EditTagParameters", [{ name: "EditExplicitTag", propType: 23, value: explicit }]);
51917
+ const res = await c.call(
51918
+ "Library",
51919
+ "EditTag",
51920
+ [{ type: "TagBase", name: "tag" }, { type: "EditTagParameters", name: "parameters" }, { type: "ResultCallback<EditTagResult>", name: "cb_result" }],
51921
+ Buffer.concat([buildArgs([Arg.ref(tag.oid)]), edit]),
51922
+ lib
51923
+ );
51924
+ if (!res.success) throw new RoonError(`Roon refused the change to "${field2(tag, "Name")}" (${res.status})`);
51925
+ await wait(500);
51926
+ const rows = [];
51927
+ let ok = 0;
51928
+ for (const a of albums) {
51929
+ const fresh2 = await findAlbum(c, String(field2(a, "AlbumId")));
51930
+ const has = (await tagsOfAlbum(c, fresh2)).some((n) => n.toLowerCase() === wanted2.toLowerCase());
51931
+ const good = opts.remove ? !has : has;
51932
+ if (good) ok++;
51933
+ rows.push({ key: String(field2(a, "AlbumId")), title: field2(a, "Title"), tagged: has });
51934
+ }
51935
+ return {
51936
+ tag: field2(tag, "Name"),
51937
+ created: created || void 0,
51938
+ action: opts.remove ? "removed" : "added",
51939
+ albums: unique.length,
51940
+ confirmed: ok,
51941
+ ...ok < unique.length ? { note: `Roon said ok; ${unique.length - ok} album(s) didn't read back as ${opts.remove ? "untagged" : "tagged"}` } : {},
51942
+ rows
51943
+ };
51944
+ });
51945
+ }
51946
+ __name(tagAlbums, "tagAlbums");
51947
+ async function deleteTag(name, confirm) {
51948
+ if (!confirm) invalid("Deleting a tag can't be undone: pass confirm: true, after the user agreed.");
51949
+ const wanted2 = name.trim();
51950
+ if (!wanted2) invalid("A tag name, please.");
51951
+ return withCore(async (c) => {
51952
+ const tag = (await allTags(c)).find((t) => String(field2(t, "Name") ?? "").toLowerCase() === wanted2.toLowerCase());
51953
+ if (!tag) invalid(`There is no tag called "${wanted2}".`);
51954
+ if (field2(tag, "IsDeletable") === false || field2(tag, "IsReadOnly") === true) invalid(`Roon doesn't allow deleting "${field2(tag, "Name")}".`);
51955
+ const res = await c.call(
51956
+ "Library",
51957
+ "DeleteTag",
51958
+ [{ type: "TagBase", name: "tag" }, { type: "ResultCallback", name: "cb_result" }],
51959
+ buildArgs([Arg.ref(tag.oid)]),
51960
+ c.serviceOid("Library")
51961
+ );
51962
+ if (!res.success) throw new RoonError(`Roon refused to delete "${field2(tag, "Name")}" (${res.status})`);
51963
+ let gone = false;
51964
+ for (let i = 0; i < 10 && !gone; i++) {
51965
+ await wait(200);
51966
+ gone = !(await allTags(c)).some((t) => String(field2(t, "Name") ?? "").toLowerCase() === wanted2.toLowerCase());
51967
+ }
51968
+ return { tag: field2(tag, "Name"), deleted: gone, ...gone ? {} : { note: "Roon said ok, but the tag is still in the list" } };
51969
+ });
51970
+ }
51971
+ __name(deleteTag, "deleteTag");
51972
+
51790
51973
  // src/tools/library.ts
51791
51974
  init_session();
51792
51975
 
@@ -51814,7 +51997,7 @@ function writablePlaylist(c, p) {
51814
51997
  return field2(p, "Type") === 5 && (ro === false || ro === void 0 && declaredBool);
51815
51998
  }
51816
51999
  __name(writablePlaylist, "writablePlaylist");
51817
- var invalid = /* @__PURE__ */ __name((s) => {
52000
+ var invalid2 = /* @__PURE__ */ __name((s) => {
51818
52001
  throw new RoonError(s, "invalid");
51819
52002
  }, "invalid");
51820
52003
  var trackKeyValid = /* @__PURE__ */ __name((key) => /^(0|[1-9]\d{0,19})$/.test(key) && BigInt(key) <= 0xffffffffffffffffn, "trackKeyValid");
@@ -51825,12 +52008,12 @@ function revisionOf(key, name, entries) {
51825
52008
  __name(revisionOf, "revisionOf");
51826
52009
  var playlistEditOn = /* @__PURE__ */ __name(() => ["1", "true", "on", "yes"].includes((process.env.DEEP_ROON_PLAYLIST_EDIT ?? "").trim().toLowerCase()), "playlistEditOn");
51827
52010
  function enabled() {
51828
- if (readOnlyMode() !== "off") invalid("Playlist editing is disabled by DEEP_ROON_READ_ONLY.");
51829
- if (!playlistEditOn()) invalid("Playlist editing is experimental and disabled; see docs/playlist-editing.md.");
52011
+ if (readOnlyMode() !== "off") invalid2("Playlist editing is disabled by DEEP_ROON_READ_ONLY.");
52012
+ if (!playlistEditOn()) invalid2("Playlist editing is experimental and disabled; see docs/playlist-editing.md.");
51830
52013
  }
51831
52014
  __name(enabled, "enabled");
51832
52015
  async function snapshotOn(c, key, timeoutMs = 3e3) {
51833
- if (!/^(?:[0-9a-f]{2})+$/i.test(key)) invalid("Use the exact playlist key from roon_playlists.");
52016
+ if (!/^(?:[0-9a-f]{2})+$/i.test(key)) invalid2("Use the exact playlist key from roon_playlists.");
51834
52017
  const service2 = c.graph.findByType("Playlists")[0];
51835
52018
  if (!service2) throw new RoonError("No playlists service", "unavailable");
51836
52019
  const got = await c.call("Playlists", "GetPlaylist", [{ type: "Sooid", name: "id" }, { type: "ResultCallback<Playlist>", name: "cb" }], buildArgs([Arg.sooid(Buffer.from(key, "hex"))]), service2.oid);
@@ -51893,29 +52076,29 @@ var publicSnapshot = /* @__PURE__ */ __name((s) => ({
51893
52076
  }), "publicSnapshot");
51894
52077
  var playlistSnapshot = /* @__PURE__ */ __name((key) => withCore(async (c) => publicSnapshot(await snapshotOn(c, key))), "playlistSnapshot");
51895
52078
  function planEdit(s, edit) {
51896
- if (edit.confirm !== true) invalid("Explicit confirmation is required.");
51897
- if (!s.writable) invalid("Only writable native Roon playlists can be edited.");
51898
- if (s.key !== edit.key || s.revision !== edit.revision) invalid("Playlist changed since the snapshot; read a fresh snapshot and review the edit.");
52079
+ if (edit.confirm !== true) invalid2("Explicit confirmation is required.");
52080
+ if (!s.writable) invalid2("Only writable native Roon playlists can be edited.");
52081
+ if (s.key !== edit.key || s.revision !== edit.revision) invalid2("Playlist changed since the snapshot; read a fresh snapshot and review the edit.");
51899
52082
  let name = s.name;
51900
52083
  let entries = s.entries.slice();
51901
52084
  let selected = [];
51902
52085
  if (edit.action === "rename") {
51903
- if (!edit.name.trim() || edit.name.length > 500) invalid("Choose a nonempty name of at most 500 characters.");
52086
+ if (!edit.name.trim() || edit.name.length > 500) invalid2("Choose a nonempty name of at most 500 characters.");
51904
52087
  name = edit.name;
51905
52088
  } else if (edit.action === "add") {
51906
- if (!edit.keys.length || edit.keys.length > 200 || edit.keys.some((k) => !trackKeyValid(k))) invalid("Provide 1\u2013200 valid track keys.");
52089
+ if (!edit.keys.length || edit.keys.length > 200 || edit.keys.some((k) => !trackKeyValid(k))) invalid2("Provide 1\u2013200 valid track keys.");
51907
52090
  const at2 = edit.before === void 0 ? entries.length : entries.findIndex((e) => e.id === edit.before);
51908
- if (at2 < 0) invalid("Insertion anchor is no longer in the playlist.");
52091
+ if (at2 < 0) invalid2("Insertion anchor is no longer in the playlist.");
51909
52092
  entries.splice(at2, 0, ...edit.keys.map((key) => ({ id: "", key })));
51910
52093
  } else {
51911
- if (!edit.items.length || edit.items.length > 200 || new Set(edit.items).size !== edit.items.length) invalid("Provide 1\u2013200 distinct playlist item ids.");
52094
+ if (!edit.items.length || edit.items.length > 200 || new Set(edit.items).size !== edit.items.length) invalid2("Provide 1\u2013200 distinct playlist item ids.");
51912
52095
  selected = s.entries.filter((e) => edit.items.includes(e.id));
51913
- if (selected.length !== edit.items.length) invalid("A selected item is no longer in the playlist.");
52096
+ if (selected.length !== edit.items.length) invalid2("A selected item is no longer in the playlist.");
51914
52097
  entries = entries.filter((e) => !edit.items.includes(e.id));
51915
52098
  if (edit.action === "reorder") {
51916
- if (edit.before !== void 0 && edit.items.includes(edit.before)) invalid("The anchor cannot be one of the moved items.");
52099
+ if (edit.before !== void 0 && edit.items.includes(edit.before)) invalid2("The anchor cannot be one of the moved items.");
51917
52100
  const at2 = edit.before === void 0 ? entries.length : entries.findIndex((e) => e.id === edit.before);
51918
- if (at2 < 0) invalid("Move anchor is no longer in the playlist.");
52101
+ if (at2 < 0) invalid2("Move anchor is no longer in the playlist.");
51919
52102
  entries.splice(at2, 0, ...selected);
51920
52103
  }
51921
52104
  }
@@ -51935,9 +52118,9 @@ async function executeEdit(io, edit, attempts = 12) {
51935
52118
  const plan = planEdit(before, edit);
51936
52119
  if (plan.noop) return { ok: true, verified: true, unchanged: true, ...publicSnapshot(before) };
51937
52120
  if (edit.action === "add") await io.validateTracks(edit.keys);
51938
- if (edit.action === "rename" && io.nameTaken && await io.nameTaken(plan.name, before.key)) invalid(`Another playlist is already called "${plan.name}"; choose another name.`);
52121
+ if (edit.action === "rename" && io.nameTaken && await io.nameTaken(plan.name, before.key)) invalid2(`Another playlist is already called "${plan.name}"; choose another name.`);
51939
52122
  const checked = await io.read();
51940
- if (checked.revision !== before.revision || !checked.writable) invalid("Playlist changed before the write; read a fresh snapshot.");
52123
+ if (checked.revision !== before.revision || !checked.writable) invalid2("Playlist changed before the write; read a fresh snapshot.");
51941
52124
  const finalPlan = planEdit(checked, edit);
51942
52125
  let uncertain;
51943
52126
  try {
@@ -52250,6 +52433,37 @@ function registerLibraryTools(server) {
52250
52433
  inputSchema: { kind: external_exports.enum(["album", "track"]), key: external_exports.string(), on: external_exports.boolean().optional(), profile: profile2 },
52251
52434
  annotations: CHANGES
52252
52435
  }, ({ kind, key, on, profile: p }) => run(() => asProfile(p, () => listenLaterSet(kind, key, on !== false))));
52436
+ server.registerTool("roon_tags", {
52437
+ title: "Tags",
52438
+ description: "Roon's tags for the profile: name, `key`, how many items, and whether it is a `smart tag` (filled by Roon's rules, not editable). For \"which tags do I have\". The tags of one album: roon_album_tags.",
52439
+ inputSchema: { profile: profile2 },
52440
+ annotations: READ2
52441
+ }, ({ profile: p }) => run(() => asProfile(p, () => tags())));
52442
+ server.registerTool("roon_album_tags", {
52443
+ title: "Tags of an album",
52444
+ description: "The tags an album (by album `key`) carries in Roon.",
52445
+ inputSchema: { key: external_exports.string().describe("An album key."), profile: profile2 },
52446
+ annotations: READ2
52447
+ }, ({ key, profile: p }) => run(() => asProfile(p, () => albumTags(key))));
52448
+ server.registerTool("roon_tag_albums", {
52449
+ title: "Tag albums",
52450
+ description: "Put albums (album `keys`, up to 500) into a Roon tag by its `name`, or take them out with `remove: true`. `create: true` makes the tag when none has that name. Changes the library: first show the user the list of albums and the tag, and pass `confirm: true` only after they agreed. Smart tags can't be edited. Every album is read back.",
52451
+ inputSchema: {
52452
+ name: external_exports.string(),
52453
+ keys: external_exports.array(external_exports.string()).min(1).max(500),
52454
+ remove: external_exports.boolean().optional(),
52455
+ create: external_exports.boolean().optional(),
52456
+ confirm: external_exports.boolean().describe("true only after the user agreed to these albums and this tag."),
52457
+ profile: profile2
52458
+ },
52459
+ annotations: CHANGES
52460
+ }, ({ name, keys, remove, create, confirm, profile: p }) => run(() => asProfile(p, () => tagAlbums(name, keys, { remove, create, confirm: confirm === true }))));
52461
+ server.registerTool("roon_tag_delete", {
52462
+ title: "Delete a tag",
52463
+ description: "Delete a Roon tag by its `name` (the albums and tracks in it stay in the library). Can't be undone: only on an explicit request, and `confirm: true` only after the user agreed.",
52464
+ inputSchema: { name: external_exports.string(), confirm: external_exports.boolean().describe("true only after the user agreed."), profile: profile2 },
52465
+ annotations: CHANGES
52466
+ }, ({ name, confirm, profile: p }) => run(() => asProfile(p, () => deleteTag(name, confirm === true))));
52253
52467
  server.registerTool("roon_library_add", {
52254
52468
  title: "Add to the library",
52255
52469
  description: "Add a Qobuz or TIDAL album to the user's Roon library (the album `key` from a search, shelf or discography). Changes the library: only on an explicit request.",
@@ -52421,7 +52635,7 @@ var INSTRUCTIONS = `Deep Roon MCP connects to the user's own Roon Core (music pl
52421
52635
  - What plays changes all the time: read roon_now_playing afresh before describing it.
52422
52636
  - "Daily Mixes" are Roon's own (roon_mixes); the user's TIDAL mixes (My Mix 1 \u2026, My Daily Discovery) are roon_tidal_playlists with shelf my_mixes, and their tracks can be read with roon_playlist.
52423
52637
  - Unofficial: this uses Roon's internal protocol, which a Roon update can change; if a tool says so, tell the user to check for an update.`;
52424
- var LIBRARY_WRITES = /* @__PURE__ */ new Set([...PLAYLIST_WRITES, "roon_playlist_create", "roon_favorite", "roon_radio_favorite", "roon_listen_later_set", "roon_library_add", "roon_dsp_set"]);
52638
+ var LIBRARY_WRITES = /* @__PURE__ */ new Set([...PLAYLIST_WRITES, "roon_playlist_create", "roon_favorite", "roon_radio_favorite", "roon_listen_later_set", "roon_library_add", "roon_dsp_set", "roon_tag_albums", "roon_tag_delete"]);
52425
52639
  var PLAYBACK = /* @__PURE__ */ new Set([
52426
52640
  "roon_device_reset",
52427
52641
  "roon_play",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deep-roon-mcp",
3
- "version": "0.5.11",
3
+ "version": "0.5.13",
4
4
  "description": "An MCP server for Roon that reaches the parts the official API doesn't: reviews, biographies, Qobuz's and TIDAL's shelves, TIDAL's playlists, your history, search across your library and the streaming services",
5
5
  "license": "Apache-2.0",
6
6
  "author": "René Bouwmeester <21277119+renebouwmeester@users.noreply.github.com>",