deep-roon-mcp 0.4.9 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md 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.4: fifty-nine tools. Qobuz, TIDAL or both — whatever is signed in on your Core.
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.
26
26
 
27
27
  **Reading** — changes nothing in Roon:
28
28
 
@@ -80,7 +80,14 @@ Version 0.4: fifty-nine tools. Qobuz, TIDAL or both — whatever is signed in on
80
80
  | `roon_play_mix` | One of today's Daily Mixes |
81
81
  | `roon_play_radio` | A Live Radio station on a zone |
82
82
 
83
- **Changing your library or sound** — only on your request; each one reads the result back and says if Roon didn't follow:
83
+ **Changing your library or sound** — only on your request; each one reads the result back and says if Roon didn't follow.
84
+
85
+ > **A word of care.** These six tools write into your Core's library and settings through Roon's *internal* protocol —
86
+ > the same wiring Roon's own apps use, but not an API Roon Labs supports for others. Deep Roon is careful with it (one
87
+ > change at a time, read back, nothing in bulk), but a Roon update can change that wiring under it. **Keep a recent backup
88
+ > of your Roon database** (Roon › Settings › Backups) before you let an assistant change things — and if you only want to
89
+ > ask and listen, switch on **Read-only library** below: then these six tools aren't there at all.
90
+
84
91
 
85
92
  | Tool | What it does |
86
93
  |---|---|
@@ -111,6 +118,7 @@ The settings (Claude Desktop › Settings › Extensions › Deep Roon MCP):
111
118
  | Roon Core address | Empty: found on your network. Fill in the Core's address for another subnet or a private VPN (Tailscale) |
112
119
  | Essentials only | Seventeen tools instead of fifty-nine, for small models |
113
120
  | Use Roon's internal protocol | Off: only the official API — zones, playback, volume, grouping; no search, reviews, Focus or history |
121
+ | Read-only library | On: Deep Roon never changes your library — no playlists, hearts, Listen Later, library additions or DSP. Playing still works |
114
122
 
115
123
  ### Other clients
116
124
 
@@ -136,7 +144,7 @@ or by hand in `~/.codex/config.toml`:
136
144
  [mcp_servers.deep-roon]
137
145
  command = "npx"
138
146
  args = ["-y", "deep-roon-mcp"]
139
- # env = { ROON_HOST = "", DEEP_ROON_TOOLS = "", DEEP_ROON_INTERNAL = "" }
147
+ # env = { ROON_HOST = "", DEEP_ROON_TOOLS = "", DEEP_ROON_INTERNAL = "", DEEP_ROON_READ_ONLY = "" }
140
148
  ```
141
149
 
142
150
  ChatGPT on the web can't run a server on your computer — use the desktop app.
@@ -149,14 +157,15 @@ ChatGPT on the web can't run a server on your computer — use the desktop app.
149
157
  "deep-roon": {
150
158
  "command": "npx",
151
159
  "args": ["-y", "deep-roon-mcp"],
152
- "env": { "ROON_HOST": "", "DEEP_ROON_TOOLS": "", "DEEP_ROON_INTERNAL": "" }
160
+ "env": { "ROON_HOST": "", "DEEP_ROON_TOOLS": "", "DEEP_ROON_INTERNAL": "", "DEEP_ROON_READ_ONLY": "" }
153
161
  }
154
162
  }
155
163
  }
156
164
  ```
157
165
 
158
- The same three settings as environment variables: `ROON_HOST` (the Core's address, empty = find it), `DEEP_ROON_TOOLS=essentials`,
159
- `DEEP_ROON_INTERNAL=off`. Leave out what you don't need. VS Code calls the block `"servers"` instead of `"mcpServers"`.
166
+ The same settings as environment variables: `ROON_HOST` (the Core's address, empty = find it), `DEEP_ROON_TOOLS=essentials`,
167
+ `DEEP_ROON_INTERNAL=off`, `DEEP_ROON_READ_ONLY=library` (nothing changes the library; playing works) or `DEEP_ROON_READ_ONLY=all`
168
+ (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"`.
160
169
 
161
170
  Then, once, in Roon: Settings › Extensions › **Enable** next to "Deep Roon MCP". Until then the tools say so.
162
171
 
@@ -42,6 +42,7 @@ var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__
42
42
  isNodeMode || !mod || !mod.__esModule ? __defProp(target2, "default", { value: mod, enumerable: true }) : target2,
43
43
  mod
44
44
  ));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
45
46
 
46
47
  // node_modules/ajv/dist/compile/codegen/code.js
47
48
  var require_code = __commonJS({
@@ -9913,9 +9914,16 @@ async function exportPlayHistory(client2, options) {
9913
9914
  if (client2.graph.findByType("HistoryPlay").length > 0) {
9914
9915
  throw new Error("history export requires a fresh client graph with no HistoryPlay objects");
9915
9916
  }
9916
- const criteria2 = inlineStruct(
9917
- client2.remoting.defineType("Sooloos.Broker.Api.HistoryQueryCriteria", [])
9918
- );
9917
+ const dateField = /* @__PURE__ */ __name((which, d) => ({
9918
+ name: `System.DateTime? Sooloos.Broker.Api.HistoryQueryCriteria::${which}`,
9919
+ propType: 18 /* NullableDateTime */,
9920
+ value: new BinaryWriter().boolean(true).long(BigInt(d.getTime()) * 10000n + UNIX_EPOCH_TICKS | 1n << 62n).toBuffer()
9921
+ }), "dateField");
9922
+ const dates = [
9923
+ ...options.minDate ? [dateField("MinPlayDate", options.minDate)] : [],
9924
+ ...options.maxDate ? [dateField("MaxPlayDate", options.maxDate)] : []
9925
+ ];
9926
+ const criteria2 = dates.length ? client2.structArg("Sooloos.Broker.Api.HistoryQueryCriteria", dates) : inlineStruct(client2.remoting.defineType("Sooloos.Broker.Api.HistoryQueryCriteria", []));
9919
9927
  const params = client2.structArg("Sooloos.Broker.Api.VirtualQueryParameters", [
9920
9928
  {
9921
9929
  name: "int Sooloos.Broker.Api.VirtualQueryParameters::PageSize",
@@ -9957,7 +9965,12 @@ async function exportPlayHistory(client2, options) {
9957
9965
  }
9958
9966
  return plays.size;
9959
9967
  }, "harvest");
9968
+ let complete = true;
9960
9969
  for (let page = 0; page < Math.ceil(target2 / pageSize); page++) {
9970
+ if (page > 0 && (options.deadline && Date.now() > options.deadline || options.enough && options.enough(snapshots.map((x) => x.event).filter((e) => !!e)))) {
9971
+ complete = false;
9972
+ break;
9973
+ }
9961
9974
  let acquired = false;
9962
9975
  try {
9963
9976
  const retained = await client2.remoting.callMethod(
@@ -10038,7 +10051,7 @@ async function exportPlayHistory(client2, options) {
10038
10051
  events.push(snapshot.event);
10039
10052
  if (events.length >= target2) break;
10040
10053
  }
10041
- return { total, events, skipped, duplicates };
10054
+ return { total, events, skipped, duplicates, complete };
10042
10055
  } finally {
10043
10056
  client2.remoting.callMethodNoReply(queryOid, SIG_DISPOSE, Buffer.alloc(0));
10044
10057
  }
@@ -15525,7 +15538,7 @@ var require_lib2 = __commonJS({
15525
15538
  var version2;
15526
15539
  var init_package = __esm({
15527
15540
  "package.json"() {
15528
- version2 = "0.4.9";
15541
+ version2 = "0.5.1";
15529
15542
  }
15530
15543
  });
15531
15544
 
@@ -17020,6 +17033,8 @@ var init_focus = __esm({
17020
17033
  });
17021
17034
 
17022
17035
  // src/index.ts
17036
+ var index_exports = {};
17037
+ module.exports = __toCommonJS(index_exports);
17023
17038
  var import_http = __toESM(require("http"));
17024
17039
 
17025
17040
  // node_modules/zod/v3/helpers/util.js
@@ -49479,10 +49494,23 @@ init_intern();
49479
49494
  init_session();
49480
49495
  init_graph();
49481
49496
  init_library();
49482
- async function history(limit3) {
49497
+ var PAGE = 500;
49498
+ var BUDGET_MS = 45e3;
49499
+ var at = /* @__PURE__ */ __name((e) => Date.parse(e.playedAt), "at");
49500
+ async function history(limit3, offset2 = 0, before) {
49483
49501
  return withCore(async (first) => {
49484
49502
  const c = first.graph.findByType("HistoryPlay").length > 0 ? await fresh() : first;
49485
- const out = await exportPlayHistory(c, { limit: Math.min(Math.max(0, limit3), 500) });
49503
+ const n = Math.min(Math.max(0, limit3), 500), skip = Math.max(0, offset2);
49504
+ const cutoff = before ? Date.parse(before) : null;
49505
+ const all = await exportPlayHistory(c, {
49506
+ limit: skip + n,
49507
+ pageSize: PAGE,
49508
+ timeoutMs: 15e3,
49509
+ deadline: Date.now() + BUDGET_MS,
49510
+ maxDate: cutoff === null ? void 0 : new Date(cutoff)
49511
+ });
49512
+ const picked = (cutoff === null ? all.events : all.events.filter((e) => at(e) < cutoff)).slice(skip, skip + n);
49513
+ const out = { ...all, events: picked };
49486
49514
  const keys = [...new Set(out.events.map((e) => e.roonTrackId).filter((k) => !!k))].slice(0, 100);
49487
49515
  const byKey = /* @__PURE__ */ new Map();
49488
49516
  if (keys.length) {
@@ -49490,8 +49518,11 @@ async function history(limit3) {
49490
49518
  for (const t of tracks2) if (t) byKey.set(String(field2(t, "TrackId")), t);
49491
49519
  }
49492
49520
  closeSoon("after the history");
49521
+ const oldest = all.events.length ? localTime(at(all.events[all.events.length - 1])) : null;
49493
49522
  return {
49494
49523
  total: out.total ?? null,
49524
+ // When the budget ran out before the asked plays: how far back it got (a smaller offset or a later `before` helps).
49525
+ note: all.complete === false && picked.length < n ? `Roon's history is long: this reached back to ${oldest} within the time \u2014 ask with a \`before\` date to start further back.` : void 0,
49495
49526
  plays: out.events.map((e) => {
49496
49527
  const r = { at: localTime(e.playedAt), title: e.title, artist: clean(e.artist), album: e.album ?? void 0, played_pct: e.completionPct ?? void 0, track_key: e.roonTrackId ?? void 0 };
49497
49528
  const t = e.roonTrackId ? byKey.get(e.roonTrackId) : void 0;
@@ -49511,26 +49542,40 @@ __name(history, "history");
49511
49542
  async function top(what, limit3, since) {
49512
49543
  return withCore(async (first) => {
49513
49544
  const c = first.graph.findByType("HistoryPlay").length > 0 ? await fresh() : first;
49514
- const out = await exportPlayHistory(c, { limit: 2e4, timeoutMs: 8e3 });
49515
- closeSoon("after the history");
49516
49545
  const from = since ? Date.parse(since) : null;
49546
+ const out = await exportPlayHistory(c, {
49547
+ limit: Number.MAX_SAFE_INTEGER,
49548
+ pageSize: PAGE,
49549
+ timeoutMs: 15e3,
49550
+ deadline: Date.now() + BUDGET_MS,
49551
+ minDate: from === null ? void 0 : new Date(from)
49552
+ });
49553
+ closeSoon("after the history");
49517
49554
  const count = /* @__PURE__ */ new Map();
49518
49555
  let counted = 0, earliest = null;
49519
49556
  for (const e of out.events) {
49520
- const at = Date.parse(e.playedAt);
49521
- if (from && at < from) continue;
49557
+ const at2 = Date.parse(e.playedAt);
49558
+ if (from && at2 < from) continue;
49522
49559
  if (typeof e.completionPct === "number" && e.completionPct < 50) continue;
49523
49560
  counted += 1;
49524
- if (earliest === null || at < earliest) earliest = at;
49561
+ if (earliest === null || at2 < earliest) earliest = at2;
49525
49562
  const artist = clean(e.artist);
49526
49563
  const key = what === "artists" ? artist : what === "tracks" ? `${e.title}\0${artist}` : `${e.album ?? "?"}\0${artist}`;
49527
49564
  const r = count.get(key) ?? { plays: 0, last: 0, title: what === "tracks" ? e.title : void 0, album: what === "albums" ? e.album ?? void 0 : void 0, artist };
49528
49565
  r.plays += 1;
49529
- if (at > r.last) r.last = at;
49566
+ if (at2 > r.last) r.last = at2;
49530
49567
  count.set(key, r);
49531
49568
  }
49532
49569
  const rows = [...count.values()].sort((a, b) => b.plays - a.plays || b.last - a.last).slice(0, Math.min(Math.max(1, limit3), 100)).map((r) => ({ plays: r.plays, title: r.title, album: r.album, artist: r.artist, last_played: localTime(r.last) }));
49533
- return { what, plays_counted: counted, plays_in_roon: out.total ?? null, from: earliest ? localTime(earliest) : null, rows };
49570
+ const reachedAll = out.complete !== false;
49571
+ return {
49572
+ what,
49573
+ plays_counted: counted,
49574
+ plays_in_roon: out.total ?? null,
49575
+ from: earliest ? localTime(earliest) : null,
49576
+ note: reachedAll ? void 0 : `Counted back to ${earliest ? localTime(earliest) : "?"} \u2014 Roon's history goes further, but the rest didn't fit in the time. Use \`since\` for a period.`,
49577
+ rows
49578
+ };
49534
49579
  });
49535
49580
  }
49536
49581
  __name(top, "top");
@@ -49781,8 +49826,8 @@ async function playTracks(keys, zoneName, how) {
49781
49826
  const br = new BinaryReader(Uint8Array.from(rr.payload));
49782
49827
  br.integer();
49783
49828
  const total = br.flexInt();
49784
- const at = Math.max(0, field2(c.graph.getObject(q.oid), "CurrentItemIndex") ?? 0);
49785
- queued = Math.max(0, total - at);
49829
+ const at2 = Math.max(0, field2(c.graph.getObject(q.oid), "CurrentItemIndex") ?? 0);
49830
+ queued = Math.max(0, total - at2);
49786
49831
  }
49787
49832
  }
49788
49833
  return {
@@ -49900,10 +49945,10 @@ __name(queueRow, "queueRow");
49900
49945
  async function queueItemAt(c, zoneName, n) {
49901
49946
  const { z: z2, q } = queueOf(c, zoneName);
49902
49947
  const refs = await queueItems(c, q);
49903
- const at = Math.max(0, field2(c.graph.getObject(q.oid), "CurrentItemIndex") ?? 0);
49904
- const oid = refs[at + n - 1];
49905
- if (oid === void 0) throw new RoonError(`The queue of ${z2.name} has no item ${n} (${Math.max(0, refs.length - at)} from here)`, "invalid");
49906
- return { z: z2, q, oid, refs, at };
49948
+ const at2 = Math.max(0, field2(c.graph.getObject(q.oid), "CurrentItemIndex") ?? 0);
49949
+ const oid = refs[at2 + n - 1];
49950
+ 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");
49951
+ return { z: z2, q, oid, refs, at: at2 };
49907
49952
  }
49908
49953
  __name(queueItemAt, "queueItemAt");
49909
49954
  async function queueJump(zoneName, n) {
@@ -49920,22 +49965,22 @@ async function queueRemove(zoneName, ns) {
49920
49965
  return withCore(async (c) => {
49921
49966
  const { z: z2, q } = queueOf(c, zoneName);
49922
49967
  const refs = await queueItems(c, q);
49923
- const at = Math.max(0, field2(c.graph.getObject(q.oid), "CurrentItemIndex") ?? 0);
49924
- const oids = [...new Set(ns)].map((n) => refs[at + n - 1]).filter((o) => o !== void 0);
49968
+ const at2 = Math.max(0, field2(c.graph.getObject(q.oid), "CurrentItemIndex") ?? 0);
49969
+ const oids = [...new Set(ns)].map((n) => refs[at2 + n - 1]).filter((o) => o !== void 0);
49925
49970
  if (!oids.length) throw new RoonError("No such items in the queue", "invalid");
49926
49971
  c.remoting.callMethodNoReply(q.oid, formatMethodSignature("Queue", "RemoveItems", [{ type: "IEnumerable<TransportItem>", name: "items" }]), buildArgs([Arg.collection(oids.map((o) => buildArgs([Arg.ref(o)])))]));
49927
49972
  log(`queue_remove: ${z2.name} \u2212 ${oids.length} item(s)`);
49928
49973
  await wait(300);
49929
49974
  const after = await queueItems(c, q);
49930
- return { ok: true, zone: z2.name, removed: oids.length, left: Math.max(0, after.length - at) };
49975
+ return { ok: true, zone: z2.name, removed: oids.length, left: Math.max(0, after.length - at2) };
49931
49976
  });
49932
49977
  }
49933
49978
  __name(queueRemove, "queueRemove");
49934
49979
  var INSERTION = { before: 3, after: 2 };
49935
49980
  async function queueMove(zoneName, n, to, where) {
49936
49981
  return withCore(async (c) => {
49937
- const { z: z2, q, oid, refs, at } = await queueItemAt(c, zoneName, n);
49938
- const rel = refs[at + to - 1];
49982
+ const { z: z2, q, oid, refs, at: at2 } = await queueItemAt(c, zoneName, n);
49983
+ const rel = refs[at2 + to - 1];
49939
49984
  if (rel === void 0 || to === n) throw new RoonError(`The queue of ${z2.name} has no item ${to} to move next to`, "invalid");
49940
49985
  const point = INSERTION[where];
49941
49986
  const res = await c.call(
@@ -49949,7 +49994,7 @@ async function queueMove(zoneName, n, to, where) {
49949
49994
  log(`queue_move: ${z2.name} item ${n} \u2192 ${where} ${to} (point ${point})`);
49950
49995
  await wait(300);
49951
49996
  const after = await queueItems(c, q);
49952
- const now = after.indexOf(oid) - at + 1;
49997
+ const now = after.indexOf(oid) - at2 + 1;
49953
49998
  return { ok: true, zone: z2.name, moved: n, now_at: now > 0 ? now : void 0 };
49954
49999
  });
49955
50000
  }
@@ -49958,11 +50003,11 @@ async function queue2(zoneName, limit3) {
49958
50003
  return withCore(async (c) => {
49959
50004
  const { z: z2, q } = queueOf(c, zoneName);
49960
50005
  const refs = await queueItems(c, q);
49961
- const at = Math.max(0, field2(c.graph.getObject(q.oid), "CurrentItemIndex") ?? 0);
49962
- const view = refs.slice(at, at + Math.min(Math.max(1, limit3), 200));
50006
+ const at2 = Math.max(0, field2(c.graph.getObject(q.oid), "CurrentItemIndex") ?? 0);
50007
+ const view = refs.slice(at2, at2 + Math.min(Math.max(1, limit3), 200));
49963
50008
  const end = Date.now() + 2500;
49964
50009
  while (Date.now() < end && view.some((oid) => queueRow(c, oid).title === null)) await wait(50);
49965
- return { zone: z2.name, left: Math.max(0, refs.length - at), rows: view.map((oid, i) => ({ n: i + 1, now: i === 0 || void 0, ...queueRow(c, oid) })) };
50010
+ 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) })) };
49966
50011
  });
49967
50012
  }
49968
50013
  __name(queue2, "queue");
@@ -49974,8 +50019,8 @@ async function queueClear(zoneName, everything) {
49974
50019
  return { ok: true, zone: z2.name, removed: "everything" };
49975
50020
  }
49976
50021
  const refs = await queueItems(c, q);
49977
- const at = Math.max(0, field2(c.graph.getObject(q.oid), "CurrentItemIndex") ?? 0);
49978
- const after = refs.slice(at + 1);
50022
+ const at2 = Math.max(0, field2(c.graph.getObject(q.oid), "CurrentItemIndex") ?? 0);
50023
+ const after = refs.slice(at2 + 1);
49979
50024
  if (after.length) c.remoting.callMethodNoReply(
49980
50025
  q.oid,
49981
50026
  "Sooloos.Broker.Api.Queue::RemoveItems(System.Collections.Generic.IEnumerable<Sooloos.Broker.Api.TransportItem>)",
@@ -50565,10 +50610,10 @@ function registerReadTools(server, internal = true) {
50565
50610
  }, ({ category, genre, limit: n }) => run(() => radio(category, genre, n ?? 40)));
50566
50611
  reg("roon_history", {
50567
50612
  title: "Play history",
50568
- description: `What was played in Roon, newest first \u2014 Roon's own play history, with how much of each track was heard. For "most played" questions use roon_top instead of counting this.`,
50569
- inputSchema: { limit: limit(300, 30) },
50613
+ description: 'What was played in Roon, newest first \u2014 Roon\'s own play history, with how much of each track was heard. Goes back as far as Roon\'s history does: `before` (YYYY-MM-DD) gives the plays before that date (e.g. "what did I play in March 2019": before 2019-04-01), `offset` skips the newest ones. For "most played" questions use roon_top instead of counting this.',
50614
+ inputSchema: { limit: limit(300, 30), offset: external_exports.number().int().min(0).optional(), before: external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().describe("Only plays before this date (YYYY-MM-DD).") },
50570
50615
  annotations: READ
50571
- }, ({ limit: n }) => run(() => history(n ?? 30)));
50616
+ }, ({ limit: n, offset: offset2, before }) => run(() => history(n ?? 30, offset2 ?? 0, before)));
50572
50617
  reg("roon_top", {
50573
50618
  title: "Most played",
50574
50619
  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` (YYYY-MM-DD) limits the period.',
@@ -51161,8 +51206,8 @@ async function listenLater(includePlayed) {
51161
51206
  const rows = list.map((it) => {
51162
51207
  const o = obj(c, thing(it));
51163
51208
  const r = { ...o ? resultRow(c, o) : { kind: field2(it, "DataType") ?? "?" }, state: { 1: "waiting", 2: "played" }[field2(it, "State")] ?? "none" };
51164
- const at = dotnetDate(field2(it, "Timestamp"));
51165
- if (at) r.added = at;
51209
+ const at2 = dotnetDate(field2(it, "Timestamp"));
51210
+ if (at2) r.added = at2;
51166
51211
  return r;
51167
51212
  }).filter((r) => includePlayed || r.state === "waiting").sort((a, b) => String(b.added ?? "").localeCompare(String(a.added ?? ""))).map((r) => ({ ...r, added: localTime(r.added) }));
51168
51213
  return { waiting: list.filter((it) => field2(it, "State") === 1).length, rows };
@@ -51885,30 +51930,53 @@ var INSTRUCTIONS = `Deep Roon MCP connects to the user's own Roon Core (music pl
51885
51930
  - What plays changes all the time: read roon_now_playing afresh before describing it.
51886
51931
  - "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.
51887
51932
  - 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.`;
51888
- function buildServer(internal, essentials) {
51889
- const server = new McpServer({ name: "deep-roon-mcp", title: "Deep Roon MCP", version: version2, websiteUrl: "https://github.com/renebouwmeester/deep-roon-mcp" }, { instructions: INSTRUCTIONS });
51890
- if (essentials) {
51891
- const keep = /* @__PURE__ */ new Set([
51892
- "roon_status",
51893
- "roon_search",
51894
- "roon_album",
51895
- "roon_review",
51896
- "roon_bio",
51897
- "roon_artist",
51898
- "roon_zones",
51899
- "roon_now_playing",
51900
- "roon_play",
51901
- "roon_play_tracks",
51902
- "roon_control",
51903
- "roon_volume",
51904
- "roon_queue",
51905
- "roon_playlists",
51906
- "roon_play_playlist",
51907
- "roon_daily_picks",
51908
- "roon_top"
51909
- ]);
51933
+ var LIBRARY_WRITES = /* @__PURE__ */ new Set(["roon_playlist_create", "roon_favorite", "roon_radio_favorite", "roon_listen_later_set", "roon_library_add", "roon_dsp_set"]);
51934
+ var PLAYBACK = /* @__PURE__ */ new Set([
51935
+ "roon_play",
51936
+ "roon_play_tracks",
51937
+ "roon_play_radio",
51938
+ "roon_play_mix",
51939
+ "roon_play_playlist",
51940
+ "roon_control",
51941
+ "roon_seek",
51942
+ "roon_volume",
51943
+ "roon_settings",
51944
+ "roon_queue_jump",
51945
+ "roon_queue_remove",
51946
+ "roon_queue_move",
51947
+ "roon_queue_clear",
51948
+ "roon_transfer",
51949
+ "roon_group",
51950
+ "roon_ungroup",
51951
+ "roon_sleep",
51952
+ "roon_standby"
51953
+ ]);
51954
+ function buildServer(internal, essentials, readOnly = "off") {
51955
+ const instructions = readOnly === "off" ? INSTRUCTIONS : INSTRUCTIONS + (readOnly === "all" ? "\n- Read-only (set by the user): Deep Roon only looks \u2014 it can't play, queue, change a zone, or change the library. Say so when asked." : "\n- Read-only library (set by the user): Deep Roon can play and control zones, but it can't change the library, playlists, hearts, Listen Later or DSP. Say so when asked.");
51956
+ const server = new McpServer({ name: "deep-roon-mcp", title: "Deep Roon MCP", version: version2, websiteUrl: "https://github.com/renebouwmeester/deep-roon-mcp" }, { instructions });
51957
+ const essentialSet = /* @__PURE__ */ new Set([
51958
+ "roon_status",
51959
+ "roon_search",
51960
+ "roon_album",
51961
+ "roon_review",
51962
+ "roon_bio",
51963
+ "roon_artist",
51964
+ "roon_zones",
51965
+ "roon_now_playing",
51966
+ "roon_play",
51967
+ "roon_play_tracks",
51968
+ "roon_control",
51969
+ "roon_volume",
51970
+ "roon_queue",
51971
+ "roon_playlists",
51972
+ "roon_play_playlist",
51973
+ "roon_daily_picks",
51974
+ "roon_top"
51975
+ ]);
51976
+ const keep = /* @__PURE__ */ __name((name) => (!essentials || essentialSet.has(name)) && !(readOnly !== "off" && LIBRARY_WRITES.has(name)) && !(readOnly === "all" && PLAYBACK.has(name)), "keep");
51977
+ if (essentials || readOnly !== "off") {
51910
51978
  const original = server.registerTool.bind(server);
51911
- server.registerTool = (name, cfg, cb) => keep.has(name) ? original(name, cfg, cb) : void 0;
51979
+ server.registerTool = (name, cfg, cb) => keep(name) ? original(name, cfg, cb) : void 0;
51912
51980
  }
51913
51981
  registerStatusTool(server, internal);
51914
51982
  registerReadTools(server, internal);
@@ -51917,7 +51985,7 @@ function buildServer(internal, essentials) {
51917
51985
  return server;
51918
51986
  }
51919
51987
  __name(buildServer, "buildServer");
51920
- function serveHttp(spec, internal, essentials) {
51988
+ function serveHttp(spec, internal, essentials, readOnly) {
51921
51989
  const m = /^(?:(.+):)?(\d+)$/.exec(spec.trim());
51922
51990
  if (!m) {
51923
51991
  log(`DEEP_ROON_HTTP should be [host:]port, not "${spec}"`);
@@ -51942,7 +52010,7 @@ function serveHttp(spec, internal, essentials) {
51942
52010
  res.writeHead(400).end("Parse error");
51943
52011
  return;
51944
52012
  }
51945
- const server = buildServer(internal, essentials);
52013
+ const server = buildServer(internal, essentials, readOnly);
51946
52014
  const transport2 = new StreamableHTTPServerTransport({ sessionIdGenerator: void 0, enableJsonResponse: true });
51947
52015
  res.on("close", () => {
51948
52016
  transport2.close().catch(() => {
@@ -51964,14 +52032,16 @@ __name(serveHttp, "serveHttp");
51964
52032
  async function main() {
51965
52033
  const internal = !/^(off|false|0|no)$/i.test(process.env.DEEP_ROON_INTERNAL ?? "");
51966
52034
  const essentials = /^(essentials|true|1|yes)$/i.test(process.env.DEEP_ROON_TOOLS ?? process.env.DEEP_ROON_ESSENTIALS ?? "");
52035
+ const ro = (process.env.DEEP_ROON_READ_ONLY ?? "").trim().toLowerCase();
52036
+ const readOnly = ro === "all" ? "all" : /^(library|true|1|yes)$/.test(ro) ? "library" : "off";
51967
52037
  if (internal) afterFirstConnect(() => selfTest(runSelfTest));
51968
52038
  checkForUpdate().catch(() => {
51969
52039
  });
51970
- log(`${internal ? "internal protocol on" : "internal protocol OFF \u2014 official API only"}${essentials ? ", essentials" : ""}`);
52040
+ log(`${internal ? "internal protocol on" : "internal protocol OFF \u2014 official API only"}${essentials ? ", essentials" : ""}${readOnly === "off" ? "" : readOnly === "all" ? ", READ-ONLY (looks only)" : ", read-only library"}`);
51971
52041
  const httpSpec = process.env.DEEP_ROON_HTTP;
51972
- if (httpSpec) serveHttp(httpSpec, internal, essentials);
52042
+ if (httpSpec) serveHttp(httpSpec, internal, essentials, readOnly);
51973
52043
  else {
51974
- await buildServer(internal, essentials).connect(new StdioServerTransport());
52044
+ await buildServer(internal, essentials, readOnly).connect(new StdioServerTransport());
51975
52045
  log(`${version2} ready (stdio)`);
51976
52046
  process.stdin.on("close", () => {
51977
52047
  shutdown();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deep-roon-mcp",
3
- "version": "0.4.9",
3
+ "version": "0.5.1",
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>",