@thehammer/danx-dashboard-mcp 0.1.158 → 0.1.159

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/handlers.js CHANGED
@@ -111,51 +111,6 @@ export async function issueGet(client, args) {
111
111
  board: args.board,
112
112
  });
113
113
  }
114
- // ---------------- brief_list / brief_get_page / brief_set_page ----------------
115
- const BRIEF_BASE_PATH = "/api/brief";
116
- /**
117
- * List the board's named Brief pages via GET /api/brief (DX-2083).
118
- * A bare board-scoped GET, no id — many named pages per board.
119
- */
120
- export async function briefList(client, args = {}) {
121
- return client.request({
122
- method: "GET",
123
- path: "",
124
- basePath: BRIEF_BASE_PATH,
125
- board: args.board,
126
- });
127
- }
128
- /**
129
- * Fetch one Brief page by slug via GET /api/brief/page?slug=
130
- * (DX-2083). A missing row (including a not-yet-created page) reads as the
131
- * empty view — never a 404.
132
- */
133
- export async function briefGetPage(client, args) {
134
- return client.request({
135
- method: "GET",
136
- path: "/page",
137
- basePath: BRIEF_BASE_PATH,
138
- query: { slug: args.slug },
139
- board: args.board,
140
- });
141
- }
142
- /**
143
- * Write one Brief page via PUT /api/brief/page?slug= (DX-2083).
144
- * Optimistic-concurrency `base_hash` with a verbatim 409 passthrough on a
145
- * stale write. `slug` rides the query string (matching the route), never
146
- * the body.
147
- */
148
- export async function briefSetPage(client, args) {
149
- const { slug, board, ...body } = args;
150
- return client.request({
151
- method: "PUT",
152
- path: "/page",
153
- basePath: BRIEF_BASE_PATH,
154
- query: { slug },
155
- body,
156
- board,
157
- });
158
- }
159
114
  export async function issueCreate(client, args, defaultBoard) {
160
115
  // Resolve the target board ONCE: per-call `args.board` override (a
161
116
  // qualified `<repo>:<slug>` id) wins, else the dispatch's env-derived
@@ -1,10 +1,6 @@
1
- import { assertVersionFloorSatisfied, MCP_MIN_VERSION_HEADER } from "./version-floor.js";
2
1
  export class DashboardHttpClient {
3
2
  config;
4
3
  fetchImpl;
5
- // DX-3597 — true once this instance has made ONE request, regardless of
6
- // outcome. Drives the "first call OR any 4xx" version-floor check below.
7
- hasCheckedVersionFloor = false;
8
4
  constructor(config, fetchImpl = fetch) {
9
5
  this.config = config;
10
6
  this.fetchImpl = fetchImpl;
@@ -54,18 +50,6 @@ export class DashboardHttpClient {
54
50
  catch (err) {
55
51
  throw new Error(`[danx-dashboard-mcp] network failure on ${args.method} ${url}: ${err instanceof Error ? err.message : String(err)}`);
56
52
  }
57
- // DX-3597 — proactive on the first call this instance ever makes
58
- // (regardless of outcome: a stale client can otherwise look fine for a
59
- // while on routes whose shape didn't change), and on every subsequent
60
- // 4xx (a response that might otherwise read as an ordinary caller
61
- // error when it's really "you're running an old MCP"). Throws
62
- // McpOutdatedError instead of returning below when this package is
63
- // behind the floor — see version-floor.ts's own doc.
64
- const isFirstCall = !this.hasCheckedVersionFloor;
65
- this.hasCheckedVersionFloor = true;
66
- if (isFirstCall || (res.status >= 400 && res.status < 500)) {
67
- assertVersionFloorSatisfied(res.headers.get(MCP_MIN_VERSION_HEADER));
68
- }
69
53
  const text = await res.text();
70
54
  let parsed = null;
71
55
  if (text !== "") {
package/dist/index.js CHANGED
@@ -34,9 +34,6 @@
34
34
  * - issue_attach POST /api/issues/:id/attachments (reads a local file)
35
35
  * - quality_gate_instruction
36
36
  * GET /api/quality-gates/:gate/instruction (DX-3341, not card-scoped)
37
- * - brief_list GET /api/brief
38
- * - brief_get_page GET /api/brief/page (DX-2083 / DX-2484)
39
- * - brief_set_page PUT /api/brief/page (DX-2083 / DX-2484)
40
37
  * - plan_list GET /api/plans (DX-2683)
41
38
  * - plan_get GET /api/plans/:id/full | /api/plans/mine (DX-2727: bare = scalars only, fields= opts in)
42
39
  * - plan_create POST /api/plans
@@ -108,7 +105,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
108
105
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
109
106
  import { z } from "zod";
110
107
  import { DashboardHttpClient } from "./http-client.js";
111
- import { issueAttach, issueChecklist, issueComment, issueCreate, issueDependency, issueEdit, issueGet, issueList, issueProblem, issueQualityGate, issueQualityGateVerdict, issueRetireBranch, issueRetro, issueSolution, issueTransition, issueTriage, briefGetPage, briefList, briefSetPage, failureCategoryCreate, failureCategoryList, failureCategoryUpdate, dispatchTranscriptSearch, planAddArchitectureSection, planAddCard, planAddNote, planAddRecord, planConnect, planCreate, planDeleteArchitectureSection, planDeleteNote, planDeleteRecord, planGet, PLAN_STATUSES, ISSUE_BATCH_GET_MAX, LIST_PAGE_MAX_LIMIT, planGetArchitectureSection, planGetRecord, planList, planRemoveCard, planRename, planReorderArchitectureSection, planUpdateArchitectureSection, planUpdateNote, planUpdateRecord, qualityGateInstruction, resourceFields, } from "./handlers.js";
108
+ import { issueAttach, issueChecklist, issueComment, issueCreate, issueDependency, issueEdit, issueGet, issueList, issueProblem, issueQualityGate, issueQualityGateVerdict, issueRetireBranch, issueRetro, issueSolution, issueTransition, issueTriage, failureCategoryCreate, failureCategoryList, failureCategoryUpdate, dispatchTranscriptSearch, planAddArchitectureSection, planAddCard, planAddNote, planAddRecord, planConnect, planCreate, planDeleteArchitectureSection, planDeleteNote, planDeleteRecord, planGet, PLAN_STATUSES, ISSUE_BATCH_GET_MAX, LIST_PAGE_MAX_LIMIT, planGetArchitectureSection, planGetRecord, planList, planRemoveCard, planRename, planReorderArchitectureSection, planUpdateArchitectureSection, planUpdateNote, planUpdateRecord, qualityGateInstruction, resourceFields, } from "./handlers.js";
112
109
  import { PRIORITY_TIER_WORDS } from "./priority.js";
113
110
  import { fieldTreeSchema } from "./field-tree.js";
114
111
  function readEnvOrDie(name) {
@@ -872,33 +869,6 @@ strictTool("issue_attach", "Attach a LOCAL file to an issue card: `id` (the card
872
869
  .describe("Absolute path to a local file on the dispatch's shared filesystem (must start with `/`)."),
873
870
  ...boardField,
874
871
  }, async (args) => jsonResult(await issueAttach(client, args)));
875
- // ---------------- brief_list ----------------
876
- strictTool("brief_list", "List the board's named Brief pages. Board-scoped; see `board`. Returns `{boardId, pages: [{slug, title, contentHash, sortOrder, updatedAt, updatedBy}]}` — metadata only, no content (use `brief_get_page`). Brief pages are MANY named pages per board (Goals/Architecture/Rules/Caveats tabs), keyed by (board, slug). The reserved `index` slug always exists.", {
877
- ...boardField,
878
- }, async (args) => jsonResult(await briefList(client, args)));
879
- // ---------------- brief_get_page ----------------
880
- strictTool("brief_get_page", 'Fetch one Brief page by slug. Board-scoped; see `board`. Returns `{boardId, slug, title, content, contentHash, sortOrder, updatedAt, updatedBy}` — a missing page reads as the empty view (content/contentHash `""`), not a 404. Before `brief_set_page`, always get immediately first and pass `contentHash` back as `base_hash` — the concurrency guard rejects a stale write.', {
881
- slug: z
882
- .string()
883
- .min(1)
884
- .describe("The page's slug. The reserved `index` slug always exists on every board."),
885
- ...boardField,
886
- }, async (args) => jsonResult(await briefGetPage(client, args)));
887
- // ---------------- brief_set_page ----------------
888
- strictTool("brief_set_page", 'Write one Brief page. Board-scoped; see `board`. Body: `{content, title?, sortOrder?, base_hash?}` — optimistic-concurrency, targeting one named page. `base_hash` must be the `contentHash` from the immediately-prior `brief_get_page` (`""` for a true first write). On mismatch fails loud with `{error: "stale_brief_page", currentHash}` — re-get, re-merge, retry, never overwrite blindly. On success persists, publishes `brief:updated` over SSE, and returns the new view. No delete tool on this surface; the reserved `index` slug is never deletable — removing a non-index page is dashboard-UI-only.', {
889
- slug: z
890
- .string()
891
- .min(1)
892
- .describe("The page's slug. Writing the reserved `index` slug is allowed (it always exists); only deletion of `index` is refused."),
893
- content: z.string(),
894
- title: z.string().optional(),
895
- sortOrder: z.number().optional(),
896
- base_hash: z
897
- .string()
898
- .optional()
899
- .describe('The contentHash last read via brief_get_page ("" for a true first write). Omitted also normalizes to "" server-side, so it only succeeds against an empty/absent page — always get immediately before set.'),
900
- ...boardField,
901
- }, async (args) => jsonResult(await briefSetPage(client, args)));
902
872
  // ---------------- plans (DX-2683) ----------------
903
873
  // THE BINDING ASYMMETRY IS IN THE SCHEMAS, NOT IN PROSE. `plan_get` takes an
904
874
  // optional `plan_id`; `plan_add_record`, `plan_get_record`,
@@ -909,7 +879,7 @@ strictTool("brief_set_page", 'Write one Brief page. Board-scoped; see `board`. B
909
879
  // plan id — and it can only ever bind the caller's own session. `plan_create`
910
880
  // also takes no plan id, but for a different reason: it MAKES a plan rather
911
881
  // than acting on one, so there is no existing plan for an id to name yet.
912
- strictTool("plan_list", "List every plan, and learn which plan THIS session is connected to. Plans are GLOBAL, not board-scoped — a plan is a named, dated set of cards an operator assembled by hand, from any repo. Returns `{plans: [{id, ref, name, createdAt, cardCount, boards, status, signedOffAt, signedOffBy, autoSignOff}], session, sessionListenerAttached}` — `ref` is the plan's short reference (`PLN-<id>`), cite it rather than the bare id. `status` is computed fresh on every read, never stored — except the sign-off pair itself: `awaiting-session` (no live session — a session row isn't released just because a session ended), `planning` (no cards, or only Review/Backlog/terminal ones with ≥1 not Done/Cancelled), `building` (a live session AND ≥1 card ToDo/In Progress or stuck-but-active — Blocked/Needs Help), `awaiting-sign-off` (≥1 card, all Done/Cancelled, but nobody has signed the plan off yet — DX-3519), `complete` (≥1 card, all Done/Cancelled, AND signed off — wins even with no session). `signedOffAt`/`signedOffBy` are `null` until a human (`signedOffBy` = their identity) or the `autoSignOff` toggle (`signedOffBy: 'auto'`) signs the plan off; sign-off itself is a human-only write, not exposed through this MCP surface — direct the operator to the dashboard's plan page. Pass `status` to filter. `session` is your own registration (`{sessionId, title, planId, planName, firstSeenAt, lastActiveAt}`) or null outside a Claude Code session; `planId: null` means connected to no plan — `plan_get` to browse, `plan_connect` to bind. `sessionListenerAttached` says whether your event stream is attached (the plugin's plan bridge); false for a few seconds right after connect is normal, false after that means events aren't reaching you — tell the operator. Distinct from the board Brief (`brief_list`).", {
882
+ strictTool("plan_list", "List every plan, and learn which plan THIS session is connected to. Plans are GLOBAL, not board-scoped — a plan is a named, dated set of cards an operator assembled by hand, from any repo. Returns `{plans: [{id, ref, name, createdAt, cardCount, boards, status, signedOffAt, signedOffBy, autoSignOff}], session, sessionListenerAttached}` — `ref` is the plan's short reference (`PLN-<id>`), cite it rather than the bare id. `status` is computed fresh on every read, never stored — except the sign-off pair itself: `awaiting-session` (no live session — a session row isn't released just because a session ended), `planning` (no cards, or only Review/Backlog/terminal ones with ≥1 not Done/Cancelled), `building` (a live session AND ≥1 card ToDo/In Progress or stuck-but-active — Blocked/Needs Help), `awaiting-sign-off` (≥1 card, all Done/Cancelled, but nobody has signed the plan off yet — DX-3519), `complete` (≥1 card, all Done/Cancelled, AND signed off — wins even with no session). `signedOffAt`/`signedOffBy` are `null` until a human (`signedOffBy` = their identity) or the `autoSignOff` toggle (`signedOffBy: 'auto'`) signs the plan off; sign-off itself is a human-only write, not exposed through this MCP surface — direct the operator to the dashboard's plan page. Pass `status` to filter. `session` is your own registration (`{sessionId, title, planId, planName, firstSeenAt, lastActiveAt}`) or null outside a Claude Code session; `planId: null` means connected to no plan — `plan_get` to browse, `plan_connect` to bind. `sessionListenerAttached` says whether your event stream is attached (the plugin's plan bridge); false for a few seconds right after connect is normal, false after that means events aren't reaching you — tell the operator.", {
913
883
  status: z
914
884
  .enum(PLAN_STATUSES)
915
885
  .optional()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thehammer/danx-dashboard-mcp",
3
- "version": "0.1.158",
3
+ "version": "0.1.159",
4
4
  "description": "Stdio MCP server wrapping danxbot's dashboard /api/issues/* normalized DB-backed HTTP routes for dispatched agents (DX-704 Phase 2).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,128 +0,0 @@
1
- /**
2
- * DX-3597 — this package's half of the MCP-version-floor guard whose
3
- * server-side half shipped in DX-3525 (`src/mcp-contract.ts`,
4
- * `src/dashboard/serve-request.ts`, `src/resources/field-tree.ts`, all in
5
- * the main danxbot repo — this package cannot import them, see below).
6
- *
7
- * The dashboard stamps `X-Danx-Mcp-Min-Version` on every routed `/api/*`
8
- * response with its currently-advertised floor (`MIN_MCP_VERSION` in
9
- * `src/mcp-contract.ts` — DX-3597 made that floor track the version where
10
- * an MCP-exposed contract last changed, not "whatever's currently
11
- * published"; see that file's module doc for the full decision).
12
- *
13
- * `DashboardHttpClient.request()` (`./http-client.ts`) reads this header on
14
- * the FIRST call this process makes (regardless of outcome — a proactive
15
- * check, since a stale client can otherwise appear to work for a while on
16
- * routes whose shape didn't change) and on every subsequent 4xx (a response
17
- * that might otherwise read as an ordinary caller error, when it's really
18
- * "you're running an old MCP"). When this package's own version is behind
19
- * the advertised floor, it throws `McpOutdatedError` instead of returning
20
- * the ordinary envelope — the same "throw rather than fabricate/silently
21
- * pass through" contract `http-client.ts` already applies to a 5xx/network
22
- * failure (see that file's own doc): an outdated MCP is exactly that class
23
- * of failure, nothing the calling tool can meaningfully work around.
24
- *
25
- * Everything here is duplicated, not imported, from the server's
26
- * `src/mcp-contract.ts` — this package is an INDEPENDENTLY PUBLISHED npm
27
- * artifact (DX-2103) and cannot depend on the danxbot service's own `src/`
28
- * tree. Keep the header name, the package name, and the version-compare
29
- * behavior in agreement with that file by hand when either changes.
30
- */
31
- import { readFileSync } from "node:fs";
32
- import { dirname, join } from "node:path";
33
- import { fileURLToPath } from "node:url";
34
- /** Must match `MCP_MIN_VERSION_HEADER` in danxbot's `src/mcp-contract.ts` verbatim. */
35
- export const MCP_MIN_VERSION_HEADER = "X-Danx-Mcp-Min-Version";
36
- /** Must match `MCP_PACKAGE_NAME` in danxbot's `src/mcp-contract.ts` verbatim. */
37
- export const MCP_PACKAGE_NAME = "@thehammer/danx-dashboard-mcp";
38
- /**
39
- * Numeric-dotted version compare (major.minor.patch, ...) — mirrors
40
- * `compareMcpVersions` in danxbot's `src/mcp-contract.ts` behavior
41
- * byte-for-byte (duplicated, not imported — see module doc). Both sides of
42
- * this contract have only ever used plain numeric dotted versions, so this
43
- * throws rather than silently falling back to a lexical compare, which
44
- * would misorder "0.1.9" vs "0.1.10".
45
- */
46
- export function compareMcpVersions(a, b) {
47
- const parse = (v) => {
48
- if (!/^\d+(\.\d+)*$/.test(v)) {
49
- throw new Error(`[danx-dashboard-mcp] "${v}" is not a plain numeric dotted version (major.minor.patch)`);
50
- }
51
- return v.split(".").map(Number);
52
- };
53
- const pa = parse(a);
54
- const pb = parse(b);
55
- const len = Math.max(pa.length, pb.length);
56
- for (let i = 0; i < len; i++) {
57
- const da = pa[i] ?? 0;
58
- const db = pb[i] ?? 0;
59
- if (da !== db)
60
- return da - db;
61
- }
62
- return 0;
63
- }
64
- let cachedOwnVersion;
65
- /**
66
- * Reads this package's OWN version from its `package.json` — always present
67
- * next to `dist/` (or `src/`, under `npm run dev`'s `tsx`) at runtime even
68
- * though `files: ["dist","README.md"]` excludes it from the tarball
69
- * MANIFEST: npm always includes `package.json` in what it publishes and
70
- * what it installs, regardless of `files` (the same guarantee `README` /
71
- * `LICENSE` / the `main` entry get) — this reads the copy npm actually
72
- * installed next to this module, not danxbot's own source tree. Both
73
- * `dist/version-floor.js` and `src/version-floor.ts` sit exactly one
74
- * directory below the package root, so `../package.json` resolves
75
- * correctly under both the published (dist) and dev (`tsx src/index.ts`)
76
- * shapes. Memoized — the version cannot change mid-process.
77
- */
78
- export function readOwnVersion() {
79
- if (cachedOwnVersion !== undefined)
80
- return cachedOwnVersion;
81
- const here = dirname(fileURLToPath(import.meta.url));
82
- const pkgJsonPath = join(here, "..", "package.json");
83
- const raw = readFileSync(pkgJsonPath, "utf8");
84
- const parsed = JSON.parse(raw);
85
- if (typeof parsed.version !== "string") {
86
- throw new Error(`[danx-dashboard-mcp] could not read this package's own version from ${pkgJsonPath}`);
87
- }
88
- cachedOwnVersion = parsed.version;
89
- return cachedOwnVersion;
90
- }
91
- /** Test-only escape hatch — real callers never need to override the memoized read. */
92
- export function __resetOwnVersionCacheForTests() {
93
- cachedOwnVersion = undefined;
94
- }
95
- /**
96
- * Thrown by `assertVersionFloorSatisfied` when this package is running
97
- * behind the server's advertised floor. Carries structured `have`/`need`
98
- * fields (not just a prose message) so a caller that wants to branch on
99
- * "is this specifically an outdated-MCP failure" can check `error.code`
100
- * rather than pattern-match the message text.
101
- */
102
- export class McpOutdatedError extends Error {
103
- code = "mcp_outdated";
104
- have;
105
- need;
106
- constructor(have, need) {
107
- super(`[danx-dashboard-mcp] mcp_outdated: this MCP is running ${MCP_PACKAGE_NAME}@${have}, but the dashboard ` +
108
- `requires >= ${need}. Restart your Claude Code session to pick up the published update.`);
109
- this.name = "McpOutdatedError";
110
- this.have = have;
111
- this.need = need;
112
- }
113
- }
114
- /**
115
- * Compares this package's own version against the floor a response header
116
- * advertised. No-ops (returns) when compatible, or when `headerValue` is
117
- * `null`/empty (an old-enough server, or a test stub, that never stamped
118
- * one — nothing to compare against). Throws `McpOutdatedError` when this
119
- * package is behind.
120
- */
121
- export function assertVersionFloorSatisfied(headerValue) {
122
- if (!headerValue)
123
- return;
124
- const have = readOwnVersion();
125
- if (compareMcpVersions(have, headerValue) < 0) {
126
- throw new McpOutdatedError(have, headerValue);
127
- }
128
- }