@nitpicker/mcp-server 0.24.0 → 0.25.1

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/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @nitpicker/mcp-server
2
2
 
3
- `.nitpicker` アーカイブを Model Context Protocol (MCP) 経由で問い合わせるためのサーバーです。
3
+ `.nitpicker`アーカイブを Model Context Protocol (MCP) 経由で問い合わせるためのサーバーです。
4
4
 
5
- 内部では [@nitpicker/query](../query/README.md) を使い、AIアシスタントなどからアーカイブ内容を参照できるようにします。
5
+ 内部では[@nitpicker/query](../query/README.md)を使い、AIアシスタントなどからアーカイブ内容を参照できるようにします。
6
6
 
7
7
  ## セットアップ
8
8
 
@@ -19,27 +19,33 @@ Claude Desktop の設定ファイルに以下を追加します。
19
19
  }
20
20
  ```
21
21
 
22
- stdio トランスポートで起動し、`.nitpicker` アーカイブを開いてページ、リンク、リソース、分析結果などを問い合わせます。
22
+ stdio トランスポートで起動し、`.nitpicker`アーカイブを開いてページ、リンク、リソース、分析結果などを問い合わせます。
23
+
24
+ `search_html`と`match_selector`は、クライアントがリクエストをキャンセルしたとき、または接続が切れたときに、走査を途中で止めます。
25
+
26
+ ネイティブ処理は、次の環境変数で調整できます。複数の呼び出しが並行したときは、上限を超えた分が順番に待ちます。正の整数でない値は、起動時にエラーにします。詳細は[@nitpicker/core](../core/README.md)を参照してください。
27
+
28
+ - `NITPICKER_NATIVE_THREADS`: スレッド数(既定は論理コア数)
29
+ - `NITPICKER_NATIVE_CONCURRENCY`: 同時に走らせる非同期のネイティブ呼び出しの数(既定は 1)
23
30
 
24
31
  ## 主なツール
25
32
 
26
33
  | ツール | 説明 |
27
34
  | ----------------------------- | ----------------------------------------------------------------- |
28
- | `open_archive` | `.nitpicker` ファイルを開き、archiveIdを返す |
35
+ | `open_archive` | `.nitpicker`ファイルを開き、archiveIdを返す |
29
36
  | `close_archive` | アーカイブを閉じる |
30
37
  | `get_summary` | サイト全体の概要統計 |
31
38
  | `list_pages` | ページ一覧 |
32
39
  | `get_page_detail` | 指定ページの詳細 |
33
40
  | `list_inbound_links` | 指定ページへの被リンク一覧 |
34
41
  | `get_page_html` | HTMLスナップショット |
35
- | `search_html` | 保存済みHTMLの文字列/正規表現検索(analyze不要・書き込みなし) |
42
+ | `search_html` | 保存済みHTMLの文字列/正規表現検索(書き込みなし) |
36
43
  | `match_selector` | 保存済みHTMLにCSSセレクタ一致要素を持つページを列挙(構造で探す) |
37
44
  | `list_links` | リンク一覧(broken / external / 全件、URLパターンで絞り込み) |
38
45
  | `list_resources` | リソース一覧(URLパターン・Content-Typeカテゴリで絞り込み) |
39
46
  | `list_pages_by_resource` | 条件に一致するリソースを読み込むページ一覧(フォント利用など) |
40
47
  | `get_resource_host_inventory` | リソースのホスト別集計(サードパーティ依存の棚卸し) |
41
48
  | `list_images` | 画像一覧 |
42
- | `get_violations` | 分析プラグインの違反結果 |
43
49
  | `list_console_logs` | 捕捉したconsoleログ・ページエラー(内容ごとに全ページ横断で集約) |
44
50
 
45
51
  ## 関連リンク
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import { startServer } from '../lib/mcp-server.js';
3
3
 
4
- startServer();
4
+ await startServer();
@@ -52,6 +52,8 @@ export declare function createServer(): Server<{
52
52
  * This is the entry point for the `nitpicker-mcp` binary.
53
53
  * @returns Resolves once the stdio transport is connected; the server then
54
54
  * keeps serving requests until the process exits.
55
+ * @throws {Error} Before connecting, if `NITPICKER_NATIVE_THREADS` or
56
+ * `NITPICKER_NATIVE_CONCURRENCY` is not a positive integer.
55
57
  * @example
56
58
  * ```ts
57
59
  * import { startServer } from '@nitpicker/mcp-server';
package/lib/mcp-server.js CHANGED
@@ -1,7 +1,8 @@
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, countPagesByJsonLdType, CONTENT_TYPE_CATEGORIES, countPagesByTechnology, findDuplicateBodies, getDuplicatesFastPath, getHeaderChecksFastPath, getImagesFastPath, getIsolatedClusterFastPath, getMismatchesFastPath, getPageConsoleLogs, getPageDetail, getPageHtml, getPageJsonLd, getPageJsonLdOverview, getPageMainContents, getPageTechnologies, getResourceHostInventory, getResourceReferrers, getSummaryFastPath, getTechnologyInventoryFastPath, getViolations, listConsoleLogs, listDedupeCapEvents, listDuplicateBodyClusters, listInboundLinks, listIsolatedClustersFastPath, listIsolatedPagesFastPath, listLinks, listNetworkOutages, listPages, listPagesByJsonLdType, listPagesByResource, listPagesByTechnology, listResources, listUnusedResources, matchSelector, searchHtml, } from '@nitpicker/query';
4
+ import { checkNativeExecutorConfig } from '@nitpicker/archive/native-executor/check-native-executor-config';
5
+ import { ArchiveManager, countPagesByJsonLdType, CONTENT_TYPE_CATEGORIES, countPagesByTechnology, findDuplicateBodies, getDuplicatesFastPath, getHeaderChecksFastPath, getImagesFastPath, getIsolatedClusterFastPath, getMismatchesFastPath, getPageConsoleLogs, getPageDetail, getPageHtml, getPageJsonLd, getPageJsonLdOverview, getPageMainContents, getPageTechnologies, getResourceHostInventory, getResourceReferrers, getSummaryFastPath, getTechnologyInventoryFastPath, listConsoleLogs, listDedupeCapEvents, listDuplicateBodyClusters, listInboundLinks, listIsolatedClustersFastPath, listIsolatedPagesFastPath, listLinks, listNetworkOutages, listPages, listPagesByJsonLdType, listPagesByResource, listPagesByTechnology, listResources, listUnusedResources, matchSelector, searchHtml, } from '@nitpicker/query';
5
6
  import { formatExtractProgressLine } from './format-extract-progress-line.js';
6
7
  import { toolDefinitions } from './tool-definitions.js';
7
8
  /**
@@ -202,7 +203,11 @@ export function createServer() {
202
203
  });
203
204
  const server = new Server({ name: 'nitpicker', version: '0.13.0' }, { capabilities: { tools: {} } });
204
205
  server.setRequestHandler(ListToolsRequestSchema, () => Promise.resolve({ tools: toolDefinitions }));
205
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
206
+ server.setRequestHandler(CallToolRequestSchema, async (request,
207
+ // Optional so a handler called without a transport (the unit specs call
208
+ // it directly) still works; the SDK always passes it. `signal` aborts when
209
+ // the client cancels the request or the transport closes.
210
+ extra) => {
206
211
  const { name } = request.params;
207
212
  const args = request.params.arguments ?? {};
208
213
  try {
@@ -336,11 +341,13 @@ export function createServer() {
336
341
  const accessor = manager.get(requireString(args, 'archiveId'));
337
342
  return jsonResult(await searchHtml(accessor, {
338
343
  pattern: requireString(args, 'pattern'),
344
+ literal: optionalBoolean(args, 'literal'),
339
345
  urlPattern: optionalString(args, 'urlPattern'),
340
346
  directory: optionalString(args, 'directory'),
341
347
  snippetLength: optionalNumber(args, 'snippetLength'),
342
348
  limit: optionalNumber(args, 'limit'),
343
349
  offset: optionalNumber(args, 'offset'),
350
+ signal: extra?.signal,
344
351
  }));
345
352
  }
346
353
  case 'match_selector': {
@@ -351,25 +358,13 @@ export function createServer() {
351
358
  directory: optionalString(args, 'directory'),
352
359
  limit: optionalNumber(args, 'limit'),
353
360
  offset: optionalNumber(args, 'offset'),
361
+ signal: extra?.signal,
354
362
  }));
355
363
  }
356
364
  case 'list_images': {
357
365
  const accessor = manager.get(requireString(args, 'archiveId'));
358
366
  return jsonResult(await getImagesFastPath(accessor, omit(args, 'archiveId')));
359
367
  }
360
- case 'get_violations': {
361
- const accessor = manager.get(requireString(args, 'archiveId'));
362
- return jsonResult(await getViolations(accessor, {
363
- validator: optionalString(args, 'validator'),
364
- severity: optionalString(args, 'severity'),
365
- rule: optionalString(args, 'rule'),
366
- urlPattern: optionalString(args, 'urlPattern'),
367
- sortBy: optionalString(args, 'sortBy'),
368
- sortOrder: optionalString(args, 'sortOrder'),
369
- limit: optionalNumber(args, 'limit'),
370
- offset: optionalNumber(args, 'offset'),
371
- }));
372
- }
373
368
  case 'list_console_logs': {
374
369
  const accessor = manager.get(requireString(args, 'archiveId'));
375
370
  return jsonResult(await listConsoleLogs(accessor, {
@@ -387,7 +382,8 @@ export function createServer() {
387
382
  case 'find_duplicates': {
388
383
  const accessor = manager.get(requireString(args, 'archiveId'));
389
384
  const field = args.field
390
- ? validateEnum(String(args.field), VALID_DUPLICATE_FIELDS, 'field')
385
+ ? // `validateEnum` rejects anything that is not an allowed field name.
386
+ validateEnum(String(args.field), VALID_DUPLICATE_FIELDS, 'field')
391
387
  : undefined;
392
388
  return jsonResult(await getDuplicatesFastPath(accessor, {
393
389
  field,
@@ -559,6 +555,8 @@ export function createServer() {
559
555
  * This is the entry point for the `nitpicker-mcp` binary.
560
556
  * @returns Resolves once the stdio transport is connected; the server then
561
557
  * keeps serving requests until the process exits.
558
+ * @throws {Error} Before connecting, if `NITPICKER_NATIVE_THREADS` or
559
+ * `NITPICKER_NATIVE_CONCURRENCY` is not a positive integer.
562
560
  * @example
563
561
  * ```ts
564
562
  * import { startServer } from '@nitpicker/mcp-server';
@@ -567,6 +565,9 @@ export function createServer() {
567
565
  * ```
568
566
  */
569
567
  export async function startServer() {
568
+ // Refuse a bad `NITPICKER_NATIVE_*` setting before the server accepts
569
+ // requests, not at the first search a client sends.
570
+ checkNativeExecutorConfig();
570
571
  const server = createServer();
571
572
  const transport = new StdioServerTransport();
572
573
  await server.connect(transport);
@@ -7,7 +7,7 @@ import { CONTENT_TYPE_CATEGORIES, SUPPORTED_SELECTOR_GRAMMAR } from '@nitpicker/
7
7
  export const toolDefinitions = [
8
8
  {
9
9
  name: 'open_archive',
10
- 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
+ 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 may shift if the user resumes the crawl. Always call this first before using any other tools.',
11
11
  inputSchema: {
12
12
  type: 'object',
13
13
  properties: {
@@ -394,7 +394,7 @@ export const toolDefinitions = [
394
394
  },
395
395
  {
396
396
  name: 'search_html',
397
- description: 'Search the stored HTML snapshots of all pages for a string or regular expression, WITHOUT running an analyze plugin and without writing to the archive. The search runs on the raw markup `get_page_html` returns, so <script>, <style>, inline style and every attribute are searchable (e.g. `fonts.example.org`, `font-family`, `gtag(`, `/UA-\\d+-\\d+/`) — unlike the analyze-search plugin, which matches DOM text nodes only. `pattern` is a plain literal substring, or `/regex/flags` (flags g, i, m) for a regular expression. Returns matching pages in page-id order with matchCount and a whitespace-collapsed snippet around the first hit, plus `total`, `scannedSnapshots` and `candidatePages` (in-scope pages with a stored snapshot; if it is 0 or far below the page count, HTML was not stored and "no match" is meaningless). This is a linear scan over every distinct snapshot, so large archives can take tens of seconds: call once with `limit: 0` to size `total`, narrow with urlPattern/directory, and prefer the CLI for bulk extraction: `nitpicker query <file> search-html --pattern "..." | jq`. Cannot search CSS/JS file bodies (not stored). To find pages by DOM structure (a CSS selector) rather than by text, use `match_selector`.',
397
+ description: 'Search the stored HTML snapshots of all pages for a string or regular expression, without writing to the archive. The search runs on the raw markup `get_page_html` returns, so <script>, <style>, inline style and every attribute are searchable (e.g. `fonts.example.org`, `font-family`, `gtag(`, `/UA-\\d+-\\d+/`). `pattern` is a plain literal substring, or `/regex/flags` (pass `literal: true` to search text such as `/static/images/` as it is) for a regular expression in Rust `regex` syntax: no backreferences or look-around and no JavaScript-only syntax such as a bare `{` or `[^]` (rejected with an error that says which), `\\<` is a word boundary, matching in time linear in the page; the match unit is a Unicode scalar value (`.` matches an emoji once), `\\d` `\\w` `\\s` `\\b` follow Unicode, `.` stops at `\\r` and `\\n` (not at U+2028), `m` anchors at `\\n`, `\\r` and `\\r\\n`; flags `i` `m` `s` take effect, `g` and `u` are always on, `d` `v` `y` are rejected; `matchCount` counts non-overlapping matches. Returns matching pages in page-id order with matchCount and a snippet around the first hit (cut from the whitespace-collapsed page, snippetLength Unicode scalar values), plus `total`, `scannedSnapshots` and `candidatePages` (in-scope pages with a stored snapshot; if it is 0 or far below the page count, HTML was not stored and "no match" is meaningless). This is a linear scan over every distinct snapshot, so large archives can take tens of seconds: call once with `limit: 0` to size `total`, narrow with urlPattern/directory, and prefer the CLI for bulk extraction: `nitpicker query <file> search-html --pattern "..." | jq`. Cannot search CSS/JS file bodies (not stored). To find pages by DOM structure (a CSS selector) rather than by text, use `match_selector`.',
398
398
  inputSchema: {
399
399
  type: 'object',
400
400
  properties: {
@@ -404,7 +404,11 @@ export const toolDefinitions = [
404
404
  },
405
405
  pattern: {
406
406
  type: 'string',
407
- description: 'Literal substring, or /regex/flags (flags g, i, m) for a regular expression.',
407
+ description: 'Literal substring, or /regex/flags for a regular expression in Rust regex syntax (flags i, m, s; no backreferences or look-around).',
408
+ },
409
+ literal: {
410
+ type: 'boolean',
411
+ description: 'Take `pattern` as plain text even if it looks like /…/flags, e.g. to find the text `/static/images/` (default: false).',
408
412
  },
409
413
  urlPattern: {
410
414
  type: 'string',
@@ -416,7 +420,7 @@ export const toolDefinitions = [
416
420
  },
417
421
  snippetLength: {
418
422
  type: 'number',
419
- description: 'Snippet window size in characters (default: 160)',
423
+ description: 'Snippet window size in Unicode scalar values, a non-negative integer (default: 160; 0 gives an empty snippet).',
420
424
  },
421
425
  limit: {
422
426
  type: 'number',
@@ -429,7 +433,7 @@ export const toolDefinitions = [
429
433
  },
430
434
  {
431
435
  name: 'match_selector',
432
- description: 'Find pages whose stored HTML snapshot contains at least one element matching a CSS selector (e.g. `img:not([alt])`, `nav > a[href^="/products/"]`, `a[target="_blank"]:not([rel~="noopener"])`), WITHOUT running an analyze plugin and without writing to the archive. Use it to search by DOM structure; use `search_html` to search by text. It is an existence check per page: matching element positions and counts are not returned. Returns matching pages in page-id order as `{ pageId, url }`, plus `total`, `scannedSnapshots` and `candidatePages` (in-scope pages with a stored snapshot; if it is 0 or far below the page count, HTML was not stored and "no match" is meaningless). Only the subset of CSS that can be evaluated exactly in a single pass over the markup is supported; anything else is rejected with an error that lists this grammar, never approximated.\n\n' +
436
+ description: 'Find pages whose stored HTML snapshot contains at least one element matching a CSS selector (e.g. `img:not([alt])`, `nav > a[href^="/products/"]`, `a[target="_blank"]:not([rel~="noopener"])`), without writing to the archive. Use it to search by DOM structure; use `search_html` to search by text. It is an existence check per page: matching element positions and counts are not returned. Returns matching pages in page-id order as `{ pageId, url }`, plus `total`, `scannedSnapshots` and `candidatePages` (in-scope pages with a stored snapshot; if it is 0 or far below the page count, HTML was not stored and "no match" is meaningless). Only the subset of CSS that can be evaluated exactly in a single pass over the markup is supported; anything else is rejected with an error that lists this grammar, never approximated.\n\n' +
433
437
  SUPPORTED_SELECTOR_GRAMMAR +
434
438
  '\n\nThis is a linear scan over every distinct snapshot, so large archives can take tens of seconds: call once with `limit: 0` to size `total`, narrow with urlPattern/directory, and prefer the CLI for bulk extraction: `nitpicker query <file> match-selector --selector "..." | jq`. Cannot inspect CSS/JS file bodies (not stored).',
435
439
  inputSchema: {
@@ -492,42 +496,6 @@ export const toolDefinitions = [
492
496
  required: ['archiveId'],
493
497
  },
494
498
  },
495
- {
496
- name: 'get_violations',
497
- description: 'Get analysis violations from plugins (axe, markuplint, textlint). Filter by validator, severity, or rule. Use for accessibility and code quality reports.',
498
- inputSchema: {
499
- type: 'object',
500
- properties: {
501
- archiveId: {
502
- type: 'string',
503
- description: 'The archive ID returned by open_archive',
504
- },
505
- validator: {
506
- type: 'string',
507
- description: 'Filter by validator name (e.g., "axe", "markuplint", "textlint")',
508
- },
509
- severity: { type: 'string', description: 'Filter by severity level' },
510
- rule: { type: 'string', description: 'Filter by rule ID' },
511
- urlPattern: {
512
- type: 'string',
513
- description: 'Filter URLs by SQL LIKE pattern',
514
- },
515
- sortBy: {
516
- type: 'string',
517
- enum: ['url', 'validator', 'severity', 'rule', 'message', 'code'],
518
- description: 'Sort field',
519
- },
520
- sortOrder: {
521
- type: 'string',
522
- enum: ['asc', 'desc'],
523
- description: 'Sort direction',
524
- },
525
- limit: { type: 'number', description: 'Max results (default: 100)' },
526
- offset: { type: 'number', description: 'Results to skip (default: 0)' },
527
- },
528
- required: ['archiveId'],
529
- },
530
- },
531
499
  {
532
500
  name: 'list_console_logs',
533
501
  description: 'List distinct console messages / page errors captured during the crawl, aggregated across every page they occurred on. Each entry reports pageCount (distinct pages) and totalCount (total occurrences) — the same message logged by a shared framework on many pages collapses to one entry. Filter by type (e.g. "error", "warn", "pageerror" for uncaught exceptions). Use for finding site-wide JS errors.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitpicker/mcp-server",
3
- "version": "0.24.0",
3
+ "version": "0.25.1",
4
4
  "description": "MCP server for querying .nitpicker archive files via AI assistants",
5
5
  "author": "D-ZERO",
6
6
  "license": "Apache-2.0",
@@ -34,8 +34,9 @@
34
34
  "clean": "tsc --build --clean"
35
35
  },
36
36
  "dependencies": {
37
- "@modelcontextprotocol/sdk": "1.31.0",
38
- "@nitpicker/query": "0.24.0"
37
+ "@modelcontextprotocol/sdk": "1.32.2",
38
+ "@nitpicker/archive": "0.25.1",
39
+ "@nitpicker/query": "0.25.1"
39
40
  },
40
- "gitHead": "840a594573c4abe0aaff1257469b7f2108fcdb19"
41
+ "gitHead": "fa839178ea8f40e92fc742e0480c6cfbbb8fb01f"
41
42
  }