@slack/radar-mcp 1.12.0 → 1.13.0

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.
@@ -7,6 +7,7 @@ import { fileURLToPath } from "url";
7
7
  import { AndroidTransport, resolveAdbPath } from "../shared/android.js";
8
8
  import { planReconnect } from "../shared/stream.js";
9
9
  import { RADAR_HOST, RADAR_PORT, RADAR_VERSION, WEB_PORT_DEFAULT } from "../shared/constants.js";
10
+ import { friendlyFeatureFlagError } from "../shared/feature-flags.js";
10
11
  import { cleanupPulledDatabases, initializeDatabasePath, listDatabases, pullDatabase, pulledSize, queryDatabase, resetDbState, availableUsers, } from "../shared/db.js";
11
12
  import { listPrefsFiles, readPrefsFile, parsePrefsXml, searchPrefs, } from "../shared/prefs.js";
12
13
  import { LogSession } from "./log-session.js";
@@ -206,6 +207,10 @@ export function createServer() {
206
207
  handleDbQuery(req, res);
207
208
  return;
208
209
  }
210
+ if (url.startsWith("/flags") && req.method === "GET") {
211
+ handleFlags(req, res);
212
+ return;
213
+ }
209
214
  if (url.split("?")[0] === "/prefs" && req.method === "GET") {
210
215
  handlePrefsList(req, res);
211
216
  return;
@@ -407,7 +412,7 @@ function handleHealth(res) {
407
412
  // profile owns the socket (the app that bound first), unlike the host-side activate
408
413
  // guess in getActiveUserId() which can drift. The dashboard shows this so it never
409
414
  // claims a profile you are not actually seeing.
410
- const reply = (device, boundUserId, boundProfile) => {
415
+ const reply = (device, boundUserId, boundProfile, sources) => {
411
416
  if (replied)
412
417
  return;
413
418
  replied = true;
@@ -419,6 +424,8 @@ function handleHealth(res) {
419
424
  boundProfile: boundProfile ?? null,
420
425
  device_serial: selected?.serial ?? null,
421
426
  device_label: selected?.label ?? null,
427
+ // Capture sources the build declares on ping (seam builds only); null on older builds.
428
+ sources: sources ?? null,
422
429
  });
423
430
  };
424
431
  const probe = http.request({
@@ -443,6 +450,7 @@ function handleHealth(res) {
443
450
  const ok = up.statusCode === 200;
444
451
  let uid = null;
445
452
  let profile = null;
453
+ let sources = null;
446
454
  // Only trust the body on a 200. A device 5xx-ing with a stale ping body must NOT
447
455
  // surface a bound profile while device:false — that would let the dashboard show a
448
456
  // confident profile label for an unhealthy device.
@@ -453,12 +461,14 @@ function handleHealth(res) {
453
461
  uid = String(p.android_user_id);
454
462
  if (typeof p.profile === "string")
455
463
  profile = p.profile;
464
+ if (Array.isArray(p.sources))
465
+ sources = p.sources;
456
466
  }
457
467
  catch {
458
468
  // non-JSON / partial body: device is up but we cannot name the profile
459
469
  }
460
470
  }
461
- reply(ok, uid, profile);
471
+ reply(ok, uid, profile, sources);
462
472
  });
463
473
  up.on("error", () => reply(false));
464
474
  });
@@ -695,6 +705,47 @@ function handleDetail(req, res) {
695
705
  });
696
706
  upstream.end();
697
707
  }
708
+ // --- Feature flags (source: "flags") ---
709
+ //
710
+ // Proxy the dashboard's /flags to the device's feature-flag RadarPlugin at GET
711
+ // /api/feature_flags, forwarding the ?overridden= filter. The plugin returns the COMPLETE set
712
+ // (no paging), so nothing to inject. Response is buffered so a device error becomes a clean 200
713
+ // {error} the Feature Flags tab renders in-place rather than a half-streamed body.
714
+ //
715
+ // Device list shape: { feature_flags: [{ key, enabled, is_overridden }], total }. `enabled` is
716
+ // the effective value (override if set, else the server value). Live changes arrive separately
717
+ // as `feature_flag` frames on /api/stream (the on-device observer). Builds predating the plugin
718
+ // 404, surfaced as a friendly message client-side.
719
+ function handleFlags(req, res) {
720
+ const u = new URL(req.url ?? "", `http://localhost:${WEB_PORT}`);
721
+ const path = `/api/feature_flags${u.search}`;
722
+ const upstream = http.request({ host: RADAR_HOST, port: RADAR_PORT, path, method: "GET", timeout: 4000 }, (up) => {
723
+ let body = "";
724
+ up.on("data", (c) => (body += c));
725
+ up.on("end", () => {
726
+ try {
727
+ const j = JSON.parse(body);
728
+ if (!Array.isArray(j.feature_flags)) {
729
+ sendJson(res, 200, {
730
+ error: j.error ? friendlyFeatureFlagError(j.error) : "Unexpected response from device.",
731
+ feature_flags: [],
732
+ });
733
+ return;
734
+ }
735
+ sendJson(res, 200, j);
736
+ }
737
+ catch {
738
+ sendJson(res, 200, { error: "Could not parse device response.", feature_flags: [] });
739
+ }
740
+ });
741
+ });
742
+ upstream.on("error", () => sendJson(res, 200, { error: "Device unreachable. Is Radar armed?", feature_flags: [] }));
743
+ upstream.on("timeout", () => {
744
+ upstream.destroy();
745
+ sendJson(res, 200, { error: "Device request timed out.", feature_flags: [] });
746
+ });
747
+ upstream.end();
748
+ }
698
749
  // --- On-device SQLite browser (source: "db") ---
699
750
  //
700
751
  // These delegate to shared/db.ts (run-as + host sqlite3, read-only). Each computes its
@@ -12,10 +12,10 @@
12
12
  */
13
13
  /**
14
14
  * Sources the dashboard can read. The first six are live streams; "all" is their unified
15
- * timeline. "db" and "prefs" are read-only point-in-time browsers (not streams) and are each
16
- * handled as a distinct view.
15
+ * timeline. "db", "prefs", and "flags" are read-only point-in-time browsers (not streams) and
16
+ * are each handled as a distinct view.
17
17
  */
18
- export declare const SOURCES: readonly ["rtm", "network", "clog", "trace", "log", "all", "db", "prefs"];
18
+ export declare const SOURCES: readonly ["rtm", "network", "clog", "trace", "log", "all", "db", "prefs", "flags"];
19
19
  export type Source = (typeof SOURCES)[number];
20
20
  /** Widgets a spec may compose. */
21
21
  export declare const VIZ: readonly ["counter", "rate", "sparkline", "feed", "inspector", "graph"];
package/dist/web/spec.js CHANGED
@@ -12,10 +12,10 @@
12
12
  */
13
13
  /**
14
14
  * Sources the dashboard can read. The first six are live streams; "all" is their unified
15
- * timeline. "db" and "prefs" are read-only point-in-time browsers (not streams) and are each
16
- * handled as a distinct view.
15
+ * timeline. "db", "prefs", and "flags" are read-only point-in-time browsers (not streams) and
16
+ * are each handled as a distinct view.
17
17
  */
18
- export const SOURCES = ["rtm", "network", "clog", "trace", "log", "all", "db", "prefs"];
18
+ export const SOURCES = ["rtm", "network", "clog", "trace", "log", "all", "db", "prefs", "flags"];
19
19
  /** Widgets a spec may compose. */
20
20
  export const VIZ = [
21
21
  "counter",
@@ -50,8 +50,8 @@ export function coerceSpec(input) {
50
50
  if (!isRecord(input))
51
51
  return BLANK_SPEC;
52
52
  const s = input;
53
- // The DB and Prefs browsers have no match/viz/series to repair; leave them untouched.
54
- if (s.source === "db" || s.source === "prefs")
53
+ // The DB, Prefs, and feature-flags browsers have no match/viz/series to repair; leave as-is.
54
+ if (s.source === "db" || s.source === "prefs" || s.source === "flags")
55
55
  return s;
56
56
  if (typeof s.match === "string") {
57
57
  // "all" mixes types whose summary fields differ, so a single field guess
@@ -110,9 +110,12 @@ export function validateSpec(s) {
110
110
  }
111
111
  return null;
112
112
  }
113
- // The Prefs browser is likewise a distinct, self-contained view: no viz/series/match.
113
+ // The Prefs and feature-flags browsers are likewise distinct, self-contained views: no
114
+ // viz/series/match to validate.
114
115
  if (spec.source === "prefs")
115
116
  return null;
117
+ if (spec.source === "flags")
118
+ return null;
116
119
  if (spec.match !== undefined && !isRecord(spec.match)) {
117
120
  return "match must be an object";
118
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slack/radar-mcp",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "MCP server and web dashboard for on-device debugging of the Slack Android app via ADB",
5
5
  "type": "module",
6
6
  "main": "dist/mcp/index.js",