@mcptoolshop/housekeeping 1.6.1 → 1.6.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project are recorded here.
4
4
  The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
+ ## [1.6.2] - 2026-12-06
7
+
8
+ ### Fixed
9
+ - Added explicit 4-hint `READ_ONLY` `ToolAnnotations` (`readOnlyHint: true`, `destructiveHint: false`, `idempotentHint: true`, `openWorldHint: false`) across all 11 `hk` MCP tools (#19).
10
+ - Preserved literal job names containing parenthesized suffixes during `classifyRequiredChecks` analysis, and added M8ven Live Score badge.
11
+
6
12
  ## [1.6.1] - 2026-12-05
7
13
 
8
14
  ### Fixed
package/README.md CHANGED
@@ -21,6 +21,8 @@
21
21
  <a href="https://mcp-tool-shop-org.github.io/housekeeping/handbook/"><img src="https://img.shields.io/badge/Handbook-read-blue" alt="Handbook" /></a>
22
22
  </p>
23
23
 
24
+ [![M8ven Score](https://m8ven.ai/badge/mcp/mcp-tool-shop-org/housekeeping)](https://m8ven.ai/mcp/mcp-tool-shop-org/housekeeping?s=readme)
25
+
24
26
  One sweep collects every repository's CI status, open issues and pull requests,
25
27
  releases, version tags, workflow files, branch protection, security alerts,
26
28
  lockfiles and Actions billing into SQLite, then audits it all against written
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcptoolshop/housekeeping",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "Operational-health warehouse for a GitHub organization: CI, issues, PRs, releases, Actions cost and repo hygiene, collected into SQLite and audited against written rules.",
5
5
  "keywords": [
6
6
  "github",
package/src/analyze.mjs CHANGED
@@ -512,7 +512,7 @@ export function classifyRequiredChecks({ required, observedNames, declaredJobs }
512
512
 
513
513
  const stale = required
514
514
  .filter(c => !universe.has(c))
515
- .filter(c => observedBases.has(base(c)) || !jobs.has(base(c)));
515
+ .filter(c => !jobs.has(c) && (observedBases.has(base(c)) || !jobs.has(base(c))));
516
516
  const staleSet = new Set(stale);
517
517
  // Everything not proven dead. A stale context is absent from every PR by
518
518
  // definition, so leaving it in `live` would bill one defect twice under two
package/src/mcp.mjs CHANGED
@@ -9,7 +9,8 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
9
9
  import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
10
10
  import { DatabaseSync } from 'node:sqlite';
11
11
  import { existsSync, readFileSync } from 'node:fs';
12
- import { join } from 'node:path';
12
+ import { join, resolve } from 'node:path';
13
+ import { fileURLToPath } from 'node:url';
13
14
  import { EXIT, formatError, readOnlyQuery, structured, userError } from './errors.mjs';
14
15
  import { DATA_DIR, PACKAGE_ROOT } from './paths.mjs';
15
16
  import { HEAD_CHECKS_RED } from './analyze.mjs';
@@ -18,22 +19,19 @@ import { runQueue } from './queue.mjs';
18
19
  import { runAtlas } from './atlas-view.mjs';
19
20
 
20
21
  const DB_FILE = process.env.HK_DB || join(DATA_DIR, 'housekeeping.db');
21
- const VERSION = JSON.parse(readFileSync(join(PACKAGE_ROOT, 'package.json'), 'utf8')).version;
22
-
23
- if (!existsSync(DB_FILE)) {
24
- console.error(formatError(userError('NO_DATABASE', `no database at ${DB_FILE}`, 'run `hk refresh` first')));
25
- process.exit(EXIT.USER);
26
- }
27
- const db = new DatabaseSync(DB_FILE, { readOnly: true });
28
- const sid = () => db.prepare('SELECT MAX(id) AS id FROM snapshot').get().id;
29
22
 
23
+ // The database handle and the snapshot-id helper. They are filled in by start()
24
+ // when this file is run as the server; left unset on import so a test (or any
25
+ // other importer) can read the tool declarations below without a database on
26
+ // disk -- importing must not open a file or exit the process. Every tool's run()
27
+ // closes over these bindings and is only ever called after start() has set them.
28
+ let db;
29
+ let sid;
30
30
  // Meta repos are a fact about the org, read from the config exactly as the CLI
31
31
  // reads it, so hk_queue and hk_atlas leave out non-product repositories by
32
- // default. A malformed config must not take the server down for the other
33
- // tools, so it falls back to the default meta repo and says so on stderr.
32
+ // default. The default stands until start() reads the config; a malformed config
33
+ // must not take the server down, so start() falls back to it and says so on stderr.
34
34
  let META_REPOS = ['.github'];
35
- try { META_REPOS = loadConfig().metaRepos; }
36
- catch (e) { console.error(`[hk-mcp] ${formatError(e)} (using default metaRepos ${JSON.stringify(META_REPOS)})`); }
37
35
 
38
36
  /** Render rows as a pipe table: far cheaper in tokens than pretty-printed JSON. */
39
37
  function asTable(rows, note) {
@@ -51,9 +49,33 @@ const str = (d) => ({ type: 'string', description: d });
51
49
  const int = (d) => ({ type: 'integer', description: d });
52
50
  const bool = (d) => ({ type: 'boolean', description: d });
53
51
 
54
- const TOOLS = [
52
+ // Tool annotations (the MCP `annotations` block). Every tool below is identical
53
+ // on all four hints, and the values are the honest ones: each handler only runs
54
+ // SELECTs against the warehouse, which start() opens read-only (`new DatabaseSync(
55
+ // DB_FILE, { readOnly: true })`), and neither the handlers nor their helpers
56
+ // (readOnlyQuery, runQueue, runAtlas) write a file, spawn a process, or make a
57
+ // network call.
58
+ // readOnlyHint true - the tool modifies nothing;
59
+ // destructiveHint false - it performs no destructive update (moot while
60
+ // readOnlyHint is true, declared so the spec default
61
+ // `true` can never misrepresent these tools);
62
+ // idempotentHint true - repeated identical calls have no additional effect,
63
+ // there being no effect at all;
64
+ // openWorldHint false - a call touches only the local warehouse, a closed
65
+ // world; GitHub was read earlier by `hk refresh`, never
66
+ // live from a tool call.
67
+ // A tool that ever writes, shells out, or reaches the network must NOT reuse this.
68
+ const READ_ONLY = Object.freeze({
69
+ readOnlyHint: true,
70
+ destructiveHint: false,
71
+ idempotentHint: true,
72
+ openWorldHint: false,
73
+ });
74
+
75
+ export const TOOLS = [
55
76
  {
56
77
  name: 'hk_summary',
78
+ annotations: READ_ONLY,
57
79
  description: 'Portfolio totals for the newest snapshot: repo/issue/PR/workflow/finding counts.',
58
80
  inputSchema: { type: 'object', properties: {} },
59
81
  run: () => {
@@ -71,6 +93,7 @@ const TOOLS = [
71
93
  },
72
94
  {
73
95
  name: 'hk_findings',
96
+ annotations: READ_ONLY,
74
97
  description: 'Audit findings, optionally filtered. Omit all filters for counts grouped by code.',
75
98
  inputSchema: {
76
99
  type: 'object',
@@ -101,6 +124,7 @@ const TOOLS = [
101
124
  },
102
125
  {
103
126
  name: 'hk_ci',
127
+ annotations: READ_ONLY,
104
128
  description: 'CI health. Default lists repos whose DEFAULT BRANCH is red (the ones that matter).',
105
129
  inputSchema: {
106
130
  type: 'object',
@@ -137,6 +161,7 @@ const TOOLS = [
137
161
  },
138
162
  {
139
163
  name: 'hk_repo',
164
+ annotations: READ_ONLY,
140
165
  description: 'Everything known about one repo: metadata, findings, workflows, open PRs and issues.',
141
166
  inputSchema: {
142
167
  type: 'object',
@@ -158,6 +183,7 @@ const TOOLS = [
158
183
  },
159
184
  {
160
185
  name: 'hk_backlog',
186
+ annotations: READ_ONLY,
161
187
  description: 'Open pull requests or issues across the org, oldest first.',
162
188
  inputSchema: {
163
189
  type: 'object',
@@ -181,6 +207,7 @@ const TOOLS = [
181
207
  },
182
208
  {
183
209
  name: 'hk_health',
210
+ annotations: READ_ONLY,
184
211
  description: 'Per-repo health score (100 minus severity-weighted findings), worst first.',
185
212
  inputSchema: { type: 'object', properties: { limit: int('default 25') } },
186
213
  run: ({ limit = 25 }) => asTable(db.prepare(`
@@ -194,6 +221,7 @@ const TOOLS = [
194
221
  },
195
222
  {
196
223
  name: 'hk_queue',
224
+ annotations: READ_ONLY,
197
225
  description: 'A ranked remediation queue: every finding in the newest snapshot sorted into an '
198
226
  + 'actionable sweep lane (security-alerts, lockfile-cves, mainline-ci, atlas-rollout, '
199
227
  + 'workflow-rules, pr-backlog, repo-hygiene), grouped by repository (worst severity first) or, '
@@ -220,6 +248,7 @@ const TOOLS = [
220
248
  },
221
249
  {
222
250
  name: 'hk_atlas',
251
+ annotations: READ_ONLY,
223
252
  description: 'Fleet-wide Atlas rollout from the newest snapshot: the fleet target engine, how many '
224
253
  + 'active repositories carry a committed map versus none, and a breakdown by engine version. '
225
254
  + 'Set missing to list repositories with no map, behind to list maps older than the fleet engine '
@@ -244,6 +273,7 @@ const TOOLS = [
244
273
  },
245
274
  {
246
275
  name: 'hk_cost',
276
+ annotations: READ_ONLY,
247
277
  description: 'GitHub Actions spend. `scope` picks the grain: "repo" (the invoice, per repo), '
248
278
  + '"workflow" or "job" (computed from per-job durations). IMPORTANT: gross and net are '
249
279
  + 'different numbers. GitHub meters public repos at full price and discounts them to zero, '
@@ -303,6 +333,7 @@ const TOOLS = [
303
333
  },
304
334
  {
305
335
  name: 'hk_sql',
336
+ annotations: READ_ONLY,
306
337
  description: 'Read-only SQL against the warehouse. Tables: snapshot, repo, topic, language, '
307
338
  + 'issue, pull_request, release, workflow, workflow_run, file_presence, finding, collect_error, '
308
339
  + 'billing_usage, run_cost, run_cost_job, cost_reconciliation. '
@@ -318,6 +349,7 @@ const TOOLS = [
318
349
  },
319
350
  {
320
351
  name: 'hk_schema',
352
+ annotations: READ_ONLY,
321
353
  description: 'The warehouse schema - table and column names, for writing hk_sql queries.',
322
354
  inputSchema: { type: 'object', properties: { table: str('one table, or omit for all') } },
323
355
  run: ({ table }) => {
@@ -333,28 +365,63 @@ const TOOLS = [
333
365
  },
334
366
  ];
335
367
 
336
- const server = new Server(
337
- { name: 'housekeeping', version: VERSION },
338
- { capabilities: { tools: {} } },
339
- );
340
-
341
- server.setRequestHandler(ListToolsRequestSchema, async () => ({
342
- tools: TOOLS.map(({ name, description, inputSchema }) => ({ name, description, inputSchema })),
343
- }));
368
+ /**
369
+ * The `tools/list` response: each tool's name, description, inputSchema and its
370
+ * four-hint `annotations` block. One source of truth, used by the server's
371
+ * ListTools handler and by the tests, so the two can never disagree about what
372
+ * the server advertises.
373
+ */
374
+ export function listToolsResult(tools = TOOLS) {
375
+ return {
376
+ tools: tools.map((t) => ({
377
+ name: t.name,
378
+ description: t.description,
379
+ inputSchema: t.inputSchema,
380
+ annotations: t.annotations,
381
+ })),
382
+ };
383
+ }
344
384
 
345
- server.setRequestHandler(CallToolRequestSchema, async (req) => {
346
- const tool = TOOLS.find(t => t.name === req.params.name);
347
- // Every failure is a structured result: { code, message, hint, retryable }.
348
- // A bad argument or a failing query must never take the server down, and a
349
- // stack trace is never sent to the caller.
350
- const fail = e => ({ isError: true, content: [{ type: 'text', text: JSON.stringify(structured(e)) }] });
351
- if (!tool) return fail(userError('UNKNOWN_TOOL', `unknown tool "${req.params.name}"`, `tools: ${TOOLS.map(t => t.name).join(', ')}`));
352
- try {
353
- return { content: [{ type: 'text', text: tool.run(req.params.arguments ?? {}) }] };
354
- } catch (e) {
355
- return fail(e);
385
+ // Open the warehouse read-only, wire the two request handlers, serve over stdio.
386
+ // Only called when this file is run directly (the `hk-mcp` bin, `node src/mcp.mjs`),
387
+ // never on import -- that is what keeps the module testable without a database.
388
+ async function start() {
389
+ if (!existsSync(DB_FILE)) {
390
+ console.error(formatError(userError('NO_DATABASE', `no database at ${DB_FILE}`, 'run `hk refresh` first')));
391
+ process.exit(EXIT.USER);
356
392
  }
357
- });
393
+ db = new DatabaseSync(DB_FILE, { readOnly: true });
394
+ sid = () => db.prepare('SELECT MAX(id) AS id FROM snapshot').get().id;
395
+ try { META_REPOS = loadConfig().metaRepos; }
396
+ catch (e) { console.error(`[hk-mcp] ${formatError(e)} (using default metaRepos ${JSON.stringify(META_REPOS)})`); }
397
+
398
+ const version = JSON.parse(readFileSync(join(PACKAGE_ROOT, 'package.json'), 'utf8')).version;
399
+ const server = new Server(
400
+ { name: 'housekeeping', version },
401
+ { capabilities: { tools: {} } },
402
+ );
403
+
404
+ server.setRequestHandler(ListToolsRequestSchema, async () => listToolsResult(TOOLS));
405
+
406
+ server.setRequestHandler(CallToolRequestSchema, async (req) => {
407
+ const tool = TOOLS.find(t => t.name === req.params.name);
408
+ // Every failure is a structured result: { code, message, hint, retryable }.
409
+ // A bad argument or a failing query must never take the server down, and a
410
+ // stack trace is never sent to the caller.
411
+ const fail = e => ({ isError: true, content: [{ type: 'text', text: JSON.stringify(structured(e)) }] });
412
+ if (!tool) return fail(userError('UNKNOWN_TOOL', `unknown tool "${req.params.name}"`, `tools: ${TOOLS.map(t => t.name).join(', ')}`));
413
+ try {
414
+ return { content: [{ type: 'text', text: tool.run(req.params.arguments ?? {}) }] };
415
+ } catch (e) {
416
+ return fail(e);
417
+ }
418
+ });
419
+
420
+ await server.connect(new StdioServerTransport());
421
+ console.error(`[hk-mcp] serving ${TOOLS.length} tools from ${DB_FILE}`);
422
+ }
358
423
 
359
- await server.connect(new StdioServerTransport());
360
- console.error(`[hk-mcp] serving ${TOOLS.length} tools from ${DB_FILE}`);
424
+ // Run as the server only when invoked directly, the same guard scripts/export-public.mjs
425
+ // uses, so importing this module has no side effects.
426
+ const invokedDirectly = process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url);
427
+ if (invokedDirectly) await start();