@nitpicker/mcp-server 0.9.0 → 0.11.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/lib/mcp-server.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
2
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
3
  import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
4
- import { ArchiveManager, checkHeaders, findDuplicates, findMismatches, getPageDetail, getPageHtml, getResourceReferrers, getSummary, getViolations, listImages, listLinks, listPages, listResources, } from '@nitpicker/query';
4
+ import { ArchiveManager, checkHeaders, countPagesByJsonLdType, countPagesByTag, findDuplicates, findMismatches, getPageDetail, getPageHtml, getPageJsonLd, getPageJsonLdOverview, getPageTags, getResourceReferrers, getSummary, getTagInventory, getViolations, listImages, listIsolatedPages, listLinks, listPages, listPagesByJsonLdType, listPagesByTag, listResources, listUnusedResources, } from '@nitpicker/query';
5
5
  import { toolDefinitions } from './tool-definitions.js';
6
6
  /**
7
7
  * Validates that a required string argument is present and returns it.
@@ -77,8 +77,18 @@ function omit(args, ...keys) {
77
77
  * @returns The configured Server instance.
78
78
  */
79
79
  export function createServer() {
80
- const manager = new ArchiveManager();
81
- const server = new Server({ name: 'nitpicker', version: '0.4.4' }, { capabilities: { tools: {} } });
80
+ // Route ArchiveManager warnings to stderr explicitly via process.stderr.write
81
+ // instead of `console.warn`, but more importantly: do NOT let them leak into
82
+ // `process.stdout`, which is reserved for JSON-RPC framing on MCP stdio.
83
+ // `console.warn` already writes to stderr on Node, but going through onWarn
84
+ // gives us a single chokepoint to silence/redirect (e.g. when an MCP host
85
+ // surfaces stderr to the user as red error banners).
86
+ const manager = new ArchiveManager({
87
+ onWarn: (message) => {
88
+ process.stderr.write(`${message}\n`);
89
+ },
90
+ });
91
+ const server = new Server({ name: 'nitpicker', version: '0.10.0' }, { capabilities: { tools: {} } });
82
92
  server.setRequestHandler(ListToolsRequestSchema, () => Promise.resolve({ tools: toolDefinitions }));
83
93
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
84
94
  const { name } = request.params;
@@ -87,13 +97,20 @@ export function createServer() {
87
97
  switch (name) {
88
98
  case 'open_archive': {
89
99
  const filePath = requireString(args, 'filePath');
90
- const { archiveId, accessor } = await manager.open(filePath);
100
+ const { archiveId, accessor, mode, crawlerLockHolder } = await manager.open(filePath);
91
101
  const summary = await getSummary(accessor);
92
102
  return jsonResult({
93
103
  archiveId,
94
104
  baseUrl: summary.baseUrl,
95
105
  roots: summary.roots,
96
106
  totalPages: summary.totalPages,
107
+ // Surface the source kind so an LLM caller knows whether
108
+ // the data is finalised or a moving snapshot.
109
+ mode,
110
+ // PID of a crawler currently writing the stub (when
111
+ // detectable). `null` for finished archives and
112
+ // interrupted-but-no-longer-running crawls.
113
+ crawlerPid: crawlerLockHolder?.alive ? crawlerLockHolder.pid : null,
97
114
  });
98
115
  }
99
116
  case 'close_archive': {
@@ -177,6 +194,67 @@ export function createServer() {
177
194
  const accessor = manager.get(requireString(args, 'archiveId'));
178
195
  return jsonResult(await checkHeaders(accessor, omit(args, 'archiveId')));
179
196
  }
197
+ case 'list_isolated_pages': {
198
+ const accessor = manager.get(requireString(args, 'archiveId'));
199
+ return jsonResult(await listIsolatedPages(accessor, {
200
+ limit: optionalNumber(args, 'limit'),
201
+ offset: optionalNumber(args, 'offset'),
202
+ }));
203
+ }
204
+ case 'list_unused_resources': {
205
+ const accessor = manager.get(requireString(args, 'archiveId'));
206
+ return jsonResult(await listUnusedResources(accessor, {
207
+ limit: optionalNumber(args, 'limit'),
208
+ offset: optionalNumber(args, 'offset'),
209
+ }));
210
+ }
211
+ case 'list_pages_by_tag': {
212
+ const accessor = manager.get(requireString(args, 'archiveId'));
213
+ return jsonResult(await listPagesByTag(accessor, {
214
+ provider: requireString(args, 'provider'),
215
+ externalId: typeof args.externalId === 'string' ? args.externalId : undefined,
216
+ limit: optionalNumber(args, 'limit'),
217
+ offset: optionalNumber(args, 'offset'),
218
+ }));
219
+ }
220
+ case 'count_pages_by_tag': {
221
+ const accessor = manager.get(requireString(args, 'archiveId'));
222
+ return jsonResult(await countPagesByTag(accessor, {
223
+ provider: requireString(args, 'provider'),
224
+ externalId: typeof args.externalId === 'string' ? args.externalId : undefined,
225
+ }));
226
+ }
227
+ case 'list_pages_by_jsonld_type': {
228
+ const accessor = manager.get(requireString(args, 'archiveId'));
229
+ return jsonResult(await listPagesByJsonLdType(accessor, {
230
+ type: requireString(args, 'type'),
231
+ limit: optionalNumber(args, 'limit'),
232
+ offset: optionalNumber(args, 'offset'),
233
+ }));
234
+ }
235
+ case 'count_pages_by_jsonld_type': {
236
+ const accessor = manager.get(requireString(args, 'archiveId'));
237
+ return jsonResult(await countPagesByJsonLdType(accessor, {
238
+ type: requireString(args, 'type'),
239
+ }));
240
+ }
241
+ case 'get_tag_inventory': {
242
+ const accessor = manager.get(requireString(args, 'archiveId'));
243
+ return jsonResult(await getTagInventory(accessor));
244
+ }
245
+ case 'get_page_jsonld': {
246
+ const accessor = manager.get(requireString(args, 'archiveId'));
247
+ const slim = typeof args.slim === 'boolean' ? args.slim : true;
248
+ return jsonResult(await getPageJsonLd(accessor, requireString(args, 'url'), slim));
249
+ }
250
+ case 'get_page_jsonld_overview': {
251
+ const accessor = manager.get(requireString(args, 'archiveId'));
252
+ return jsonResult(await getPageJsonLdOverview(accessor, requireString(args, 'url')));
253
+ }
254
+ case 'get_page_tags': {
255
+ const accessor = manager.get(requireString(args, 'archiveId'));
256
+ return jsonResult(await getPageTags(accessor, requireString(args, 'url')));
257
+ }
180
258
  default: {
181
259
  return {
182
260
  content: [{ type: 'text', text: `Unknown tool: ${name}` }],
@@ -6,13 +6,13 @@
6
6
  export const toolDefinitions = [
7
7
  {
8
8
  name: 'open_archive',
9
- description: 'Load a .nitpicker archive file for querying. Returns an archiveId to use with other tools. Always call this first before using any other tools.',
9
+ description: 'Load a Nitpicker archive source for querying. Accepts either a finished `.nitpicker` archive file OR a crawl stub directory (an `._nitpicker-*` working directory left behind when a crawl is interrupted). Returns an archiveId, the detected `mode` (`"archive"` or `"stub"`), and `crawlerPid` (the PID of a crawler currently writing the stub, or `null` for finished archives and interrupted-but-no-longer-running crawls). When `mode === "stub"`, treat the data as a point-in-time snapshot: any counts/violations may shift if the user resumes the crawl. Always call this first before using any other tools.',
10
10
  inputSchema: {
11
11
  type: 'object',
12
12
  properties: {
13
13
  filePath: {
14
14
  type: 'string',
15
- description: 'Absolute or relative path to the .nitpicker archive file',
15
+ description: 'Absolute or relative path to a `.nitpicker` archive file OR a crawl stub directory (containing `db.sqlite`).',
16
16
  },
17
17
  },
18
18
  required: ['filePath'],
@@ -34,7 +34,7 @@ export const toolDefinitions = [
34
34
  },
35
35
  {
36
36
  name: 'get_summary',
37
- description: 'Get site-wide overview: total pages, internal/external counts, HTTP status distribution, and metadata fulfillment rates (title, description, OG tags). Use this first to understand the archive contents.',
37
+ description: 'Get site-wide overview. Returns: internal/external HTML page counts (`internalPages` / `externalPages`), internal/external content-row counts across every MIME (`internalContents` / `externalContents` — HTML + PDF + Office docs + CSVs + archives + ...), HTTP status distribution, Content-Type distribution over 18 categories (html, pdf, csv, word, excel, powerpoint, image, css, javascript, json+yaml, xml, font, audio, video, archive, text, other, unknown), and metadata fulfillment rates (title, description, OG tags) for internal HTML pages only. `internalContents` is always >= `internalPages` (the latter applies the historical HTML-or-null filter, the former does not). Use this first to understand the archive contents.',
38
38
  inputSchema: {
39
39
  type: 'object',
40
40
  properties: {
@@ -48,7 +48,7 @@ export const toolDefinitions = [
48
48
  },
49
49
  {
50
50
  name: 'list_pages',
51
- description: 'List pages with rich filtering: by status code (exact or range), missing metadata (title, description), noindex flag, URL patterns, directory paths. Supports sorting and pagination. Use for questions like "show me all 404 pages" or "pages without descriptions".',
51
+ description: 'List pages with rich filtering: by status code (exact or range), missing metadata (title, description), noindex flag, URL patterns, directory paths. Supports sorting and pagination. Use for questions like "show me all 404 pages" or "pages without descriptions". For large sites, set `limit` to keep the response bounded — to dump the whole list use the CLI (`nitpicker query pages`) and pipe through `jq` instead of pulling everything through MCP.',
52
52
  inputSchema: {
53
53
  type: 'object',
54
54
  properties: {
@@ -75,6 +75,30 @@ export const toolDefinitions = [
75
75
  description: 'Filter to pages missing description',
76
76
  },
77
77
  noindex: { type: 'boolean', description: 'Filter to pages with noindex set' },
78
+ contentTypeCategory: {
79
+ type: 'string',
80
+ enum: [
81
+ 'html',
82
+ 'pdf',
83
+ 'csv',
84
+ 'word',
85
+ 'excel',
86
+ 'powerpoint',
87
+ 'image',
88
+ 'css',
89
+ 'javascript',
90
+ 'json',
91
+ 'xml',
92
+ 'font',
93
+ 'audio',
94
+ 'video',
95
+ 'archive',
96
+ 'text',
97
+ 'other',
98
+ 'unknown',
99
+ ],
100
+ description: 'Restrict to one Content-Type category. When set, the default HTML-or-null base filter is relaxed so non-HTML categories (PDF, image, archive…) become reachable through this listing — useful for audits like "show every PDF in scope". csv groups .csv + .tsv; word groups .doc + .docx; excel groups .xls + .xlsx; powerpoint groups .ppt + .pptx; json groups JSON + YAML; text groups .txt + .md.',
101
+ },
78
102
  urlPattern: {
79
103
  type: 'string',
80
104
  description: 'URL pattern to search (SQL LIKE: use % as wildcard)',
@@ -98,7 +122,7 @@ export const toolDefinitions = [
98
122
  },
99
123
  {
100
124
  name: 'get_page_detail',
101
- description: 'Get full details for a specific page URL: all metadata (title, description, OG, Twitter), outbound links, inbound links, redirects, response headers. Use when drilling down into a specific page.',
125
+ description: 'Get full details for a specific page URL: ~47 flat meta fields (title, description, OG, Twitter, robots, link, charset, manifest, themeColor, fb_app_id, verification_google, format_detection, og:image:alt/width/height, og:locale, og:article timestamps, twitter:site/creator, etc.), `metaExtras` JSON (referrer, viewport parsed, httpEquiv, apple, msapplication, verification.{bing|yandex|...}, geo, citation, hreflang alternates, others.*, originTrial), JSON-LD/SpeculationRules **summary** (count + unique @types + parseErrorCount), Wappalyzer tag **summary** (count + provider→ids map), outbound/inbound links, redirect sources, response headers, and within-archive timestamps (firstCrawledAt / lastCrawledAt). Raw JSON-LD entries and full tag rows are NOT included — fetch them via `get_page_jsonld` / `get_page_tags`. Use when drilling down into a specific page.',
102
126
  inputSchema: {
103
127
  type: 'object',
104
128
  properties: {
@@ -291,6 +315,147 @@ export const toolDefinitions = [
291
315
  required: ['archiveId', 'resourceUrl'],
292
316
  },
293
317
  },
318
+ {
319
+ name: 'list_pages_by_tag',
320
+ description: 'List pages that have a Wappalyzer-detected tag matching the given `provider` (and optionally a specific `externalId` like a GTM container ID or GA4 measurement ID). Returns the same shape as `list_pages`. Before pulling the full list, consider calling `count_pages_by_tag` to size-check — on a large site GTM may cover most pages and the response can run into MB. For full bulk extraction prefer the CLI: `nitpicker query pages-by-tag --provider "Google Tag Manager" | jq`.',
321
+ inputSchema: {
322
+ type: 'object',
323
+ properties: {
324
+ archiveId: {
325
+ type: 'string',
326
+ description: 'The archive ID returned by open_archive',
327
+ },
328
+ provider: {
329
+ type: 'string',
330
+ description: 'Wappalyzer provider name (e.g. "Google Tag Manager", "Google Analytics 4")',
331
+ },
332
+ externalId: {
333
+ type: 'string',
334
+ description: 'Optional external identifier extracted from the page (GTM-XXXX / G-XXXX / …). Omit for any.',
335
+ },
336
+ limit: { type: 'number', description: 'Max results (default: 100)' },
337
+ offset: { type: 'number', description: 'Results to skip (default: 0)' },
338
+ },
339
+ required: ['archiveId', 'provider'],
340
+ },
341
+ },
342
+ {
343
+ name: 'count_pages_by_tag',
344
+ description: 'Lightweight count-only sibling of `list_pages_by_tag`. Returns `{ pageCount }` for the given provider (and optional `externalId`). Use this to size-check before fetching the full list.',
345
+ inputSchema: {
346
+ type: 'object',
347
+ properties: {
348
+ archiveId: {
349
+ type: 'string',
350
+ description: 'The archive ID returned by open_archive',
351
+ },
352
+ provider: { type: 'string', description: 'Wappalyzer provider name' },
353
+ externalId: {
354
+ type: 'string',
355
+ description: 'Optional external identifier (GTM-XXXX / G-XXXX / …)',
356
+ },
357
+ },
358
+ required: ['archiveId', 'provider'],
359
+ },
360
+ },
361
+ {
362
+ name: 'list_pages_by_jsonld_type',
363
+ description: 'List pages with at least one JSON-LD entry having the given top-level `@type` (e.g. "Product", "BreadcrumbList", "FAQPage"). Returns the same shape as `list_pages`. Before pulling the full list, consider calling `count_pages_by_jsonld_type` — on an e-commerce site "Product" may match thousands of pages. For full bulk extraction prefer the CLI: `nitpicker query pages-by-jsonld-type --type Product | jq`.',
364
+ inputSchema: {
365
+ type: 'object',
366
+ properties: {
367
+ archiveId: {
368
+ type: 'string',
369
+ description: 'The archive ID returned by open_archive',
370
+ },
371
+ type: {
372
+ type: 'string',
373
+ description: 'Top-level JSON-LD `@type` value to filter by (e.g. "Product")',
374
+ },
375
+ limit: { type: 'number', description: 'Max results (default: 100)' },
376
+ offset: { type: 'number', description: 'Results to skip (default: 0)' },
377
+ },
378
+ required: ['archiveId', 'type'],
379
+ },
380
+ },
381
+ {
382
+ name: 'count_pages_by_jsonld_type',
383
+ description: 'Lightweight count-only sibling of `list_pages_by_jsonld_type`. Returns `{ pageCount }` for the given JSON-LD `@type`. Use to size-check before fetching the full list.',
384
+ inputSchema: {
385
+ type: 'object',
386
+ properties: {
387
+ archiveId: {
388
+ type: 'string',
389
+ description: 'The archive ID returned by open_archive',
390
+ },
391
+ type: { type: 'string', description: 'Top-level JSON-LD `@type` value' },
392
+ },
393
+ required: ['archiveId', 'type'],
394
+ },
395
+ },
396
+ {
397
+ name: 'get_tag_inventory',
398
+ description: 'Returns the site-wide Wappalyzer technology inventory: one entry per detected provider, with the count of distinct pages where it was found, sorted by page count desc. Use as a "what tech does this site use?" answer for audit kick-offs. On 1M-page archives this can be MB-sized; for bulk consumption prefer the CLI: `nitpicker query tag-inventory | jq`.',
399
+ inputSchema: {
400
+ type: 'object',
401
+ properties: {
402
+ archiveId: {
403
+ type: 'string',
404
+ description: 'The archive ID returned by open_archive',
405
+ },
406
+ },
407
+ required: ['archiveId'],
408
+ },
409
+ },
410
+ {
411
+ name: 'get_page_jsonld',
412
+ description: 'Returns the JSON-LD / SpeculationRules entries for a page. Defaults to `slim=true` which omits the `raw` JSON text and the `parsed` object — only `kind`, `type`, `rawByteSize`, and `parseError` are returned per entry. Use `slim=false` for full raw payload, but be aware: an e-commerce product page can have 50 schemas × 50KB each. Before requesting `slim=false`, call `get_page_jsonld_overview` to see entry sizes. For full raw bulk extraction prefer the CLI: `nitpicker query page-jsonld --url <URL> --full | jq`.',
413
+ inputSchema: {
414
+ type: 'object',
415
+ properties: {
416
+ archiveId: {
417
+ type: 'string',
418
+ description: 'The archive ID returned by open_archive',
419
+ },
420
+ url: { type: 'string', description: 'The page URL' },
421
+ slim: {
422
+ type: 'boolean',
423
+ description: 'Omit `raw` and `parsed` (default true). Set to false for full payload.',
424
+ },
425
+ },
426
+ required: ['archiveId', 'url'],
427
+ },
428
+ },
429
+ {
430
+ name: 'get_page_jsonld_overview',
431
+ description: 'Lightweight overview of a page\'s JSON-LD: one entry per `<script type="application/ld+json">` or `<script type="speculationrules">` with `kind`, `type`, `rawByteSize`, and `parseError`. Designed as the "metadata before data" probe — see total bytes before fetching the full payload via `get_page_jsonld(slim=false)`.',
432
+ inputSchema: {
433
+ type: 'object',
434
+ properties: {
435
+ archiveId: {
436
+ type: 'string',
437
+ description: 'The archive ID returned by open_archive',
438
+ },
439
+ url: { type: 'string', description: 'The page URL' },
440
+ },
441
+ required: ['archiveId', 'url'],
442
+ },
443
+ },
444
+ {
445
+ name: 'get_page_tags',
446
+ description: 'Returns the Wappalyzer tag rows for a page (one per provider × external-id), with `categories`, `version`, `confidence`, and `sources` preserved. Use after `get_page_detail` returned a tags summary and you need provider details. Bounded payload (KB-scale per page); no slim mode needed.',
447
+ inputSchema: {
448
+ type: 'object',
449
+ properties: {
450
+ archiveId: {
451
+ type: 'string',
452
+ description: 'The archive ID returned by open_archive',
453
+ },
454
+ url: { type: 'string', description: 'The page URL' },
455
+ },
456
+ required: ['archiveId', 'url'],
457
+ },
458
+ },
294
459
  {
295
460
  name: 'check_headers',
296
461
  description: 'Check security HTTP headers (CSP, X-Frame-Options, X-Content-Type-Options, HSTS) for internal pages. Use missingOnly=true to find pages lacking security headers.',
@@ -311,4 +476,36 @@ export const toolDefinitions = [
311
476
  required: ['archiveId'],
312
477
  },
313
478
  },
479
+ {
480
+ name: 'list_isolated_pages',
481
+ description: 'List internal HTML pages that no other archived page anchors to (excluding archived roots). These are the "orphan landing pages" the recursive crawl could not reach via the link graph. Combine with `crawl --inventory` to surface pages that only exist on the server but are unreachable from the site map. Each row carries a `source` badge (`crawled` / `inventory-seed` / `inventory-discovered`) indicating how the page entered the archive.',
482
+ inputSchema: {
483
+ type: 'object',
484
+ properties: {
485
+ archiveId: {
486
+ type: 'string',
487
+ description: 'The archive ID returned by open_archive',
488
+ },
489
+ limit: { type: 'number', description: 'Max results (default: 100)' },
490
+ offset: { type: 'number', description: 'Results to skip (default: 0)' },
491
+ },
492
+ required: ['archiveId'],
493
+ },
494
+ },
495
+ {
496
+ name: 'list_unused_resources',
497
+ description: 'List internal sub-resources that no archived page references — candidates for deletion from the server. Each row carries a `source` badge so callers can distinguish files registered via `crawl --inventory` (no page ever loaded them) from files that were once referenced but lost their last referrer.',
498
+ inputSchema: {
499
+ type: 'object',
500
+ properties: {
501
+ archiveId: {
502
+ type: 'string',
503
+ description: 'The archive ID returned by open_archive',
504
+ },
505
+ limit: { type: 'number', description: 'Max results (default: 100)' },
506
+ offset: { type: 'number', description: 'Results to skip (default: 0)' },
507
+ },
508
+ required: ['archiveId'],
509
+ },
510
+ },
314
511
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitpicker/mcp-server",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "MCP server for querying .nitpicker archive files via AI assistants",
5
5
  "author": "D-ZERO",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@modelcontextprotocol/sdk": "1.12.1",
35
- "@nitpicker/query": "0.9.0"
35
+ "@nitpicker/query": "0.11.0"
36
36
  },
37
- "gitHead": "2d194c881f323de7555e0025f6291ded65450dae"
37
+ "gitHead": "b11dbe3691746b3cb980476808d1f745bc6d0e98"
38
38
  }