test-inventory-mcp 0.8.0 → 0.9.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/CHANGELOG.md +17 -0
- package/README.md +11 -6
- package/dist/page.js +3 -0
- package/dist/project.js +9 -8
- package/dist/saved-inventory.js +17 -2
- package/dist/server.js +9 -9
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# test-inventory-mcp
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#36](https://github.com/Huldoser/test-inventory-mcp/pull/36) [`204339e`](https://github.com/Huldoser/test-inventory-mcp/commit/204339e25feb6cc05f32d39f485724e7b85786f2) - Reject unknown tool arguments instead of silently ignoring misspelled filters. Report saved-inventory I/O failures with corrective messages rather than resolved host paths, and preserve cancellation reasons during file operations.
|
|
8
|
+
|
|
9
|
+
Tool input schemas now set additionalProperties to false. Clients must send only declared arguments; previously unknown keys were accepted and ignored.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#35](https://github.com/Huldoser/test-inventory-mcp/pull/35) [`9d6f384`](https://github.com/Huldoser/test-inventory-mcp/commit/9d6f384d5113fad1d8960a4c81bd599762393b2b) - Keep affected tests when related paths are filtered for a directory reached through an internal link or an absolute project path.
|
|
14
|
+
Keep dependencies on changed helpers elsewhere in the project when scanning a subdirectory. Refuse parent-directory components in brace and extglob alternatives.
|
|
15
|
+
|
|
16
|
+
Return a complete final page when dropping its cursor and paging hint lets the answer fit the size limit.
|
|
17
|
+
|
|
18
|
+
- [#37](https://github.com/Huldoser/test-inventory-mcp/pull/37) [`b5a81f3`](https://github.com/Huldoser/test-inventory-mcp/commit/b5a81f3a56c58c5d0d64fb1ebd2664fc9330ef61) - Require test-inventory ^0.10.1 so MCP scans include the released fixes for named describe callbacks, suite parent links, Playwright modifier aliases and config alias dependencies. Saved inventory diffs also ignore annotation and step line moves.
|
|
19
|
+
|
|
3
20
|
## 0.8.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ it, the one the project uses. Globs pick the files instead, as on test-inventory
|
|
|
16
16
|
**Claude Code**, in the project folder. `--scope project` writes `.mcp.json`, for everyone who works on the project:
|
|
17
17
|
|
|
18
18
|
```sh
|
|
19
|
-
claude mcp add --scope project test-inventory -- npx -y test-inventory-mcp@0.
|
|
19
|
+
claude mcp add --scope project test-inventory -- npx -y test-inventory-mcp@0.9 --framework playwright
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
**Cursor**, in `.cursor/mcp.json`:
|
|
@@ -26,7 +26,7 @@ claude mcp add --scope project test-inventory -- npx -y test-inventory-mcp@0.8 -
|
|
|
26
26
|
"mcpServers": {
|
|
27
27
|
"test-inventory": {
|
|
28
28
|
"command": "npx",
|
|
29
|
-
"args": ["-y", "test-inventory-mcp@0.
|
|
29
|
+
"args": ["-y", "test-inventory-mcp@0.9", "--framework", "playwright"]
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -40,7 +40,7 @@ claude mcp add --scope project test-inventory -- npx -y test-inventory-mcp@0.8 -
|
|
|
40
40
|
"test-inventory": {
|
|
41
41
|
"type": "stdio",
|
|
42
42
|
"command": "npx",
|
|
43
|
-
"args": ["-y", "test-inventory-mcp@0.
|
|
43
|
+
"args": ["-y", "test-inventory-mcp@0.9", "--framework", "playwright"]
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -79,6 +79,8 @@ test-inventory-mcp [--framework <name>] [<glob...>] [--root <dir>]
|
|
|
79
79
|
`related` takes the files a change touches, from the project root as `git diff --name-only` writes them, and keeps
|
|
80
80
|
the tests whose `dependencies` include one of them, and those that reach code the scan can't follow, as
|
|
81
81
|
test-inventory's [`--related`](https://huldoser.github.io/test-inventory/guide/cli#tests-a-change-can-affect) does.
|
|
82
|
+
The filter uses the actual scanned folder when `directory` names an internal link or an absolute path inside the project.
|
|
83
|
+
It also keeps tests that import a changed helper elsewhere in the project, outside that scanned folder.
|
|
82
84
|
`dependencies` can list hundreds of files, so it isn't among the default `fields`, and `get_tests` returns as many
|
|
83
85
|
tests as fit in one answer, with the other ids in `remaining`. An id stays the same when a test moves to another
|
|
84
86
|
line, and changes when its title, describes or file change.
|
|
@@ -90,8 +92,11 @@ each pass of a loop as its own test, with the name the runner gives it, as test-
|
|
|
90
92
|
the same `expandCases` as the `find_tests` call the ids came from. Records have the keys of test-inventory's
|
|
91
93
|
[output format](https://huldoser.github.io/test-inventory/reference/output).
|
|
92
94
|
|
|
95
|
+
Unknown tool arguments are refused with an error naming the unrecognized key, so misspelled filters are not silently ignored.
|
|
96
|
+
|
|
93
97
|
Answers are JSON, sent both as structured content and as text. Lists come 50 items at a time (`limit` takes up to
|
|
94
98
|
200), and an answer stays under about 30,000 characters; passing `nextCursor` back as `cursor` gets the next page.
|
|
99
|
+
A single oversized record is returned alone. A final page can fit more records because it needs no next-page cursor or hint.
|
|
95
100
|
`scanErrors` counts the problems that may leave tests out, and `hint` says what to do next when there is something to
|
|
96
101
|
say.
|
|
97
102
|
|
|
@@ -103,13 +108,13 @@ say.
|
|
|
103
108
|
framework, root, patterns, filters and `expandCases` setting for both scans. Hash comparisons and rename matching
|
|
104
109
|
need the exact same core version. Incomplete scans produce warnings. Zero changes returns an empty page and a hint.
|
|
105
110
|
Each saved file must be a regular file of at most 128 MiB. Save scans with the core CLI, without `--fields` or
|
|
106
|
-
`--format jsonl`; see [inventory diffs](https://huldoser.github.io/test-inventory/guide/diff).
|
|
111
|
+
`--format jsonl`; see [inventory diffs](https://huldoser.github.io/test-inventory/guide/diff). If a saved file disappears or becomes unreadable while opening it, the error names the supplied file and suggests checking its existence and readability, without exposing the resolved host path. Cancellation during these operations retains the request's cancellation reason.
|
|
107
112
|
|
|
108
113
|
## Security
|
|
109
114
|
|
|
110
115
|
The server reads the test files its globs match inside the project, or without globs those the configs run, and,
|
|
111
116
|
for Vitest, the files that symbolic links among them point to, as Vitest does. It reads the configs as code, without
|
|
112
|
-
running them. It refuses a `directory` or pattern that reaches outside the project, and refuses scan answers whose test files, configs or dependencies resolve outside it. Saved inventories must resolve inside the project too. The scanner may read a linked file before the answer is refused; this boundary is not a filesystem sandbox. It runs no code from the project, writes no files, and opens no network connections.
|
|
117
|
+
running them. It refuses a `directory` or pattern that reaches outside the project, including parent-directory components in brace or extglob alternatives, and refuses scan answers whose test files, configs or dependencies resolve outside it. Saved inventories must resolve inside the project too. The scanner may read a linked file before the answer is refused; this boundary is not a filesystem sandbox. It runs no code from the project, writes no files, and opens no network connections.
|
|
113
118
|
|
|
114
119
|
Answers hold text from the project's files, such as test titles, skip reasons and comments. A client should treat it
|
|
115
120
|
as content of that project, not as instructions. To report a vulnerability, see [SECURITY.md](SECURITY.md).
|
|
@@ -117,7 +122,7 @@ as content of that project, not as instructions. To report a vulnerability, see
|
|
|
117
122
|
## Versioning
|
|
118
123
|
|
|
119
124
|
Tool names, their arguments and their answers are the server's API. Before 1.0, a change that breaks them raises the
|
|
120
|
-
minor version, so `test-inventory-mcp@0.
|
|
125
|
+
minor version, so `test-inventory-mcp@0.9` in the setup above gets fixes only.
|
|
121
126
|
|
|
122
127
|
## License
|
|
123
128
|
|
package/dist/page.js
CHANGED
|
@@ -50,6 +50,9 @@ export function paginate(items, limit, cursor, answer) {
|
|
|
50
50
|
// The largest page that fits; a single item is returned even when it alone is larger.
|
|
51
51
|
let low = 1;
|
|
52
52
|
let high = Math.max(1, Math.min(limit, items.length - offset));
|
|
53
|
+
// The final page loses its cursor and paging hint, so it can fit even when a smaller page doesn't.
|
|
54
|
+
if (fits(high))
|
|
55
|
+
return build(high);
|
|
53
56
|
while (low < high) {
|
|
54
57
|
const middle = Math.ceil((low + high) / 2);
|
|
55
58
|
if (fits(middle))
|
package/dist/project.js
CHANGED
|
@@ -9,30 +9,31 @@ export function isInside(root, file) {
|
|
|
9
9
|
/**
|
|
10
10
|
* A pattern from a tool call stays inside the folder it is scanned from: no absolute path and no `..`. On Windows a
|
|
11
11
|
* backslash separates folders, and elsewhere it escapes the next character, so `.\./` is `../` to the glob; a pattern
|
|
12
|
-
* is refused when either reading leaves the folder, so the answer is the
|
|
12
|
+
* is refused when either reading leaves the folder, including brace and extglob alternatives, so the answer is the
|
|
13
|
+
* same on every system.
|
|
13
14
|
*/
|
|
14
15
|
function checkPattern(pattern) {
|
|
15
16
|
const unescaped = pattern.replaceAll(/\\(.)/gs, '$1');
|
|
16
17
|
if (path.posix.isAbsolute(unescaped) ||
|
|
17
18
|
path.win32.isAbsolute(pattern) ||
|
|
18
|
-
[...pattern.split(/[\\/]/), ...unescaped.split(
|
|
19
|
+
[...pattern.split(/[\\/]/), ...unescaped.split(/[/{}(),|]/)].includes('..')) {
|
|
19
20
|
throw new Error(`The pattern "${pattern}" reaches outside the folder it is scanned from. Patterns are relative to ` +
|
|
20
21
|
'`directory` (the project root by default) and cannot start with "/" or a drive, or contain "..".');
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Changed files from the project root, as `git diff --name-only` writes them, named as the scan of `directory` names
|
|
25
|
-
* them: from that folder. A
|
|
26
|
+
* them: from that folder. A helper elsewhere in the project can still be a dependency, named with `../`.
|
|
26
27
|
*/
|
|
27
|
-
export function relatedIn(directory, files) {
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
export async function relatedIn(root, directory, files) {
|
|
29
|
+
const real = directory === undefined ? root : await directoryIn(root, directory);
|
|
30
|
+
const folder = path.relative(root, real).split(path.sep).join('/');
|
|
31
|
+
return files.map((file) => {
|
|
30
32
|
if (path.posix.isAbsolute(file) || path.win32.isAbsolute(file) || file.split(/[\\/]/).includes('..')) {
|
|
31
33
|
throw new Error(`The file "${file}" is outside the project. Changed files are relative to the project root, as ` +
|
|
32
34
|
'`git diff --name-only` writes them, and cannot start with "/" or a drive, or contain "..".');
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
return relative.startsWith('../') ? [] : [relative];
|
|
36
|
+
return path.posix.relative(folder, path.posix.normalize(file.replaceAll('\\', '/')));
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
39
|
async function directoryIn(root, directory) {
|
package/dist/saved-inventory.js
CHANGED
|
@@ -3,6 +3,19 @@ import path from 'node:path';
|
|
|
3
3
|
import { isInside } from "./project.js";
|
|
4
4
|
/** Bounds the memory of parsing a saved scan before its schema is checked by the core. */
|
|
5
5
|
export const MAX_INVENTORY_BYTES = 128 * 1024 * 1024;
|
|
6
|
+
/** Keeps operating-system paths out of errors and preserves cancellation during a saved-file operation. */
|
|
7
|
+
async function readable(file, signal, read) {
|
|
8
|
+
try {
|
|
9
|
+
signal?.throwIfAborted();
|
|
10
|
+
const result = await read();
|
|
11
|
+
signal?.throwIfAborted();
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
signal?.throwIfAborted();
|
|
16
|
+
throw new Error(`The inventory "${file}" could not be read. Check that it still exists and is readable.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
6
19
|
/** Reads a complete JSON scan inside the server's project; its contents remain untrusted project data. */
|
|
7
20
|
export async function readInventory(root, file, signal) {
|
|
8
21
|
signal?.throwIfAborted();
|
|
@@ -11,17 +24,19 @@ export async function readInventory(root, file, signal) {
|
|
|
11
24
|
real = await realpath(path.resolve(root, file));
|
|
12
25
|
}
|
|
13
26
|
catch {
|
|
27
|
+
signal?.throwIfAborted();
|
|
14
28
|
throw new Error(`The inventory "${file}" does not exist. Pass a saved JSON scan inside the project.`);
|
|
15
29
|
}
|
|
30
|
+
signal?.throwIfAborted();
|
|
16
31
|
if (!isInside(root, real)) {
|
|
17
32
|
throw new Error(`The inventory "${file}" is outside the project. Pass a saved JSON scan inside it.`);
|
|
18
33
|
}
|
|
19
|
-
const info = await stat(real);
|
|
34
|
+
const info = await readable(file, signal, () => stat(real));
|
|
20
35
|
if (!info.isFile())
|
|
21
36
|
throw new Error(`The inventory "${file}" is not a file. Pass a saved JSON scan.`);
|
|
22
37
|
if (info.size > MAX_INVENTORY_BYTES)
|
|
23
38
|
throw new Error(`The inventory "${file}" exceeds 128 MiB. Save a smaller scan with matching patterns or filters for both revisions.`);
|
|
24
|
-
const content = await readFile(real, { encoding: 'utf8', signal });
|
|
39
|
+
const content = await readable(file, signal, () => readFile(real, { encoding: 'utf8', signal }));
|
|
25
40
|
try {
|
|
26
41
|
return JSON.parse(content);
|
|
27
42
|
}
|
package/dist/server.js
CHANGED
|
@@ -136,10 +136,10 @@ function hints(...parts) {
|
|
|
136
136
|
return given.length === 0 ? null : given.join(' ');
|
|
137
137
|
}
|
|
138
138
|
/** Filters the tests of a scan of `directory`, with changed files named from the project root. */
|
|
139
|
-
function filterTests(inventory, filter, directory) {
|
|
139
|
+
async function filterTests(inventory, filter, root, directory) {
|
|
140
140
|
const { related, ...rest } = filter;
|
|
141
141
|
try {
|
|
142
|
-
return filterInventory(inventory, related === undefined ? rest : { ...rest, related: relatedIn(directory, related) });
|
|
142
|
+
return filterInventory(inventory, related === undefined ? rest : { ...rest, related: await relatedIn(root, directory, related) });
|
|
143
143
|
}
|
|
144
144
|
catch (error) {
|
|
145
145
|
// test-inventory throws a TypeError for a filter it rejects, such as a grep that isn't a regular expression.
|
|
@@ -182,7 +182,7 @@ export function createServer(config) {
|
|
|
182
182
|
'the counts of each, sorted by name and paged with limit and cursor; a test with no tag is in no tag group, ' +
|
|
183
183
|
'and one whose projects the scan cannot tell in no project group. configs lists the config files read and ' +
|
|
184
184
|
'their projects. Example: {"states": ["skip", "fixme"], "groupBy": "file"}.',
|
|
185
|
-
inputSchema: z.
|
|
185
|
+
inputSchema: z.strictObject({
|
|
186
186
|
...scanArguments,
|
|
187
187
|
...testFilters,
|
|
188
188
|
groupBy: z
|
|
@@ -219,7 +219,7 @@ export function createServer(config) {
|
|
|
219
219
|
annotations: { title: 'Test summary', ...READ_ONLY },
|
|
220
220
|
}, ({ states, tags, grep, related, groupBy, limit, cursor, ...scan }, { mcpReq: { signal } }) => answer(async () => {
|
|
221
221
|
const inventory = await scanProject(config, scan, signal);
|
|
222
|
-
const matched = filterTests(inventory, { states, tags, grep, related }, scan.directory);
|
|
222
|
+
const matched = await filterTests(inventory, { states, tags, grep, related }, config.root, scan.directory);
|
|
223
223
|
const base = { ...scanOutput(inventory), summary: matched.summary, configs: inventory.configs };
|
|
224
224
|
if (groupBy === undefined) {
|
|
225
225
|
return {
|
|
@@ -257,7 +257,7 @@ export function createServer(config) {
|
|
|
257
257
|
'Filters combine with AND; a list matches ' +
|
|
258
258
|
'any of its values. fields picks other keys of the test records (id is always there). Answers are paged: ' +
|
|
259
259
|
'follow nextCursor, or narrow the filters. Example: {"states": ["skip"], "withoutReason": true}.',
|
|
260
|
-
inputSchema: z.
|
|
260
|
+
inputSchema: z.strictObject({
|
|
261
261
|
...scanArguments,
|
|
262
262
|
...testFilters,
|
|
263
263
|
projects: z
|
|
@@ -288,7 +288,7 @@ export function createServer(config) {
|
|
|
288
288
|
annotations: { title: 'Find tests', ...READ_ONLY },
|
|
289
289
|
}, ({ states, tags, grep, related, projects, only, withoutReason, fields, limit, cursor, ...scan }, { mcpReq: { signal } }) => answer(async () => {
|
|
290
290
|
const inventory = await scanProject(config, scan, signal);
|
|
291
|
-
const matched = filterTests(inventory, { states, tags, grep, related, only, withoutReason }, scan.directory);
|
|
291
|
+
const matched = await filterTests(inventory, { states, tags, grep, related, only, withoutReason }, config.root, scan.directory);
|
|
292
292
|
const run = projects
|
|
293
293
|
? matched.tests.filter((test) => test.projects?.some((name) => projects.includes(name)))
|
|
294
294
|
: matched.tests;
|
|
@@ -317,7 +317,7 @@ export function createServer(config) {
|
|
|
317
317
|
'title, describe or file changes; ids not in the current scan are returned in notFound. Example: ' +
|
|
318
318
|
'{"ids": ["3f9a0c1d2e4b5a69"]}. An answer that would be too long returns the first tests and the other ids in ' +
|
|
319
319
|
'remaining.',
|
|
320
|
-
inputSchema: z.
|
|
320
|
+
inputSchema: z.strictObject({
|
|
321
321
|
...scanArguments,
|
|
322
322
|
ids: z.array(z.string().min(1)).min(1).max(20).describe('Test ids, as find_tests returns them.'),
|
|
323
323
|
}),
|
|
@@ -373,7 +373,7 @@ export function createServer(config) {
|
|
|
373
373
|
'at run time, a file no config runs). They are ' +
|
|
374
374
|
'about reading the code, not test failures. Use it when another tool reports scanErrors, or to check why a ' +
|
|
375
375
|
'test is missing or notLoaded. Answers are paged: follow nextCursor. Example: {"levels": ["error"]}.',
|
|
376
|
-
inputSchema: z.
|
|
376
|
+
inputSchema: z.strictObject({
|
|
377
377
|
...scanArguments,
|
|
378
378
|
levels: z.array(z.enum(DIAGNOSTIC_LEVELS)).min(1).optional().describe('Keeps problems of these levels.'),
|
|
379
379
|
codes: z.array(z.enum(DIAGNOSTIC_CODES)).min(1).optional().describe('Keeps problems with these codes.'),
|
|
@@ -415,7 +415,7 @@ export function createServer(config) {
|
|
|
415
415
|
'Use the same framework, root, patterns, filters and expandCases for both saved scans. Hash comparisons and rename matching ' +
|
|
416
416
|
'are disabled across tool versions. Follow nextCursor for more changes. For Playwright, Vitest, Jest, Mocha, Jasmine, ' +
|
|
417
417
|
'Cypress, WebdriverIO, node:test and Bun inventories. Example: {"before":"inventories/base.json","after":"inventories/head.json"}.',
|
|
418
|
-
inputSchema: z.
|
|
418
|
+
inputSchema: z.strictObject({
|
|
419
419
|
before: z
|
|
420
420
|
.string()
|
|
421
421
|
.min(1)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "test-inventory-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "MCP server for test-inventory: AI agents ask which Playwright, Vitest, Jest, Mocha, Jasmine, Cypress, WebdriverIO, node:test and Bun tests a project has, which are skipped and why, and which a change can affect, without running them.",
|
|
5
5
|
"mcpName": "io.github.Huldoser/test-inventory",
|
|
6
6
|
"keywords": [
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
80
|
-
"test-inventory": "^0.10.
|
|
80
|
+
"test-inventory": "^0.10.1",
|
|
81
81
|
"zod": "^4.6.7"
|
|
82
82
|
}
|
|
83
83
|
}
|