@slack/radar-mcp 1.3.0 → 1.4.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.
package/dist/mcp/tools.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { SOURCES, VIZ, SERIES_METRICS } from "../web/spec.js";
1
2
  export const SERVER_INSTRUCTIONS = [
2
3
  "Slack Radar provides on-device debugging tools for the Slack Android app via ADB.",
3
4
  "",
@@ -31,24 +32,59 @@ export const SERVER_INSTRUCTIONS = [
31
32
  "- RTM event types use subtypes when available (e.g. message_changed, not message).",
32
33
  "- Use wait_for_events with idle_timeout_ms instead of polling loops.",
33
34
  "- Use ping(timeout_minutes=N) to extend sessions. Monitor remaining_minutes proactively.",
35
+ "- ping reports which app/profile is bound (android_user_id, profile, package). The debug",
36
+ " build can run on more than one user (personal=0, plus a work profile or secondary user),",
37
+ " and only the first to bind the socket wins. If events seem to come from the wrong app, tell",
38
+ " the user which profile is bound and use list_profiles + activate_for_user to switch.",
34
39
  "- Screenshots default to 720px. Use full_res=true only when detail matters.",
35
40
  "- Setup: /slack-radar-setup",
36
41
  "- Manual enable (no skill): adb shell am broadcast -a slack.debug.ENABLE_RADAR --ei timeout_minutes 5 -p com.Slack.internal.debug",
37
42
  " Then: adb forward tcp:8099 localabstract:slack-radar",
38
43
  "",
39
44
  "WEB DASHBOARD (/radar-ui):",
40
- "A browser-based dashboard (http://localhost:8100) shows the same live device data in a",
41
- "visual UI. Launched via the /radar-ui skill, which wraps `npx -p @slack/radar-mcp slack-radar-web`.",
45
+ "A browser-based dashboard (http://localhost:8100) shows the same live device data as",
46
+ "tabs: Live (everything), Network, RTM, Clogs, and Logs, each with counters, a graph, a",
47
+ "filterable feed, and a payload inspector. Launched via the /radar-ui skill, which runs",
48
+ "`npx @slack/radar-mcp web` (a global install also exposes it as `slack-radar`).",
42
49
  "",
43
- "When to suggest /radar-ui (mention it ONCE per thread, do not auto-invoke):",
50
+ "PROACTIVELY offer the dashboard when it would help do not wait to be asked. The moment a",
51
+ "device session turns visual or multi-step, say so and offer to open it, e.g.: \"This is",
52
+ "easier to watch live — want me to open the Radar dashboard?\" Offer (once per thread) when:",
44
53
  '- User says "watch", "monitor", "let me see", "show me live" about device traffic',
45
54
  "- User wants to share traffic with a colleague, pair, or teammate",
46
55
  "- User is doing a multi-minute investigation and the transcript is getting noisy",
47
56
  '- User explicitly asks about a GUI, UI, browser view, or dashboard',
48
57
  "",
49
- "DO NOT invoke /radar-ui yourself. Opening a browser window is a user-visible action.",
50
- "DO NOT suggest /radar-ui for single-query debugging or when the user is happy reading",
51
- "results in the transcript. Suggest it when visual inspection adds real value.",
58
+ "OFFER, then open ONLY AFTER THE USER AGREES — opening a browser window is a user-visible",
59
+ "action; never pop one unbidden. On a yes, run the /radar-ui skill (or tell them to run",
60
+ "`npx @slack/radar-mcp web`) and hand over the URL. Nudge, do not auto-open.",
61
+ "DO NOT offer for single-query debugging or when the user is happy reading results in the",
62
+ "transcript. Offer when visual inspection adds real value.",
63
+ "",
64
+ "CUSTOM DASHBOARD (open_radar_dashboard):",
65
+ "The pre-built tabs (Live/Network/RTM/Clogs/Logs) cover the common cases. When the user",
66
+ "describes a live view the tabs do not show, SUGGEST building it; invoke open_radar_dashboard",
67
+ "only after they agree or explicitly ask for a custom view/dashboard (same discipline as",
68
+ "/radar-ui). To build, translate their words into a spec and call the tool; it renders your",
69
+ "spec as a 'Custom' tab on the dashboard (default http://localhost:8100) and returns the URL",
70
+ "for you to share. Cases worth suggesting it for:",
71
+ '- "graph calls per second vs average response time and flag the slow ones"',
72
+ '- "count every DM I receive and beep when one arrives"',
73
+ '- "show only RTM events on channel C... and let me click each for its payload"',
74
+ '- "watch network calls whose body contains <substring>"',
75
+ "Authoring rules:",
76
+ "- source is one of network/rtm/clog/log/all ('all' = one unified timeline).",
77
+ "- match filters on SUMMARY fields only, by source: network=url/method/status_code,",
78
+ " rtm=event_type/direction/channel, clog=event_name, log=tag/level/message/pid/package.",
79
+ " NEVER invent a field; a match on a field the stream does not carry silently matches",
80
+ " nothing. To filter on body text use bodyContains (network/all only), which fetches detail.",
81
+ "- viz composes counter/rate/sparkline/feed/inspector/graph. graph needs a series array",
82
+ " (1-2 entries; metric ratePerSec/count/avg/errorRate; avg needs a field like duration_ms).",
83
+ "- highlight {field, op, value} flags rows breaching a numeric threshold; alert {sound,flash,",
84
+ " say, at} fires on each live match (or once at the Nth). Author an honest one-line `summary`.",
85
+ "Calling it again replaces/refines the live custom dashboard. The dashboard reads a connected",
86
+ "device, so Radar must be armed to show data (it has its own Reconnect button). Debug builds",
87
+ "only; local only. Does not open a browser window for you; surface the returned URL to the user.",
52
88
  "",
53
89
  "CAPTURE_SNAPSHOT OUTPUT:",
54
90
  "When capture_snapshot returns, tell the user:",
@@ -69,7 +105,7 @@ export const SERVER_INSTRUCTIONS = [
69
105
  export const TOOL_DEFINITIONS = [
70
106
  {
71
107
  name: "ping",
72
- description: "Check if Slack Radar is running. Returns uptime, buffer sizes, remaining session time, and stream status.",
108
+ description: "Check if Slack Radar is running. Returns uptime, buffer sizes, remaining session time, stream status, and which app/profile is bound: android_user_id (0 = personal, non-zero = a secondary user such as a work profile), profile ('personal'/'secondary'), and package.",
73
109
  inputSchema: {
74
110
  type: "object",
75
111
  properties: {
@@ -206,19 +242,19 @@ export const TOOL_DEFINITIONS = [
206
242
  },
207
243
  {
208
244
  name: "list_profiles",
209
- description: "List Android user profiles that have the Slack debug build running. Use this before activate_for_user when the user asks to switch profiles (personal vs work) or when logs/app state seem to point at the wrong profile. Returns each profile's userId (e.g. '0' for personal, '10' for work) and a human label.",
245
+ description: "List Android user profiles that have the Slack debug build running. Use this before activate_for_user when the user asks to switch profiles (personal vs a secondary user such as a work profile) or when logs/app state seem to point at the wrong profile. Returns each profile's userId (e.g. '0' for personal, '10' for a secondary user) and a human label.",
210
246
  inputSchema: { type: "object", properties: {} },
211
247
  annotations: { readOnlyHint: true },
212
248
  },
213
249
  {
214
250
  name: "activate_for_user",
215
- description: "Activate Slack Radar on a specific Android user profile. Use after list_profiles to switch between personal and work profile targets. Switching profiles restarts log capture with a new session-scoped file and reconnects the SSE event stream so events come from the newly activated profile; old captures remain on disk for up to 7 days. Call this when already connected and only the target profile needs to change.",
251
+ description: "Activate Slack Radar on a specific Android user profile. Use after list_profiles to switch between the personal user and a secondary user (such as a work profile). Switching profiles restarts log capture with a new session-scoped file and reconnects the SSE event stream so events come from the newly activated profile; old captures remain on disk for up to 7 days. Call this when already connected and only the target profile needs to change.",
216
252
  inputSchema: {
217
253
  type: "object",
218
254
  properties: {
219
255
  user_id: {
220
256
  type: "string",
221
- description: "Android user ID from list_profiles (e.g. '0' for personal, '10' for work).",
257
+ description: "Android user ID from list_profiles (e.g. '0' for personal, '10' for a secondary user).",
222
258
  },
223
259
  timeout_minutes: {
224
260
  type: "number",
@@ -298,6 +334,79 @@ export const TOOL_DEFINITIONS = [
298
334
  inputSchema: { type: "object", properties: {} },
299
335
  annotations: { readOnlyHint: false, idempotentHint: true },
300
336
  },
337
+ {
338
+ name: "open_radar_dashboard",
339
+ description: "Build or refine a custom live dashboard tab in the Slack Radar web UI from a spec YOU author. " +
340
+ "Suggest this when the user describes a live view the pre-built tabs (Live/Network/RTM/Clogs/Logs) do not cover " +
341
+ "(e.g. 'graph calls per second vs response time and flag slow ones', 'beep when I get a DM'); invoke it once they agree. " +
342
+ "Translate the request into the spec fields below and call this tool; it ensures the web dashboard is " +
343
+ "running (default http://localhost:8100) and renders your spec as a 'Custom' tab, then returns the URL to share. " +
344
+ "Calling again replaces/refines it. Does not open a browser window for the user. The dashboard reads a connected " +
345
+ "device, so Radar must be armed to show data (the dashboard has its own Reconnect button). Debug builds only, local only.",
346
+ inputSchema: {
347
+ type: "object",
348
+ properties: {
349
+ title: { type: "string", description: "Short 1-3 word dashboard title; also the Custom tab label." },
350
+ summary: {
351
+ type: "string",
352
+ description: "ONE honest plain-English line describing what this shows, including any active filter.",
353
+ },
354
+ source: {
355
+ type: "string",
356
+ enum: [...SOURCES],
357
+ description: "Which device stream to read. 'all' is a unified timeline mixing network, RTM, and clog.",
358
+ },
359
+ match: {
360
+ type: "object",
361
+ description: "Case-insensitive substring filter on SUMMARY fields, keyed by source. network: url/method/status_code; " +
362
+ "rtm: event_type/direction/channel; clog: event_name; log: tag/level/package. NEVER invent a field " +
363
+ "(a match on an absent field silently matches nothing). For body text use bodyContains instead.",
364
+ },
365
+ bodyContains: {
366
+ type: "string",
367
+ description: "network/all only: keep calls whose request/response BODY contains this substring (fetches each call's detail).",
368
+ },
369
+ viz: {
370
+ type: "array",
371
+ items: { type: "string", enum: [...VIZ] },
372
+ description: "Widgets to compose. 'graph' requires a series array.",
373
+ },
374
+ rateWindowSec: {
375
+ type: "number",
376
+ description: "Sliding window in seconds for the rate widget (default 10).",
377
+ },
378
+ series: {
379
+ type: "array",
380
+ description: "Required when viz includes 'graph'. 1-2 entries.",
381
+ items: {
382
+ type: "object",
383
+ properties: {
384
+ label: { type: "string" },
385
+ metric: { type: "string", enum: [...SERIES_METRICS] },
386
+ field: { type: "string", description: "Required for the 'avg' metric, e.g. duration_ms." },
387
+ unit: { type: "string" },
388
+ },
389
+ required: ["metric"],
390
+ },
391
+ },
392
+ extract: {
393
+ type: "object",
394
+ description: "Pull CONTENT from a record body into the feed: {parse:'response_body'|'request_body'|'data', field:'dot.path', label}.",
395
+ },
396
+ highlight: {
397
+ type: "object",
398
+ description: "Flag feed rows whose numeric field breaches a threshold: {field, op:'>'|'>='|'<'|'<='|'==', value, label}.",
399
+ },
400
+ alert: {
401
+ type: "object",
402
+ description: "Sentry mode: {sound, flash, say, at}. 'at':N fires once when the match count reaches N; omit to fire on every match.",
403
+ },
404
+ },
405
+ required: ["title", "summary", "source", "viz"],
406
+ },
407
+ // Not read-only: it starts a local web server and pushes a spec to it.
408
+ annotations: { readOnlyHint: false, idempotentHint: true },
409
+ },
301
410
  ];
302
411
  /**
303
412
  * Check whether a tool call should be blocked by the session gate.
@@ -312,6 +421,11 @@ export function sessionGate(toolName, sessionEnabled) {
312
421
  if (toolName === "ping") {
313
422
  return null;
314
423
  }
424
+ // open_radar_dashboard launches an independent local web process with its own
425
+ // device-enable (Reconnect) button, so it does not require the MCP session enabled.
426
+ if (toolName === "open_radar_dashboard") {
427
+ return null;
428
+ }
315
429
  if (!sessionEnabled) {
316
430
  return {
317
431
  content: [
@@ -13,8 +13,9 @@ export declare function resolveAdbPath(): string | null;
13
13
  /**
14
14
  * Parse the output of `ps -A -o USER,NAME` to extract the Android user ID
15
15
  * for the debug build process. When multiple profiles are running, prefers
16
- * the work profile (user ID > 0) since that's the typical debugging target.
17
- * Returns "0" for primary user, "10" for work profile, etc.
16
+ * a secondary user (user ID > 0) since that's the typical debugging target.
17
+ * Returns "0" for the primary user, or the first secondary user id (commonly
18
+ * "10", which is often a work profile, but the id alone cannot prove that).
18
19
  */
19
20
  export declare function parseUserFromPsOutput(psOutput: string): string;
20
21
  export declare class AndroidTransport implements DeviceTransport {
@@ -61,8 +61,9 @@ const ADB = resolveAdbPath();
61
61
  /**
62
62
  * Parse the output of `ps -A -o USER,NAME` to extract the Android user ID
63
63
  * for the debug build process. When multiple profiles are running, prefers
64
- * the work profile (user ID > 0) since that's the typical debugging target.
65
- * Returns "0" for primary user, "10" for work profile, etc.
64
+ * a secondary user (user ID > 0) since that's the typical debugging target.
65
+ * Returns "0" for the primary user, or the first secondary user id (commonly
66
+ * "10", which is often a work profile, but the id alone cannot prove that).
66
67
  */
67
68
  export function parseUserFromPsOutput(psOutput) {
68
69
  if (!psOutput || !psOutput.trim())
@@ -77,9 +78,9 @@ export function parseUserFromPsOutput(psOutput) {
77
78
  }
78
79
  if (userIds.length === 0)
79
80
  return "0";
80
- // Prefer work profile (non-zero user ID) when multiple profiles are running
81
- const workProfile = userIds.find((id) => id !== "0");
82
- return workProfile ?? userIds[0];
81
+ // Prefer a secondary user (non-zero user ID) when multiple profiles are running
82
+ const secondaryUser = userIds.find((id) => id !== "0");
83
+ return secondaryUser ?? userIds[0];
83
84
  }
84
85
  export class AndroidTransport {
85
86
  platform = "android";
@@ -228,7 +229,7 @@ export class AndroidTransport {
228
229
  const id = match[1];
229
230
  profiles.push({
230
231
  userId: id,
231
- label: id === "0" ? "Personal (user 0)" : `Work profile (user ${id})`,
232
+ label: id === "0" ? "Personal (user 0)" : `Secondary (user ${id}, e.g. a work profile)`,
232
233
  });
233
234
  }
234
235
  }
@@ -4,3 +4,9 @@ export declare const RADAR_PORT = 8099;
4
4
  export declare const RADAR_HOST = "127.0.0.1";
5
5
  /** Max events to retain in each local SSE buffer. */
6
6
  export declare const MAX_LOCAL_BUFFER = 500;
7
+ /**
8
+ * Default port for the web dashboard. Shared so the MCP `open_radar_dashboard`
9
+ * tool POSTs its spec to the same port the web server listens on; both honor the
10
+ * `SLACK_RADAR_WEB_PORT` env override.
11
+ */
12
+ export declare const WEB_PORT_DEFAULT = 8100;
@@ -4,3 +4,9 @@ export const RADAR_PORT = 8099;
4
4
  export const RADAR_HOST = "127.0.0.1";
5
5
  /** Max events to retain in each local SSE buffer. */
6
6
  export const MAX_LOCAL_BUFFER = 500;
7
+ /**
8
+ * Default port for the web dashboard. Shared so the MCP `open_radar_dashboard`
9
+ * tool POSTs its spec to the same port the web server listens on; both honor the
10
+ * `SLACK_RADAR_WEB_PORT` env override.
11
+ */
12
+ export const WEB_PORT_DEFAULT = 8100;
package/dist/web/bin.js CHANGED
@@ -1,35 +1,50 @@
1
1
  #!/usr/bin/env node
2
- import { createServer, WEB_PORT } from "./server.js";
3
2
  import { execSync } from "child_process";
4
- const server = createServer();
5
- server.on("error", (err) => {
6
- if (err.code === "EADDRINUSE") {
7
- console.error(`Port ${WEB_PORT} is already in use. Another instance may be running.\n` +
8
- `Kill it with: lsof -ti :${WEB_PORT} | xargs kill\n` +
9
- `Or set a different port: SLACK_RADAR_WEB_PORT=8101 slack-radar-web`);
10
- process.exit(1);
11
- }
12
- throw err;
13
- });
14
- server.listen(WEB_PORT, () => {
15
- const url = `http://localhost:${WEB_PORT}`;
16
- console.log(`Slack Radar Web running at ${url}`);
17
- try {
18
- if (process.platform === "darwin") {
19
- execSync(`open ${url}`, { stdio: "ignore" });
3
+ import { createServer, WEB_PORT } from "./server.js";
4
+ /**
5
+ * Start the web dashboard server, open the browser, and wire shutdown signals.
6
+ * Extracted so both the dedicated `slack-radar-web` bin and the default bin's
7
+ * `web` subcommand dispatcher launch the dashboard the same way.
8
+ */
9
+ function startWebServer() {
10
+ const server = createServer();
11
+ server.on("error", (err) => {
12
+ if (err.code === "EADDRINUSE") {
13
+ console.error(`Port ${WEB_PORT} is already in use. Another instance may be running.\n` +
14
+ `Kill it with: lsof -ti :${WEB_PORT} | xargs kill\n` +
15
+ `Or set a different port: SLACK_RADAR_WEB_PORT=8101 slack-radar web`);
16
+ process.exit(1);
17
+ }
18
+ throw err;
19
+ });
20
+ server.listen(WEB_PORT, () => {
21
+ const url = `http://localhost:${WEB_PORT}`;
22
+ console.log(`Slack Radar Web running at ${url}`);
23
+ // Auto-open the browser for the HUMAN launcher (`slack-radar web` / `slack-radar-web`),
24
+ // but NOT when spawned as a bridge child by the open_radar_dashboard MCP tool
25
+ // (SLACK_RADAR_NO_OPEN=1). The Claude Code session must not pop a browser window the user
26
+ // did not ask for — the same no-auto-open-browser rule the SERVER_INSTRUCTIONS state for
27
+ // /radar-ui. The tool returns the URL instead, for the Claude Code session to surface.
28
+ if (process.env.SLACK_RADAR_NO_OPEN)
29
+ return;
30
+ try {
31
+ if (process.platform === "darwin") {
32
+ execSync(`open ${url}`, { stdio: "ignore" });
33
+ }
34
+ else if (process.platform === "linux") {
35
+ execSync(`xdg-open ${url}`, { stdio: "ignore" });
36
+ }
20
37
  }
21
- else if (process.platform === "linux") {
22
- execSync(`xdg-open ${url}`, { stdio: "ignore" });
38
+ catch {
39
+ // Browser open is best-effort
23
40
  }
24
- }
25
- catch {
26
- // Browser open is best-effort
27
- }
28
- });
29
- function shutdown() {
30
- console.log("\nShutting down…");
31
- server.close(() => process.exit(0));
32
- setTimeout(() => process.exit(0), 2000);
41
+ });
42
+ const shutdown = () => {
43
+ console.log("\nShutting down…");
44
+ server.close(() => process.exit(0));
45
+ setTimeout(() => process.exit(0), 2000);
46
+ };
47
+ process.on("SIGINT", shutdown);
48
+ process.on("SIGTERM", shutdown);
33
49
  }
34
- process.on("SIGINT", shutdown);
35
- process.on("SIGTERM", shutdown);
50
+ startWebServer();