@nitpicker/mcp-server 0.24.0 → 0.25.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/README.md +8 -2
- package/lib/mcp-server.d.ts +2 -0
- package/lib/mcp-server.js +15 -15
- package/lib/tool-definitions.js +9 -41
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -21,6 +21,13 @@ Claude Desktop の設定ファイルに以下を追加します。
|
|
|
21
21
|
|
|
22
22
|
stdio トランスポートで起動し、`.nitpicker` アーカイブを開いてページ、リンク、リソース、分析結果などを問い合わせます。
|
|
23
23
|
|
|
24
|
+
`search_html` と `match_selector` は、クライアントがリクエストをキャンセルしたとき、または接続が切れたときに、走査を途中で止めます。
|
|
25
|
+
|
|
26
|
+
ネイティブ処理は、次の環境変数で調整できます。複数の呼び出しが並行したときは、上限を超えた分が順番に待ちます。正の整数でない値は、起動時にエラーにします。詳細は [@nitpicker/core](../core/README.md) を参照してください。
|
|
27
|
+
|
|
28
|
+
- `NITPICKER_NATIVE_THREADS`: スレッド数(既定は論理コア数)
|
|
29
|
+
- `NITPICKER_NATIVE_CONCURRENCY`: 同時に走らせる非同期のネイティブ呼び出しの数(既定は 1)
|
|
30
|
+
|
|
24
31
|
## 主なツール
|
|
25
32
|
|
|
26
33
|
| ツール | 説明 |
|
|
@@ -32,14 +39,13 @@ stdio トランスポートで起動し、`.nitpicker` アーカイブを開い
|
|
|
32
39
|
| `get_page_detail` | 指定ページの詳細 |
|
|
33
40
|
| `list_inbound_links` | 指定ページへの被リンク一覧 |
|
|
34
41
|
| `get_page_html` | HTMLスナップショット |
|
|
35
|
-
| `search_html` | 保存済みHTML
|
|
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
|
## 関連リンク
|
package/lib/mcp-server.d.ts
CHANGED
|
@@ -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 {
|
|
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, {
|
|
@@ -559,6 +554,8 @@ export function createServer() {
|
|
|
559
554
|
* This is the entry point for the `nitpicker-mcp` binary.
|
|
560
555
|
* @returns Resolves once the stdio transport is connected; the server then
|
|
561
556
|
* keeps serving requests until the process exits.
|
|
557
|
+
* @throws {Error} Before connecting, if `NITPICKER_NATIVE_THREADS` or
|
|
558
|
+
* `NITPICKER_NATIVE_CONCURRENCY` is not a positive integer.
|
|
562
559
|
* @example
|
|
563
560
|
* ```ts
|
|
564
561
|
* import { startServer } from '@nitpicker/mcp-server';
|
|
@@ -567,6 +564,9 @@ export function createServer() {
|
|
|
567
564
|
* ```
|
|
568
565
|
*/
|
|
569
566
|
export async function startServer() {
|
|
567
|
+
// Refuse a bad `NITPICKER_NATIVE_*` setting before the server accepts
|
|
568
|
+
// requests, not at the first search a client sends.
|
|
569
|
+
checkNativeExecutorConfig();
|
|
570
570
|
const server = createServer();
|
|
571
571
|
const transport = new StdioServerTransport();
|
|
572
572
|
await server.connect(transport);
|
package/lib/tool-definitions.js
CHANGED
|
@@ -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
|
|
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,
|
|
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
|
|
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
|
|
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"])`),
|
|
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.
|
|
3
|
+
"version": "0.25.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",
|
|
@@ -34,8 +34,9 @@
|
|
|
34
34
|
"clean": "tsc --build --clean"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@modelcontextprotocol/sdk": "1.
|
|
38
|
-
"@nitpicker/
|
|
37
|
+
"@modelcontextprotocol/sdk": "1.32.1",
|
|
38
|
+
"@nitpicker/archive": "0.25.0",
|
|
39
|
+
"@nitpicker/query": "0.25.0"
|
|
39
40
|
},
|
|
40
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "fb258acf112366504c6dbb44b69a25bbc528fa30"
|
|
41
42
|
}
|