deep-roon-mcp 0.5.6 → 0.5.8

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: fifty-nine tools (fifty-three with a read-only library). Qobuz, TIDAL or both — whatever is signed in on your Core.
25
+ Version 0.5: sixty-one tools (fifty-five with a read-only library; sixty-five 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
 
@@ -44,6 +44,7 @@ Version 0.5: fifty-nine tools (fifty-three with a read-only library). Qobuz, TID
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 |
47
+ | `roon_profiles` | The Roon profiles, and the one Deep Roon uses |
47
48
  | `roon_library` | Your library with Roon's Focus: stars, genre, label, artist, composer, producer, years, hi-res, live … sorted any way |
48
49
  | `roon_focus` | The Focus panel: what your library (or part of it) is made of, with counts |
49
50
  | `roon_tracks`, `roon_artists` | Focus on tracks and artists (and composers) |
@@ -52,6 +53,7 @@ Version 0.5: fifty-nine tools (fifty-three with a read-only library). Qobuz, TID
52
53
  | `roon_new_for_you` | New releases Roon picked for you |
53
54
  | `roon_mixes` | Today's Daily Mixes |
54
55
  | `roon_playlists`, `roon_playlist` | Your playlists, and one playlist's tracks |
56
+ | `roon_playlist_snapshot` | One of your playlists complete, with an id for every track in it (also a track that's in it twice) — what the playlist edits below work from |
55
57
  | `roon_tidal_playlists` | TIDAL's playlists: its editorial shelves, by genre or mood, and your own TIDAL mixes |
56
58
  | `roon_favorites` | Albums with a heart in Roon, or your Qobuz or TIDAL favourites |
57
59
  | `roon_listen_later` | Your Listen Later list |
@@ -99,6 +101,19 @@ Version 0.5: fifty-nine tools (fifty-three with a read-only library). Qobuz, TID
99
101
  | `roon_dsp_set` | MUSE on or off, one part on or off, or a preset |
100
102
  | `roon_radio_favorite` | A station into My Live Radio, or out of it |
101
103
 
104
+ **Editing your own playlists** — experimental, and off until you switch on **Edit existing playlists** below
105
+ (`DEEP_ROON_PLAYLIST_EDIT=1`). Only your own Roon playlists; imported, smart, Qobuz and TIDAL playlists are refused. Each
106
+ edit starts from a fresh `roon_playlist_snapshot`, is checked once more right before it's written, and is read back in
107
+ full afterwards; if that read doesn't match, it says so and doesn't try again. With **Read-only library** on they aren't
108
+ there. Contributed by kvarnelis on GitHub.
109
+
110
+ | Tool | What it does |
111
+ |---|---|
112
+ | `roon_playlist_add_tracks` | Tracks into a playlist, at the end or before a given track |
113
+ | `roon_playlist_remove_tracks` | Tracks out of a playlist — only the ones you point at, not other copies of the same track |
114
+ | `roon_playlist_reorder_tracks` | Tracks to another place in a playlist |
115
+ | `roon_playlist_rename` | A playlist under a new name (never onto a name another playlist already has) |
116
+
102
117
  ## Install
103
118
 
104
119
  Deep Roon MCP runs on a computer on the same network as your Roon Core (Mac, Windows or Linux), next to your MCP client.
@@ -117,9 +132,10 @@ The settings (Claude Desktop › Settings › Extensions › Deep Roon MCP):
117
132
  | Setting | What it does |
118
133
  |---|---|
119
134
  | Roon Core address | Empty: found on your network. Fill in the Core's address for another subnet or a private VPN (Tailscale) |
120
- | Essentials only | Seventeen tools instead of fifty-nine, for small models |
135
+ | Essentials only | Seventeen tools instead of sixty-one, for small models |
121
136
  | Use Roon's internal protocol | Off: only the official API — zones, playback, volume, grouping; no search, reviews, Focus or history |
122
137
  | Read-only library | On: Deep Roon never changes your library — no playlists, hearts, Listen Later, library additions or DSP. Playing still works |
138
+ | Edit existing playlists | Experimental, off by default. On: the four playlist edits above |
123
139
 
124
140
  ### Other clients
125
141
 
@@ -145,7 +161,7 @@ or by hand in `~/.codex/config.toml`:
145
161
  [mcp_servers.deep-roon]
146
162
  command = "npx"
147
163
  args = ["-y", "deep-roon-mcp"]
148
- # env = { ROON_HOST = "", DEEP_ROON_TOOLS = "", DEEP_ROON_INTERNAL = "", DEEP_ROON_READ_ONLY = "" }
164
+ # env = { ROON_HOST = "", ROON_PROFILE = "", DEEP_ROON_TOOLS = "", DEEP_ROON_INTERNAL = "", DEEP_ROON_READ_ONLY = "" }
149
165
  ```
150
166
 
151
167
  ChatGPT on the web can't run a server on your computer — use the desktop app.
@@ -158,18 +174,24 @@ ChatGPT on the web can't run a server on your computer — use the desktop app.
158
174
  "deep-roon": {
159
175
  "command": "npx",
160
176
  "args": ["-y", "deep-roon-mcp"],
161
- "env": { "ROON_HOST": "", "DEEP_ROON_TOOLS": "", "DEEP_ROON_INTERNAL": "", "DEEP_ROON_READ_ONLY": "" }
177
+ "env": { "ROON_HOST": "", "ROON_PROFILE": "", "DEEP_ROON_TOOLS": "", "DEEP_ROON_INTERNAL": "", "DEEP_ROON_READ_ONLY": "" }
162
178
  }
163
179
  }
164
180
  }
165
181
  ```
166
182
 
167
- The same settings as environment variables: `ROON_HOST` (the Core's address, empty = find it), `DEEP_ROON_TOOLS=essentials`,
183
+ The same settings as environment variables: `ROON_HOST` (the Core's address, empty = find it), `ROON_PROFILE` (a Roon profile
184
+ by name, empty = the first; see below), `DEEP_ROON_TOOLS=essentials`,
168
185
  `DEEP_ROON_INTERNAL=off`, `DEEP_ROON_READ_ONLY=library` (nothing changes the library; playing works) or `DEEP_ROON_READ_ONLY=all`
169
- (Deep Roon only looks: no playing, queueing or zone changes either). Leave out what you don't need. VS Code calls the block `"servers"` instead of `"mcpServers"`.
186
+ (Deep Roon only looks: no playing, queueing or zone changes either), `DEEP_ROON_PLAYLIST_EDIT=1` (the playlist edits). Leave out what you don't need. VS Code calls the block `"servers"` instead of `"mcpServers"`.
170
187
 
171
188
  Then, once, in Roon: Settings › Extensions › **Enable** next to "Deep Roon MCP". Until then the tools say so.
172
189
 
190
+ **Roon profiles.** The play history, most played, Daily Picks, Daily Mixes, New for you, favourites and Listen Later belong to
191
+ a Roon profile. Deep Roon is a Roon remote of its own, like each Roon app, so switching profiles in a Roon app doesn't change
192
+ it: it uses `ROON_PROFILE` (or **Roon profile** in Claude Desktop's settings), else the first profile. Those tools also take
193
+ `profile` for one question ("what did Anna play this week?"); `roon_profiles` lists the names.
194
+
173
195
  ### Over HTTP
174
196
 
175
197
  For a client that can't start a program on your computer, Deep Roon MCP can serve MCP over HTTP instead (Streamable
@@ -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 invalid = 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}, ${invalid}))`);
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}))`);
5412
5412
  }
5413
5413
  };
5414
5414
  exports2.default = def;
@@ -9269,6 +9269,9 @@ var init_client = __esm({
9269
9269
  graph = new ObjectGraph();
9270
9270
  explicitProfile;
9271
9271
  cachedProfile;
9272
+ /** The profile chosen by name (7 Nov 2026, forum: "after switching profiles, roon_history still returns my first
9273
+ * profile") — see core/session.ts; unset = the explicit option, else the first Profile in the graph. */
9274
+ chosenProfile;
9272
9275
  settleMs;
9273
9276
  /** Added 8 Oct 2026: a PING every 10 s while connected (see RemotingClient.ping); stops at the first failed one —
9274
9277
  * a caller may replace conn.onclosed, so the close hook alone is not enough. */
@@ -9291,7 +9294,11 @@ var init_client = __esm({
9291
9294
  * on every other Core the server matched nothing against it, which is a big
9292
9295
  * part of why search returned no results.
9293
9296
  */
9297
+ useProfile(id) {
9298
+ this.chosenProfile = id;
9299
+ }
9294
9300
  profile() {
9301
+ if (this.chosenProfile) return this.chosenProfile;
9295
9302
  if (this.explicitProfile) return this.explicitProfile;
9296
9303
  if (this.cachedProfile) return this.cachedProfile;
9297
9304
  for (const o of this.graph.objects.values()) {
@@ -9865,9 +9872,14 @@ async function exportPlayHistory(client2, options) {
9865
9872
  if (!result.success) throw new Error(`VirtualHistoryQuery failed: ${result.status}`);
9866
9873
  const [queryOid] = readFlexLong(Uint8Array.from(result.payload), 0);
9867
9874
  try {
9875
+ let seen2 = 0;
9868
9876
  const total = await pollFor("history Count", timeoutMs, pollIntervalMs, () => {
9869
- const count = field(client2.graph.getObject(queryOid), "::Count");
9870
- if (count === void 0) return void 0;
9877
+ const q = client2.graph.getObject(queryOid);
9878
+ const count = field(q, "::Count");
9879
+ if (count === void 0) {
9880
+ if (q && !seen2) seen2 = Date.now();
9881
+ return q && Date.now() - seen2 >= 1500 ? 0 : void 0;
9882
+ }
9871
9883
  if (!Number.isSafeInteger(count) || count < 0) {
9872
9884
  throw new Error(`invalid history Count: ${String(count)}`);
9873
9885
  }
@@ -12292,7 +12304,7 @@ var require_websocket = __commonJS({
12292
12304
  var http2 = require("http");
12293
12305
  var net3 = require("net");
12294
12306
  var tls = require("tls");
12295
- var { randomBytes: randomBytes2, createHash } = require("crypto");
12307
+ var { randomBytes: randomBytes2, createHash: createHash2 } = require("crypto");
12296
12308
  var { Duplex, Readable: Readable2 } = require("stream");
12297
12309
  var { URL: URL2 } = require("url");
12298
12310
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -12976,7 +12988,7 @@ var require_websocket = __commonJS({
12976
12988
  abortHandshake(websocket, socket, "Invalid Upgrade header");
12977
12989
  return;
12978
12990
  }
12979
- const digest = createHash("sha1").update(key + GUID).digest("base64");
12991
+ const digest = createHash2("sha1").update(key + GUID).digest("base64");
12980
12992
  if (res.headers["sec-websocket-accept"] !== digest) {
12981
12993
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
12982
12994
  return;
@@ -13370,7 +13382,7 @@ var require_websocket_server = __commonJS({
13370
13382
  var EventEmitter = require("events");
13371
13383
  var http2 = require("http");
13372
13384
  var { Duplex } = require("stream");
13373
- var { createHash } = require("crypto");
13385
+ var { createHash: createHash2 } = require("crypto");
13374
13386
  var extension2 = require_extension();
13375
13387
  var PerMessageDeflate2 = require_permessage_deflate();
13376
13388
  var subprotocol2 = require_subprotocol();
@@ -13680,7 +13692,7 @@ var require_websocket_server = __commonJS({
13680
13692
  );
13681
13693
  }
13682
13694
  if (this._state > RUNNING) return abortHandshake(socket, 503);
13683
- const digest = createHash("sha1").update(key + GUID).digest("base64");
13695
+ const digest = createHash2("sha1").update(key + GUID).digest("base64");
13684
13696
  const headers = [
13685
13697
  "HTTP/1.1 101 Switching Protocols",
13686
13698
  "Upgrade: websocket",
@@ -15457,7 +15469,7 @@ var require_lib2 = __commonJS({
15457
15469
  var version2;
15458
15470
  var init_package = __esm({
15459
15471
  "package.json"() {
15460
- version2 = "0.5.6";
15472
+ version2 = "0.5.8";
15461
15473
  }
15462
15474
  });
15463
15475
 
@@ -15685,6 +15697,29 @@ var init_official = __esm({
15685
15697
  function afterFirstConnect(f) {
15686
15698
  onFirstConnect = f;
15687
15699
  }
15700
+ function asProfile(name, work2) {
15701
+ return name?.trim() ? asked.run(name.trim(), work2) : work2();
15702
+ }
15703
+ function profilesOf(c) {
15704
+ const list = [...c.graph.objects.values()].find((o) => /\.DataList<[\w.]*\.Profile>$/.test(o.typeName));
15705
+ const objs = list ? (list.fields.$items ?? []).map((r) => c.graph.getObject(r.$ref)) : [...c.graph.objects.values()].filter((o) => o.typeName.endsWith(".Profile"));
15706
+ const field3 = /* @__PURE__ */ __name((o, n) => Object.entries(o.fields).find(([k]) => k.endsWith(`::${n}`) || k === n)?.[1], "field");
15707
+ return objs.filter(Boolean).map((o) => ({ name: String(field3(o, "Name") ?? ""), id: field3(o, "ProfileId") })).filter((p) => p.name && Buffer.isBuffer(p.id));
15708
+ }
15709
+ function chooseProfile(c) {
15710
+ const name = wanted ?? (process.env.ROON_PROFILE?.trim() || void 0);
15711
+ if (!name) {
15712
+ c.useProfile(void 0);
15713
+ return;
15714
+ }
15715
+ const all = profilesOf(c), p = all.find((x) => x.name.toLowerCase() === name.toLowerCase());
15716
+ if (!p) throw new RoonError(`No Roon profile called "${name}" \u2014 the profiles: ${all.map((x) => x.name).join(", ") || "none found"}`, "invalid");
15717
+ c.useProfile(p.id);
15718
+ }
15719
+ function profileInUse(c) {
15720
+ const id = c.profile();
15721
+ return profilesOf(c).find((p) => p.id.equals(id))?.name;
15722
+ }
15688
15723
  function findTarget() {
15689
15724
  if (target) return Promise.resolve(target);
15690
15725
  finding ??= locate().finally(() => {
@@ -15765,13 +15800,17 @@ async function open3() {
15765
15800
  return c;
15766
15801
  }
15767
15802
  function withCore(work2) {
15803
+ const mine = asked.getStore();
15768
15804
  const task = queue.then(async () => {
15769
15805
  if (idleTimer) {
15770
15806
  clearTimeout(idleTimer);
15771
15807
  idleTimer = null;
15772
15808
  }
15809
+ wanted = mine;
15773
15810
  try {
15774
- return await work2(await open3());
15811
+ const c = await open3();
15812
+ chooseProfile(c);
15813
+ return await work2(c);
15775
15814
  } catch (e) {
15776
15815
  if (!(e instanceof RoonError && (e.kind === "not_found" || e.kind === "invalid"))) close("after an error");
15777
15816
  throw e;
@@ -15785,7 +15824,9 @@ function withCore(work2) {
15785
15824
  }
15786
15825
  async function fresh() {
15787
15826
  close("a fresh graph");
15788
- return open3();
15827
+ const c = await open3();
15828
+ chooseProfile(c);
15829
+ return c;
15789
15830
  }
15790
15831
  function closeSoon(reason) {
15791
15832
  close(reason);
@@ -15793,10 +15834,11 @@ function closeSoon(reason) {
15793
15834
  function shutdown() {
15794
15835
  close("shutting down");
15795
15836
  }
15796
- var IDLE_MS, INTERNAL_PORT, target, client, idleTimer, queue, onFirstConnect, finding;
15837
+ var import_node_async_hooks, IDLE_MS, INTERNAL_PORT, target, client, idleTimer, queue, onFirstConnect, asked, wanted, finding;
15797
15838
  var init_session = __esm({
15798
15839
  "src/core/session.ts"() {
15799
15840
  "use strict";
15841
+ import_node_async_hooks = require("node:async_hooks");
15800
15842
  init_intern();
15801
15843
  init_discover();
15802
15844
  init_errors();
@@ -15811,6 +15853,11 @@ var init_session = __esm({
15811
15853
  queue = Promise.resolve();
15812
15854
  onFirstConnect = null;
15813
15855
  __name(afterFirstConnect, "afterFirstConnect");
15856
+ asked = new import_node_async_hooks.AsyncLocalStorage();
15857
+ __name(asProfile, "asProfile");
15858
+ __name(profilesOf, "profilesOf");
15859
+ __name(chooseProfile, "chooseProfile");
15860
+ __name(profileInUse, "profileInUse");
15814
15861
  finding = null;
15815
15862
  __name(findTarget, "findTarget");
15816
15863
  __name(locate, "locate");
@@ -16040,11 +16087,11 @@ function signedIn(c, s) {
16040
16087
  const st = field2(o, "LoginStatus");
16041
16088
  return st === void 0 || st === 4 ? o : null;
16042
16089
  }
16043
- function streaming(c, wanted) {
16044
- if (wanted) {
16045
- const o = signedIn(c, wanted);
16046
- if (!o) throw new RoonError(`${SERVICE_NAME[wanted]} isn't signed in on this Roon Core`, "unavailable");
16047
- return { service: wanted, o };
16090
+ function streaming(c, wanted2) {
16091
+ if (wanted2) {
16092
+ const o = signedIn(c, wanted2);
16093
+ if (!o) throw new RoonError(`${SERVICE_NAME[wanted2]} isn't signed in on this Roon Core`, "unavailable");
16094
+ return { service: wanted2, o };
16048
16095
  }
16049
16096
  for (const s of ["qobuz", "tidal"]) {
16050
16097
  const o = signedIn(c, s);
@@ -16074,9 +16121,9 @@ async function search(query, limit3, kind) {
16074
16121
  return { query, rows };
16075
16122
  });
16076
16123
  }
16077
- async function section(name, limit3, offset2, genres2 = [], wanted, what = "albums") {
16124
+ async function section(name, limit3, offset2, genres2 = [], wanted2, what = "albums") {
16078
16125
  return withCore(async (c) => {
16079
- const { service: service2, o } = streaming(c, wanted);
16126
+ const { service: service2, o } = streaming(c, wanted2);
16080
16127
  const methods = SECTIONS[service2];
16081
16128
  if (!methods[name] && !(service2 === "tidal" && genres2.length)) throw new RoonError(`${SERVICE_NAME[service2]} has no shelf "${name}"; choose from ${Object.keys(methods).join(", ")}`, "invalid");
16082
16129
  if (what === "tracks" && service2 !== "tidal") throw new RoonError("Shelves of tracks are TIDAL's; Qobuz's shelves are albums", "invalid");
@@ -16161,9 +16208,9 @@ function tidalStruct(c, type, g) {
16161
16208
  { name: `string ${T}::Path`, propType: 20, value: new BinaryWriter().string(g.path).toBuffer() }
16162
16209
  ]);
16163
16210
  }
16164
- async function genres(parent, wanted) {
16211
+ async function genres(parent, wanted2) {
16165
16212
  return withCore(async (c) => {
16166
- const { service: service2, o } = streaming(c, wanted);
16213
+ const { service: service2, o } = streaming(c, wanted2);
16167
16214
  if (service2 === "tidal") {
16168
16215
  if (parent) throw new RoonError("TIDAL's genres have no sub-genres", "invalid");
16169
16216
  const [g, m] = [await tidalList(c, o, "GetGenres"), await tidalList(c, o, "GetMoods")];
@@ -16398,9 +16445,9 @@ async function bio(key, max, wiki) {
16398
16445
  };
16399
16446
  });
16400
16447
  }
16401
- async function discography(key, wanted) {
16448
+ async function discography(key, wanted2) {
16402
16449
  return withCore(async (c) => {
16403
- const { service: service2, o: q } = streaming(c, wanted);
16450
+ const { service: service2, o: q } = streaming(c, wanted2);
16404
16451
  const pv = await performer(c, key);
16405
16452
  const end = Date.now() + 1500;
16406
16453
  while (Date.now() < end && field2(c.graph.getObject(pv.$ref), "Name") === void 0) await wait(40);
@@ -16696,10 +16743,10 @@ async function focusMembers(c, f, people = ["artist", "composer", "producer"]) {
16696
16743
  }
16697
16744
  if (f.year_from && f.year_from > 1e3) m.push({ name: "MinDate", propType: 23, value: dateValue(f.year_from, 0, 0) });
16698
16745
  if (f.year_to && f.year_to > 1e3) m.push({ name: "MaxDate", propType: 23, value: dateValue(f.year_to, 12, 31) });
16699
- const wanted = [["artist", "artists", "RequirePerformers"], ["composer", "composers", "RequireComposers"], ["producer", "producers", "RequireProduction"]].filter(([p]) => people.includes(p) && f[p]);
16700
- if (wanted.length) {
16746
+ const wanted2 = [["artist", "artists", "RequirePerformers"], ["composer", "composers", "RequireComposers"], ["producer", "producers", "RequireProduction"]].filter(([p]) => people.includes(p) && f[p]);
16747
+ if (wanted2.length) {
16701
16748
  const whole = await albumInfo(c, []);
16702
- for (const [p, list, member2] of wanted) {
16749
+ for (const [p, list, member2] of wanted2) {
16703
16750
  const want = String(f[p]);
16704
16751
  const l = await panelList(c, whole, list, want);
16705
16752
  const hit = l.find((x) => String(x.name).toLowerCase() === want.toLowerCase()) ?? l[0];
@@ -50536,8 +50583,10 @@ async function runImage(work2) {
50536
50583
  __name(runImage, "runImage");
50537
50584
 
50538
50585
  // src/tools/read.ts
50586
+ init_session();
50539
50587
  var READ = { readOnlyHint: true, openWorldHint: false };
50540
50588
  var service = external_exports.enum(["qobuz", "tidal"]).optional().describe("qobuz or tidal \u2014 default: Qobuz when it is signed in in Roon, else TIDAL.");
50589
+ var profile = external_exports.string().optional().describe("A Roon profile by name (roon_profiles lists them) \u2014 default: ROON_PROFILE, else the first profile.");
50541
50590
  var limit = /* @__PURE__ */ __name((max, dflt) => external_exports.number().int().min(1).max(max).optional().describe(`How many (default ${dflt}, at most ${max}).`), "limit");
50542
50591
  function registerReadTools(server, internal = true) {
50543
50592
  const R = /* @__PURE__ */ __name((name) => internal || name === "roon_zones" || name === "roon_now_playing", "R");
@@ -50636,10 +50685,11 @@ function registerReadTools(server, internal = true) {
50636
50685
  limit: limit(500, 30),
50637
50686
  offset: external_exports.number().int().min(0).optional(),
50638
50687
  since: external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().describe("Only plays from this date on (YYYY-MM-DD)."),
50639
- before: external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().describe("Only plays before this date (YYYY-MM-DD).")
50688
+ before: external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().describe("Only plays before this date (YYYY-MM-DD)."),
50689
+ profile
50640
50690
  },
50641
50691
  annotations: READ
50642
- }, ({ limit: n, offset: offset2, since, before }) => run(() => history(n ?? 30, offset2 ?? 0, before, since)));
50692
+ }, ({ limit: n, offset: offset2, since, before, profile: p }) => run(() => asProfile(p, () => history(n ?? 30, offset2 ?? 0, before, since))));
50643
50693
  reg("roon_top", {
50644
50694
  title: "Most played",
50645
50695
  description: 'The most played albums, artists or tracks in Roon, counted over the WHOLE play history (a play counts when at least half the track was heard). Use this for "most listened" questions \u2014 don\'t tally roon_history yourself. `since` and `until` (YYYY-MM-DD) limit the period \u2014 Roon filters by date itself, however far back: "what did I play most in March 2019" is since 2019-03-01, until 2019-04-01.',
@@ -50647,10 +50697,17 @@ function registerReadTools(server, internal = true) {
50647
50697
  what: external_exports.enum(["albums", "artists", "tracks"]).optional(),
50648
50698
  limit: limit(100, 20),
50649
50699
  since: external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().describe("Only plays from this date on (YYYY-MM-DD)."),
50650
- until: external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().describe("Only plays before this date (YYYY-MM-DD).")
50700
+ until: external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().describe("Only plays before this date (YYYY-MM-DD)."),
50701
+ profile
50651
50702
  },
50652
50703
  annotations: READ
50653
- }, ({ what, limit: n, since, until }) => run(() => top(what ?? "albums", n ?? 20, since, until)));
50704
+ }, ({ what, limit: n, since, until, profile: p }) => run(() => asProfile(p, () => top(what ?? "albums", n ?? 20, since, until))));
50705
+ reg("roon_profiles", {
50706
+ title: "Roon profiles",
50707
+ description: "The profiles on this Roon Core, and the one Deep Roon uses (`in_use`). Deep Roon is a Roon remote of its own: switching profiles in a Roon app doesn't change it. The play history, most played, Daily Picks, Daily Mixes, New for you, favourites and Listen Later are per profile \u2014 those tools take `profile` (a name from here) for one question; ROON_PROFILE sets the default.",
50708
+ inputSchema: {},
50709
+ annotations: READ
50710
+ }, () => run(() => withCore(async (c) => ({ profiles: profilesOf(c).map((p) => p.name), in_use: profileInUse(c), default: process.env.ROON_PROFILE?.trim() || null }))));
50654
50711
  }
50655
50712
  __name(registerReadTools, "registerReadTools");
50656
50713
 
@@ -51044,7 +51101,12 @@ __name(findPlaylist, "findPlaylist");
51044
51101
 
51045
51102
  // src/roon/more.ts
51046
51103
  var profileObject = /* @__PURE__ */ __name((c) => {
51047
- const p = [...c.graph.objects.values()].find((o) => o.typeName.endsWith(".Profile"));
51104
+ const id = c.profile();
51105
+ const all = [...c.graph.objects.values()].filter((o) => o.typeName.endsWith(".Profile"));
51106
+ const p = all.find((o) => {
51107
+ const v = field2(o, "ProfileId");
51108
+ return Buffer.isBuffer(v) && v.equals(id);
51109
+ }) ?? all[0];
51048
51110
  if (!p) throw new RoonError("Roon gave no profile");
51049
51111
  return p;
51050
51112
  }, "profileObject");
@@ -51602,12 +51664,256 @@ async function dspSet(zoneName, s) {
51602
51664
  }
51603
51665
  __name(dspSet, "dspSet");
51604
51666
 
51667
+ // src/tools/library.ts
51668
+ init_session();
51669
+
51670
+ // src/roon/playlist-edit.ts
51671
+ var import_node_crypto = require("node:crypto");
51672
+ init_intern();
51673
+ init_serializer();
51674
+ init_signature();
51675
+ init_session();
51676
+ init_graph();
51677
+ init_library();
51678
+ function writablePlaylist(c, p) {
51679
+ const ro = field2(p, "IsReadOnly");
51680
+ const declaredBool = c.graph.types.get(p.typeId)?.members.some((m) => m.name.endsWith("::IsReadOnly") && m.propType === 2) === true;
51681
+ return field2(p, "Type") === 5 && (ro === false || ro === void 0 && declaredBool);
51682
+ }
51683
+ __name(writablePlaylist, "writablePlaylist");
51684
+ var invalid = /* @__PURE__ */ __name((s) => {
51685
+ throw new RoonError(s, "invalid");
51686
+ }, "invalid");
51687
+ var trackKeyValid = /* @__PURE__ */ __name((key) => /^(0|[1-9]\d{0,19})$/.test(key) && BigInt(key) <= 0xffffffffffffffffn, "trackKeyValid");
51688
+ var stable = /* @__PURE__ */ __name((v) => Buffer.isBuffer(v) ? v.toString("hex") : typeof v === "bigint" ? v.toString() : typeof v === "string" ? v : "", "stable");
51689
+ function revisionOf(key, name, entries) {
51690
+ return (0, import_node_crypto.createHash)("sha256").update(JSON.stringify([key, name, entries.map((e) => [e.id, e.key])])).digest("hex");
51691
+ }
51692
+ __name(revisionOf, "revisionOf");
51693
+ var playlistEditOn = /* @__PURE__ */ __name(() => ["1", "true", "on", "yes"].includes((process.env.DEEP_ROON_PLAYLIST_EDIT ?? "").trim().toLowerCase()), "playlistEditOn");
51694
+ function enabled() {
51695
+ const ro = (process.env.DEEP_ROON_READ_ONLY ?? "").trim().toLowerCase();
51696
+ if (ro && !["off", "0", "false", "no"].includes(ro)) invalid("Playlist editing is disabled by DEEP_ROON_READ_ONLY.");
51697
+ if (!playlistEditOn()) invalid("Playlist editing is experimental and disabled; see docs/playlist-editing.md.");
51698
+ }
51699
+ __name(enabled, "enabled");
51700
+ async function snapshotOn(c, key, timeoutMs = 3e3) {
51701
+ if (!/^(?:[0-9a-f]{2})+$/i.test(key)) invalid("Use the exact playlist key from roon_playlists.");
51702
+ const service2 = c.graph.findByType("Playlists")[0];
51703
+ if (!service2) throw new RoonError("No playlists service", "unavailable");
51704
+ 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);
51705
+ if (!got.success) throw new RoonError(`Cannot read playlist (${got.status})`);
51706
+ const ref = c.graph.decodeReturnValue(Uint8Array.from(got.payload));
51707
+ if (!isRef2(ref)) throw new RoonError("Playlist read returned no object");
51708
+ const end = Date.now() + timeoutMs;
51709
+ let p;
51710
+ for (; ; ) {
51711
+ p = obj(c, ref);
51712
+ if (p && field2(p, "Name") !== void 0 && playlistKey(p).toLowerCase() === key.toLowerCase()) break;
51713
+ if (Date.now() >= end) break;
51714
+ await wait(40);
51715
+ }
51716
+ if (!p || playlistKey(p).toLowerCase() !== key.toLowerCase() || typeof field2(p, "Name") !== "string") throw new RoonError("Incomplete playlist identity");
51717
+ const result = await c.call("Playlist", "GetItems", [{ type: "ResultCallback<Query<PlaylistItem>>", name: "cb" }], Buffer.alloc(0), p.oid);
51718
+ if (!result.success) throw new RoonError(`Cannot read playlist items (${result.status})`);
51719
+ const query = c.graph.decodeReturnValue(Uint8Array.from(result.payload));
51720
+ for (; ; ) {
51721
+ const q = obj(c, query);
51722
+ const f = q?.fields;
51723
+ if (f && Number.isInteger(f.$count) && f.$count >= 0 && Array.isArray(f.$items) && f.$items.length === f.$count) {
51724
+ const entries = [];
51725
+ for (const ref2 of f.$items) {
51726
+ const item = obj(c, ref2);
51727
+ const track = obj(c, field2(item, "Track"));
51728
+ const id = stable(field2(item, "PlaylistItemId"));
51729
+ const trackKey = stable(field2(track, "TrackId"));
51730
+ if (!item || typeof item.oid !== "bigint" || !id || !trackKeyValid(trackKey)) break;
51731
+ entries.push({ id, key: trackKey, oid: item.oid });
51732
+ }
51733
+ const count = field2(p, "ItemCount");
51734
+ if (entries.length === f.$count && count === entries.length && new Set(entries.map((e) => e.id)).size === entries.length) {
51735
+ const name = field2(p, "Name");
51736
+ const canonicalKey2 = playlistKey(p);
51737
+ return {
51738
+ key: canonicalKey2,
51739
+ name,
51740
+ entries,
51741
+ oid: p.oid,
51742
+ service: service2.oid,
51743
+ writable: writablePlaylist(c, p),
51744
+ revision: revisionOf(canonicalKey2, name, entries)
51745
+ };
51746
+ }
51747
+ }
51748
+ if (Date.now() >= end) break;
51749
+ await wait(40);
51750
+ }
51751
+ throw new RoonError("Playlist membership is incomplete; no edit was attempted.");
51752
+ }
51753
+ __name(snapshotOn, "snapshotOn");
51754
+ var publicSnapshot = /* @__PURE__ */ __name((s) => ({
51755
+ key: s.key,
51756
+ name: s.name,
51757
+ revision: s.revision,
51758
+ writable: s.writable,
51759
+ total: s.entries.length,
51760
+ items: s.entries.map(({ id, key }, i) => ({ n: i + 1, id, key }))
51761
+ }), "publicSnapshot");
51762
+ var playlistSnapshot = /* @__PURE__ */ __name((key) => withCore(async (c) => publicSnapshot(await snapshotOn(c, key))), "playlistSnapshot");
51763
+ function planEdit(s, edit) {
51764
+ if (edit.confirm !== true) invalid("Explicit confirmation is required.");
51765
+ if (!s.writable) invalid("Only writable native Roon playlists can be edited.");
51766
+ if (s.key !== edit.key || s.revision !== edit.revision) invalid("Playlist changed since the snapshot; read a fresh snapshot and review the edit.");
51767
+ let name = s.name;
51768
+ let entries = s.entries.slice();
51769
+ let selected = [];
51770
+ if (edit.action === "rename") {
51771
+ if (!edit.name.trim() || edit.name.length > 500) invalid("Choose a nonempty name of at most 500 characters.");
51772
+ name = edit.name;
51773
+ } else if (edit.action === "add") {
51774
+ if (!edit.keys.length || edit.keys.length > 200 || edit.keys.some((k) => !trackKeyValid(k))) invalid("Provide 1\u2013200 valid track keys.");
51775
+ const at2 = edit.before === void 0 ? entries.length : entries.findIndex((e) => e.id === edit.before);
51776
+ if (at2 < 0) invalid("Insertion anchor is no longer in the playlist.");
51777
+ entries.splice(at2, 0, ...edit.keys.map((key) => ({ id: "", key })));
51778
+ } else {
51779
+ if (!edit.items.length || edit.items.length > 200 || new Set(edit.items).size !== edit.items.length) invalid("Provide 1\u2013200 distinct playlist item ids.");
51780
+ selected = s.entries.filter((e) => edit.items.includes(e.id));
51781
+ if (selected.length !== edit.items.length) invalid("A selected item is no longer in the playlist.");
51782
+ entries = entries.filter((e) => !edit.items.includes(e.id));
51783
+ if (edit.action === "reorder") {
51784
+ if (edit.before !== void 0 && edit.items.includes(edit.before)) invalid("The anchor cannot be one of the moved items.");
51785
+ const at2 = edit.before === void 0 ? entries.length : entries.findIndex((e) => e.id === edit.before);
51786
+ if (at2 < 0) invalid("Move anchor is no longer in the playlist.");
51787
+ entries.splice(at2, 0, ...selected);
51788
+ }
51789
+ }
51790
+ const anchor2 = "before" in edit && edit.before !== void 0 ? s.entries.find((e) => e.id === edit.before) : void 0;
51791
+ const noop = name === s.name && JSON.stringify(entries.map((e) => [e.id, e.key])) === JSON.stringify(s.entries.map((e) => [e.id, e.key]));
51792
+ return { name, entries, selected, anchor: anchor2, noop };
51793
+ }
51794
+ __name(planEdit, "planEdit");
51795
+ function matchesPlan(after, before, plan) {
51796
+ if (after.key !== before.key || after.name !== plan.name || after.entries.length !== plan.entries.length) return false;
51797
+ const oldIds = new Set(before.entries.map((e) => e.id));
51798
+ return after.entries.every((e, i) => e.key === plan.entries[i].key && (plan.entries[i].id ? e.id === plan.entries[i].id : !oldIds.has(e.id)));
51799
+ }
51800
+ __name(matchesPlan, "matchesPlan");
51801
+ async function executeEdit(io, edit, attempts = 12) {
51802
+ const before = await io.read();
51803
+ const plan = planEdit(before, edit);
51804
+ if (plan.noop) return { ok: true, verified: true, unchanged: true, ...publicSnapshot(before) };
51805
+ if (edit.action === "add") await io.validateTracks(edit.keys);
51806
+ if (edit.action === "rename" && io.nameTaken && await io.nameTaken(plan.name, before.key)) invalid(`Another playlist is already called "${plan.name}"; choose another name.`);
51807
+ const checked = await io.read();
51808
+ if (checked.revision !== before.revision || !checked.writable) invalid("Playlist changed before the write; read a fresh snapshot.");
51809
+ const finalPlan = planEdit(checked, edit);
51810
+ let uncertain;
51811
+ try {
51812
+ await io.write(checked, finalPlan, edit);
51813
+ } catch (e) {
51814
+ uncertain = e;
51815
+ }
51816
+ let after;
51817
+ for (let i = 0; i < attempts; i++) {
51818
+ try {
51819
+ after = await io.read();
51820
+ if (matchesPlan(after, checked, finalPlan)) return {
51821
+ ok: true,
51822
+ verified: true,
51823
+ ...publicSnapshot(after),
51824
+ note: uncertain ? "The write response was uncertain; a fresh read verified the exact requested result." : void 0
51825
+ };
51826
+ } catch {
51827
+ }
51828
+ if (i + 1 < attempts) await io.pause();
51829
+ }
51830
+ return {
51831
+ ok: false,
51832
+ verified: false,
51833
+ outcome: "uncertain",
51834
+ key: edit.key,
51835
+ note: "The requested result could not be verified. Do not retry automatically. Read a fresh snapshot and inspect Roon before another edit.",
51836
+ observed: after ? publicSnapshot(after) : void 0
51837
+ };
51838
+ }
51839
+ __name(executeEdit, "executeEdit");
51840
+ async function writeOn(c, s, p, edit) {
51841
+ const selected = Arg.collection(p.selected.map((e) => buildArgs([Arg.ref(e.oid)])));
51842
+ const at2 = [Arg.enum_(p.anchor ? 3 : 1), Arg.ref(p.anchor?.oid ?? 0n)];
51843
+ const playlist2 = { type: "Playlist", name: "playlist" };
51844
+ const collection = { type: "IEnumerable<PlaylistItem>", name: "items" };
51845
+ const where = [{ type: "InsertionPoint", name: "insertionpoint" }, { type: "PlaylistItem", name: "relative_to_item" }];
51846
+ if (edit.action === "remove") {
51847
+ c.remoting.callMethodNoReply(s.service, formatMethodSignature("Playlists", "RemoveItems", [playlist2, collection]), buildArgs([Arg.ref(s.oid), selected]));
51848
+ return;
51849
+ }
51850
+ const method = edit.action === "add" ? "InsertMedia" : edit.action === "reorder" ? "MoveItems" : "Rename";
51851
+ const params = edit.action === "add" ? [playlist2, { type: "IEnumerable<long>", name: "mediaids" }, ...where, { type: "ResultCallback<PlaylistInsertionResult>", name: "cb" }] : edit.action === "reorder" ? [playlist2, collection, ...where, { type: "ResultCallback", name: "cb" }] : [playlist2, { type: "string", name: "name" }, { type: "bool", name: "overwrite_on_duplicate_name" }, { type: "ResultCallback", name: "cb" }];
51852
+ const args = edit.action === "add" ? [Arg.ref(s.oid), Arg.collection(edit.keys.map((k) => buildArgs([Arg.long(BigInt(k))]))), ...at2] : edit.action === "reorder" ? [Arg.ref(s.oid), selected, ...at2] : [Arg.ref(s.oid), Arg.str(edit.name), Arg.bool(false)];
51853
+ const result = await c.call("Playlists", method, params, buildArgs(args), s.service);
51854
+ if (!result.success) throw new RoonError(`Roon refused playlist edit (${result.status}); checking the saved result.`);
51855
+ }
51856
+ __name(writeOn, "writeOn");
51857
+ var playlistEdit = /* @__PURE__ */ __name((edit) => {
51858
+ enabled();
51859
+ return withCore((c) => executeEdit({
51860
+ read: /* @__PURE__ */ __name(() => snapshotOn(c, edit.key), "read"),
51861
+ validateTracks: /* @__PURE__ */ __name((keys) => findTracks(c, keys), "validateTracks"),
51862
+ write: /* @__PURE__ */ __name((s, p, e) => writeOn(c, s, p, e), "write"),
51863
+ pause: /* @__PURE__ */ __name(() => wait(150), "pause"),
51864
+ nameTaken: /* @__PURE__ */ __name(async (name, key) => allPlaylists(c).list.some((p) => playlistKey(p).toLowerCase() !== key.toLowerCase() && String(field2(p, "Name") ?? "").trim().toLowerCase() === name.trim().toLowerCase()), "nameTaken")
51865
+ }, edit));
51866
+ }, "playlistEdit");
51867
+
51868
+ // src/tools/playlist-edit.ts
51869
+ var PLAYLIST_WRITES = ["roon_playlist_add_tracks", "roon_playlist_remove_tracks", "roon_playlist_reorder_tracks", "roon_playlist_rename"];
51870
+ function registerPlaylistEditTools(server) {
51871
+ server.registerTool("roon_playlist_snapshot", {
51872
+ title: "Complete playlist snapshot",
51873
+ description: "Read a complete playlist by exact key from roon_playlists. Returns a revision and an id for each track occurrence, including duplicates. Use these for edits; display row numbers and track keys do not identify occurrences.",
51874
+ inputSchema: { key: external_exports.string().min(1) },
51875
+ annotations: { readOnlyHint: true, openWorldHint: false }
51876
+ }, ({ key }) => run(() => playlistSnapshot(key)));
51877
+ if (!playlistEditOn()) return;
51878
+ const common = { key: external_exports.string().min(1), revision: external_exports.string().regex(/^[a-f0-9]{64}$/), confirm: external_exports.literal(true) };
51879
+ const items2 = external_exports.array(external_exports.string().min(1)).min(1).max(200);
51880
+ const before = external_exports.string().min(1).optional().describe("Insert before this occurrence id; omit to place at the end.");
51881
+ const annotations = { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false };
51882
+ const safety = " Experimental: only on an explicit user request. Requires a fresh roon_playlist_snapshot revision and confirm:true. Native writable Roon playlists only. Verifies the entire saved result. If uncertain, inspect Roon and read a fresh snapshot; never retry automatically.";
51883
+ server.registerTool("roon_playlist_add_tracks", {
51884
+ title: "Add playlist tracks",
51885
+ description: "Add track keys in the given order, retaining duplicates." + safety,
51886
+ inputSchema: { ...common, keys: external_exports.array(external_exports.string().regex(/^-?\d+$/)).min(1).max(200), before },
51887
+ annotations
51888
+ }, (args) => run(() => playlistEdit({ ...args, action: "add" })));
51889
+ server.registerTool("roon_playlist_remove_tracks", {
51890
+ title: "Remove playlist occurrences",
51891
+ description: "Remove only the selected occurrence ids. Other copies of the same track remain." + safety,
51892
+ inputSchema: { ...common, items: items2 },
51893
+ annotations
51894
+ }, (args) => run(() => playlistEdit({ ...args, action: "remove" })));
51895
+ server.registerTool("roon_playlist_reorder_tracks", {
51896
+ title: "Move playlist occurrences",
51897
+ description: "Move selected occurrence ids before an anchor or to the end, preserving their original relative order." + safety,
51898
+ inputSchema: { ...common, items: items2, before },
51899
+ annotations
51900
+ }, (args) => run(() => playlistEdit({ ...args, action: "reorder" })));
51901
+ server.registerTool("roon_playlist_rename", {
51902
+ title: "Rename a playlist",
51903
+ description: "Rename without overwriting another playlist with the same name." + safety,
51904
+ inputSchema: { ...common, name: external_exports.string().min(1).max(500) },
51905
+ annotations
51906
+ }, (args) => run(() => playlistEdit({ ...args, action: "rename" })));
51907
+ }
51908
+ __name(registerPlaylistEditTools, "registerPlaylistEditTools");
51909
+
51605
51910
  // src/tools/library.ts
51606
51911
  var READ2 = { readOnlyHint: true, openWorldHint: false };
51607
51912
  var PLAYS2 = { readOnlyHint: false, destructiveHint: false, openWorldHint: false };
51608
51913
  var CHANGES = { readOnlyHint: false, destructiveHint: true, openWorldHint: false };
51609
51914
  var zone2 = external_exports.string().describe("A Roon zone name (see roon_zones).");
51610
51915
  var mode2 = external_exports.enum(["now", "next", "queue"]).optional().describe("now (default), next, or queue (at the end).");
51916
+ var profile2 = external_exports.string().optional().describe("A Roon profile by name (roon_profiles lists them) \u2014 default: ROON_PROFILE, else the first profile.");
51611
51917
  var limit2 = /* @__PURE__ */ __name((max, dflt) => external_exports.number().int().min(1).max(max).optional().describe(`How many (default ${dflt}, at most ${max}).`), "limit");
51612
51918
  var offset = external_exports.number().int().min(0).optional().describe("Paging: where to start (in steps of `limit`).");
51613
51919
  var days = external_exports.number().int().min(1).optional();
@@ -51718,33 +52024,34 @@ function registerLibraryTools(server) {
51718
52024
  server.registerTool("roon_daily_picks", {
51719
52025
  title: "Daily Picks",
51720
52026
  description: 'Roon\'s Daily Picks from the Home screen \u2014 today\'s personal recommendations, in boxes. Each box has its `kind`, its `reason` (new_release; recent = from what was played lately; all_time = from long-term listening) and `because_you_played` \u2014 the album the box is built on \u2014 plus the recommended albums with a `key`. `limit` is per box (default 8). THE tool for "what does Roon recommend today", "my daily picks".',
51721
- inputSchema: { limit: limit2(30, 8) },
52027
+ inputSchema: { limit: limit2(30, 8), profile: profile2 },
51722
52028
  annotations: READ2
51723
- }, ({ limit: n }) => run(() => dailyPicks(n ?? 8)));
52029
+ }, ({ limit: n, profile: p }) => run(() => asProfile(p, () => dailyPicks(n ?? 8))));
51724
52030
  server.registerTool("roon_mix", {
51725
52031
  title: "A Daily Mix's tracks",
51726
52032
  description: "The tracks inside one of Roon's Daily Mixes (by `key` or name from roon_mixes), as Roon's mix page shows them before playing \u2014 each with a `key` for roon_play_tracks. To play the whole mix, roon_play_mix.",
51727
- inputSchema: { key: external_exports.string().describe("A mix key or its name, from roon_mixes."), limit: limit2(300, 100) },
52033
+ inputSchema: { key: external_exports.string().describe("A mix key or its name, from roon_mixes."), limit: limit2(300, 100), profile: profile2 },
51728
52034
  annotations: READ2
51729
- }, ({ key, limit: n }) => run(() => mix(key, n ?? 100)));
52035
+ }, ({ key, limit: n, profile: p }) => run(() => asProfile(p, () => mix(key, n ?? 100))));
51730
52036
  server.registerTool("roon_new_for_you", {
51731
52037
  title: "New releases for you",
51732
52038
  description: '"New releases for you" from Roon\'s Home: new albums Roon picked for this user, from the artists and music they listen to \u2014 personal, unlike roon_new (the streaming services\' editorial shelf, the same for everyone). Use it for "my new releases", "what\'s new for me". Albums carry year, format, `genres`, sometimes a `review`, and a `key`; `genres` at the top counts the shelf\'s top-level genres (the choices for `genre`).',
51733
- inputSchema: { limit: limit2(100, 30), offset, genre: external_exports.string().optional().describe("Only albums of this genre (a Roon genre name, e.g. Jazz; sub-genres match too).") },
52039
+ inputSchema: { limit: limit2(100, 30), offset, genre: external_exports.string().optional().describe("Only albums of this genre (a Roon genre name, e.g. Jazz; sub-genres match too)."), profile: profile2 },
51734
52040
  annotations: READ2
51735
- }, ({ limit: n, offset: o, genre }) => run(() => newForYou(n ?? 30, o ?? 0, genre)));
52041
+ }, ({ limit: n, offset: o, genre, profile: p }) => run(() => asProfile(p, () => newForYou(n ?? 30, o ?? 0, genre))));
51736
52042
  server.registerTool("roon_mixes", {
51737
52043
  title: "Daily Mixes",
51738
52044
  description: 'Roon\'s own Daily Mixes, from Roon\'s Home \u2014 NOT TIDAL\'s mixes: for "TIDAL mixes", "My Mix", "My Daily Discovery" or TIDAL\'s daily mixes use roon_tidal_playlists with `shelf: "my_mixes"`. These are today\'s personal Roon mixes, each built around an artist (or genre) the user listens to, with a few `touchstones` and a `key` for roon_play_mix. They change every day.',
51739
- inputSchema: {},
52045
+ inputSchema: { profile: profile2 },
51740
52046
  annotations: READ2
51741
- }, () => run(() => mixes()));
52047
+ }, ({ profile: p }) => run(() => asProfile(p, () => mixes())));
51742
52048
  server.registerTool("roon_play_mix", {
51743
52049
  title: "Play a Daily Mix",
51744
52050
  description: "Play one of today's Daily Mixes on a Roon zone (`key` from roon_mixes, or the mix's name). `mode`: now (default), next or queue. Only on an explicit request, never as a probe.",
51745
52051
  inputSchema: { key: external_exports.string(), zone: zone2, mode: mode2 },
51746
52052
  annotations: PLAYS2
51747
52053
  }, ({ key, zone: zn, mode: m }) => run(() => playMix(key, zn, m ?? "now")));
52054
+ registerPlaylistEditTools(server);
51748
52055
  server.registerTool("roon_playlists", {
51749
52056
  title: "Playlists",
51750
52057
  description: "The playlists in the user's Roon: their own Roon playlists, Qobuz and TIDAL playlists they added, and editorial ones \u2014 each with a `key` for roon_playlist and roon_play_playlist, the number of tracks, and whether it is read-only.",
@@ -51784,9 +52091,9 @@ function registerLibraryTools(server) {
51784
52091
  server.registerTool("roon_favorites", {
51785
52092
  title: "Favourite albums",
51786
52093
  description: 'The user\'s favourite albums: `source: "roon"` (default) are the albums with a heart in Roon, newest first; `source: "qobuz"` or `"tidal"` the favourites at that service. Albums carry a `key`.',
51787
- inputSchema: { source: external_exports.enum(["roon", "qobuz", "tidal"]).optional(), limit: limit2(100, 50) },
52094
+ inputSchema: { source: external_exports.enum(["roon", "qobuz", "tidal"]).optional(), limit: limit2(100, 50), profile: profile2 },
51788
52095
  annotations: READ2
51789
- }, ({ source, limit: n }) => run(() => favorites(source ?? "roon", n ?? 50)));
52096
+ }, ({ source, limit: n, profile: p }) => run(() => asProfile(p, () => favorites(source ?? "roon", n ?? 50))));
51790
52097
  server.registerTool("roon_radio_favorite", {
51791
52098
  title: "A station in My Live Radio",
51792
52099
  description: "Put a Live Radio station in the user's own list (My Live Radio), or take it out (`on: false`). The `key` comes from roon_radio. Changes the user's library: only on an explicit request. Reads the result back.",
@@ -51802,9 +52109,9 @@ function registerLibraryTools(server) {
51802
52109
  server.registerTool("roon_listen_later", {
51803
52110
  title: "Listen Later",
51804
52111
  description: "The user's Listen Later list in Roon: the albums (and tracks) marked to hear later, newest first, each with a `key`. By default only what still waits; `include_played: true` adds what has been heard since.",
51805
- inputSchema: { include_played: external_exports.boolean().optional() },
52112
+ inputSchema: { include_played: external_exports.boolean().optional(), profile: profile2 },
51806
52113
  annotations: READ2
51807
- }, ({ include_played }) => run(() => listenLater(include_played === true)));
52114
+ }, ({ include_played, profile: p }) => run(() => asProfile(p, () => listenLater(include_played === true))));
51808
52115
  server.registerTool("roon_listen_later_set", {
51809
52116
  title: "Listen Later: add or remove",
51810
52117
  description: "Put an album or a track on the Listen Later list in Roon, or take it off (`on: false`) \u2014 the natural thing to offer after recommending something the user can't hear right now. Changes the library: only on an explicit request. Reads it back.",
@@ -51846,7 +52153,7 @@ function registerLibraryTools(server) {
51846
52153
  description: "Switch MUSE (Roon's DSP) on a zone: `enabled` turns the whole DSP on or off; `part` + `enabled` turns one part on or off (names from roon_dsp); `preset` loads a saved preset by name. This changes how the zone SOUNDS: only on an explicit request, one change at a time, after reading roon_dsp. It doesn't edit EQ bands or other values. Reads it back.",
51847
52154
  inputSchema: { zone: zone2, enabled: external_exports.boolean().optional(), part: external_exports.string().optional(), preset: external_exports.string().optional() },
51848
52155
  annotations: CHANGES
51849
- }, ({ zone: zn, enabled, part, preset }) => run(() => dspSet(zn, { enabled, part, preset })));
52156
+ }, ({ zone: zn, enabled: enabled2, part, preset }) => run(() => dspSet(zn, { enabled: enabled2, part, preset })));
51850
52157
  }
51851
52158
  __name(registerLibraryTools, "registerLibraryTools");
51852
52159
 
@@ -51964,7 +52271,7 @@ var INSTRUCTIONS = `Deep Roon MCP connects to the user's own Roon Core (music pl
51964
52271
  - What plays changes all the time: read roon_now_playing afresh before describing it.
51965
52272
  - "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.
51966
52273
  - 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.`;
51967
- var LIBRARY_WRITES = /* @__PURE__ */ new Set(["roon_playlist_create", "roon_favorite", "roon_radio_favorite", "roon_listen_later_set", "roon_library_add", "roon_dsp_set"]);
52274
+ 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"]);
51968
52275
  var PLAYBACK = /* @__PURE__ */ new Set([
51969
52276
  "roon_play",
51970
52277
  "roon_play_tracks",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deep-roon-mcp",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
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>",
@@ -37,7 +37,8 @@
37
37
  "build": "node scripts/build.mjs",
38
38
  "start": "node dist/deep-roon-mcp.js",
39
39
  "bundle": "node scripts/bundle.mjs",
40
- "prepublishOnly": "node scripts/build.mjs"
40
+ "prepublishOnly": "node scripts/build.mjs",
41
+ "test": "node scripts/test.mjs"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@anthropic-ai/mcpb": "^2.1.2",