test-inventory-mcp 0.8.0 → 0.9.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/CHANGELOG.md +32 -0
- package/README.md +68 -10
- package/dist/page.js +3 -0
- package/dist/project.js +9 -8
- package/dist/saved-inventory.js +17 -2
- package/dist/server.js +13 -10
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# test-inventory-mcp
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#40](https://github.com/Huldoser/test-inventory-mcp/pull/40) [`5560a57`](https://github.com/Huldoser/test-inventory-mcp/commit/5560a579ee0436e7d6346e176ecc193a8977e5bf) - Clarify that withoutReason includes expected failures and does not establish whether a test executes. Document all
|
|
8
|
+
five tools, add setup verification and troubleshooting, and distinguish server-local operation from installation,
|
|
9
|
+
client data handling and filesystem isolation.
|
|
10
|
+
|
|
11
|
+
- [#41](https://github.com/Huldoser/test-inventory-mcp/pull/41) [`2837d6c`](https://github.com/Huldoser/test-inventory-mcp/commit/2837d6c3b89c2009d5335eeab4f77e00ed89e3ad) - Generate the five-tool reference from server schemas and real fixture calls, with complete results, pagination,
|
|
12
|
+
empty matches and corrective errors. Check the generated reference and documented workflows in the test suite.
|
|
13
|
+
|
|
14
|
+
- [#42](https://github.com/Huldoser/test-inventory-mcp/pull/42) [`bd89da4`](https://github.com/Huldoser/test-inventory-mcp/commit/bd89da4970b014ef5b4203e5c5eb8a746efd3157) - Require test-inventory 0.10.2 so MCP scans receive the named node:test context, subtest parent link, linked-folder,
|
|
15
|
+
concurrency, missing Jest preset and malformed TOML fixes. Regenerate the tool reference with the released core.
|
|
16
|
+
Refresh the tool output-schema descriptions for config selection, active state and inherited retries.
|
|
17
|
+
|
|
18
|
+
## 0.9.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- [#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.
|
|
23
|
+
|
|
24
|
+
Tool input schemas now set additionalProperties to false. Clients must send only declared arguments; previously unknown keys were accepted and ignored.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- [#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.
|
|
29
|
+
Keep dependencies on changed helpers elsewhere in the project when scanning a subdirectory. Refuse parent-directory components in brace and extglob alternatives.
|
|
30
|
+
|
|
31
|
+
Return a complete final page when dropping its cursor and paging hint lets the answer fit the size limit.
|
|
32
|
+
|
|
33
|
+
- [#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.
|
|
34
|
+
|
|
3
35
|
## 0.8.0
|
|
4
36
|
|
|
5
37
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -4,11 +4,15 @@ An MCP server for [test-inventory](https://github.com/Huldoser/test-inventory):
|
|
|
4
4
|
has, which are skipped and why, and which tests a change can affect, without running them.
|
|
5
5
|
|
|
6
6
|
It reads Playwright, Vitest, Jest, Mocha, Jasmine, Cypress, WebdriverIO, node:test and Bun test files with
|
|
7
|
-
test-inventory and answers from their source code.
|
|
8
|
-
|
|
7
|
+
test-inventory and answers from their source code. The running server executes no project code, writes no files and
|
|
8
|
+
opens no network connections. Installation through `npx` may download packages. Answers are passed to the MCP
|
|
9
|
+
client; its model provider and privacy settings determine what happens to that text next.
|
|
9
10
|
|
|
10
11
|
## Setup
|
|
11
12
|
|
|
13
|
+
The server requires test-inventory 0.10.2 or a later 0.10 patch, including its
|
|
14
|
+
[Node context/concurrency, Jest preset and TOML fixes](https://github.com/Huldoser/test-inventory/releases/tag/v0.10.2).
|
|
15
|
+
|
|
12
16
|
Node.js 22.12 or newer. The client starts the server with `npx` and talks to it over standard input and output. The
|
|
13
17
|
server scans the test files your test runner's config runs, with the runner `--framework` names or, without
|
|
14
18
|
it, the one the project uses. Globs pick the files instead, as on test-inventory's command line.
|
|
@@ -16,7 +20,7 @@ it, the one the project uses. Globs pick the files instead, as on test-inventory
|
|
|
16
20
|
**Claude Code**, in the project folder. `--scope project` writes `.mcp.json`, for everyone who works on the project:
|
|
17
21
|
|
|
18
22
|
```sh
|
|
19
|
-
claude mcp add --scope project test-inventory -- npx -y test-inventory-mcp@0.
|
|
23
|
+
claude mcp add --scope project test-inventory -- npx -y test-inventory-mcp@0.9 --framework playwright
|
|
20
24
|
```
|
|
21
25
|
|
|
22
26
|
**Cursor**, in `.cursor/mcp.json`:
|
|
@@ -26,7 +30,7 @@ claude mcp add --scope project test-inventory -- npx -y test-inventory-mcp@0.8 -
|
|
|
26
30
|
"mcpServers": {
|
|
27
31
|
"test-inventory": {
|
|
28
32
|
"command": "npx",
|
|
29
|
-
"args": ["-y", "test-inventory-mcp@0.
|
|
33
|
+
"args": ["-y", "test-inventory-mcp@0.9", "--framework", "playwright"]
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
36
|
}
|
|
@@ -40,7 +44,7 @@ claude mcp add --scope project test-inventory -- npx -y test-inventory-mcp@0.8 -
|
|
|
40
44
|
"test-inventory": {
|
|
41
45
|
"type": "stdio",
|
|
42
46
|
"command": "npx",
|
|
43
|
-
"args": ["-y", "test-inventory-mcp@0.
|
|
47
|
+
"args": ["-y", "test-inventory-mcp@0.9", "--framework", "playwright"]
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
}
|
|
@@ -53,6 +57,18 @@ wants other files than the configs run.
|
|
|
53
57
|
The project is the folder given with `--root`, otherwise the one Claude Code names in `CLAUDE_PROJECT_DIR`, otherwise
|
|
54
58
|
the folder the client starts the server in.
|
|
55
59
|
|
|
60
|
+
### Verify the setup
|
|
61
|
+
|
|
62
|
+
1. Open your client's MCP server list and confirm that `test-inventory` is connected. In Claude Code use `/mcp`;
|
|
63
|
+
in VS Code run **MCP: List Servers** from the Command Palette; in Cursor open its MCP settings.
|
|
64
|
+
2. Confirm the five tools below are available, then ask: "Use test-inventory to summarize this project's tests."
|
|
65
|
+
3. Check that `test_summary` reports the expected framework and file counts. If it reports `scanErrors`, ask the
|
|
66
|
+
agent to call `scan_diagnostics` before trusting the counts.
|
|
67
|
+
|
|
68
|
+
Try "List tests marked fixme, with their conditions and reasons" or "Which tests may be affected by a change to
|
|
69
|
+
pages/orders-blotter.ts?" A conditional skip is not proof a test was skipped in a run. Expected-to-fail tests run;
|
|
70
|
+
their non-active state does not mean they are disabled. See [key concepts](https://huldoser.github.io/test-inventory/guide/concepts).
|
|
71
|
+
|
|
56
72
|
## Command line
|
|
57
73
|
|
|
58
74
|
```text
|
|
@@ -69,29 +85,53 @@ test-inventory-mcp [--framework <name>] [<glob...>] [--root <dir>]
|
|
|
69
85
|
|
|
70
86
|
## Tools
|
|
71
87
|
|
|
88
|
+
The generated [tool reference](https://github.com/Huldoser/test-inventory-mcp/blob/main/docs/tools.md) lists each argument's type, default and bounds, response fields,
|
|
89
|
+
complete request/response examples, pagination and errors. It is checked against the running server in tests.
|
|
90
|
+
|
|
72
91
|
| Tool | Answers |
|
|
73
92
|
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
74
93
|
| `test_summary` | Counts by state, tag and annotation, and the configs with their projects; with `groupBy`, the counts of each file, tag or project. |
|
|
75
94
|
| `find_tests` | The tests that match `states`, `tags`, `grep`, `related`, `projects`, `only` or `withoutReason`, with the `fields` you pick. |
|
|
76
95
|
| `get_tests` | Every key of up to 20 tests by `ids`, with the scan's diagnostics about them; ids it can't find come back in `notFound`. |
|
|
77
96
|
| `scan_diagnostics` | The problems the scan found, such as a file that failed to parse, by `levels`, `codes` or `path`. |
|
|
97
|
+
| `diff_inventories` | Changes between saved scans named by `before` and `after`, including renames, moves and newly declared skip states. |
|
|
98
|
+
|
|
99
|
+
A typical call sequence is `test_summary`, `find_tests`, then `get_tests` for a few returned ids. For example, the
|
|
100
|
+
arguments to `find_tests` can be:
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"states": ["skip", "fixme"],
|
|
105
|
+
"fields": ["fullName", "state", "condition", "reason"],
|
|
106
|
+
"limit": 10
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The answer contains matching `tests`, their `total`, `scanErrors`, `nextCursor` and `hint`, plus the framework and its
|
|
111
|
+
version. The records have selected keys and their `id`. Pass a non-null `nextCursor` as `cursor` with the same other
|
|
112
|
+
arguments to read another page; a narrow filter returning zero tests is a valid result.
|
|
78
113
|
|
|
79
114
|
`related` takes the files a change touches, from the project root as `git diff --name-only` writes them, and keeps
|
|
80
115
|
the tests whose `dependencies` include one of them, and those that reach code the scan can't follow, as
|
|
81
116
|
test-inventory's [`--related`](https://huldoser.github.io/test-inventory/guide/cli#tests-a-change-can-affect) does.
|
|
117
|
+
The filter uses the actual scanned folder when `directory` names an internal link or an absolute path inside the project.
|
|
118
|
+
It also keeps tests that import a changed helper elsewhere in the project, outside that scanned folder.
|
|
82
119
|
`dependencies` can list hundreds of files, so it isn't among the default `fields`, and `get_tests` returns as many
|
|
83
120
|
tests as fit in one answer, with the other ids in `remaining`. An id stays the same when a test moves to another
|
|
84
121
|
line, and changes when its title, describes or file change.
|
|
85
122
|
|
|
86
|
-
Every tool also takes `directory`, a folder inside the project to scan, and `framework` and `patterns`, relative to
|
|
123
|
+
Every scan tool also takes `directory`, a folder inside the project to scan, and `framework` and `patterns`, relative to
|
|
87
124
|
`directory`, to override the command line, and `expandCases`, which lists each case of a `.each` or `.for` table and
|
|
88
125
|
each pass of a loop as its own test, with the name the runner gives it, as test-inventory's
|
|
89
126
|
[`--expand-cases`](https://huldoser.github.io/test-inventory/guide/cli) does. Ids differ with it, so `get_tests` takes
|
|
90
127
|
the same `expandCases` as the `find_tests` call the ids came from. Records have the keys of test-inventory's
|
|
91
128
|
[output format](https://huldoser.github.io/test-inventory/reference/output).
|
|
92
129
|
|
|
130
|
+
Unknown tool arguments are refused with an error naming the unrecognized key, so misspelled filters are not silently ignored.
|
|
131
|
+
|
|
93
132
|
Answers are JSON, sent both as structured content and as text. Lists come 50 items at a time (`limit` takes up to
|
|
94
133
|
200), and an answer stays under about 30,000 characters; passing `nextCursor` back as `cursor` gets the next page.
|
|
134
|
+
A single oversized record is returned alone. A final page can fit more records because it needs no next-page cursor or hint.
|
|
95
135
|
`scanErrors` counts the problems that may leave tests out, and `hint` says what to do next when there is something to
|
|
96
136
|
say.
|
|
97
137
|
|
|
@@ -103,21 +143,39 @@ say.
|
|
|
103
143
|
framework, root, patterns, filters and `expandCases` setting for both scans. Hash comparisons and rename matching
|
|
104
144
|
need the exact same core version. Incomplete scans produce warnings. Zero changes returns an empty page and a hint.
|
|
105
145
|
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).
|
|
146
|
+
`--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.
|
|
147
|
+
|
|
148
|
+
## Troubleshooting
|
|
149
|
+
|
|
150
|
+
| Symptom | Next step |
|
|
151
|
+
| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
152
|
+
| The server is disconnected or tools are missing | Open the client's server logs. Check that the client can find Node.js 22.12 or newer and `npx`, then restart the server through the client. A client launched by a desktop app may use a different PATH from your terminal. |
|
|
153
|
+
| No files or tests were found | Check `--root`, `directory`, the framework and the config's selected files. Try explicit `patterns`, such as `["tests/**/*.spec.ts"]`. Call `scan_diagnostics` for details. |
|
|
154
|
+
| Several runners were detected | Pass `framework` on the call, or set `--framework` in the server configuration. Scan each runner separately. |
|
|
155
|
+
| The answer has `scanErrors` | Call `scan_diagnostics` and resolve the errors before treating the inventory as complete. |
|
|
156
|
+
| A path is refused | Keep the scanned files and dependencies inside the configured project. For an intended shared dependency, start the server at the shared parent and use `directory` to select a package. |
|
|
157
|
+
| A cursor is refused | Start the query again without `cursor`; keep filters, directory and case expansion unchanged when requesting later pages. Files may have changed between calls. |
|
|
158
|
+
| `get_tests` cannot find an id | Obtain current ids from `find_tests`. Keep its `directory`, `framework`, `patterns` and `expandCases` settings. |
|
|
159
|
+
| A saved scan is refused | Use complete JSON inventories, not JSON Lines or `--fields` output. Keep both files inside the project and below the size limit. |
|
|
160
|
+
|
|
161
|
+
For incorrect source analysis, use the core's [troubleshooting guide](https://huldoser.github.io/test-inventory/guide/troubleshooting).
|
|
162
|
+
For a server bug, include the server version, client, tool arguments, expected answer and a minimal reproduction.
|
|
163
|
+
Remove private project data before sharing it.
|
|
107
164
|
|
|
108
165
|
## Security
|
|
109
166
|
|
|
110
167
|
The server reads the test files its globs match inside the project, or without globs those the configs run, and,
|
|
111
168
|
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.
|
|
169
|
+
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
170
|
|
|
114
171
|
Answers hold text from the project's files, such as test titles, skip reasons and comments. A client should treat it
|
|
115
|
-
as content of that project, not as instructions.
|
|
172
|
+
as content of that project, not as instructions. The client's handling of that text is separate from the server's
|
|
173
|
+
local operation. To report a vulnerability, see [SECURITY.md](SECURITY.md).
|
|
116
174
|
|
|
117
175
|
## Versioning
|
|
118
176
|
|
|
119
177
|
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.
|
|
178
|
+
minor version, so `test-inventory-mcp@0.9` in the setup above gets fixes only.
|
|
121
179
|
|
|
122
180
|
## License
|
|
123
181
|
|
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
|
|
@@ -266,7 +266,10 @@ export function createServer(config) {
|
|
|
266
266
|
.optional()
|
|
267
267
|
.describe('Keeps tests that one of these projects runs, named as in the configs test_summary lists.'),
|
|
268
268
|
only: z.boolean().optional().describe('true keeps tests that use .only, or are in a describe that does.'),
|
|
269
|
-
withoutReason: z
|
|
269
|
+
withoutReason: z
|
|
270
|
+
.boolean()
|
|
271
|
+
.optional()
|
|
272
|
+
.describe('true keeps non-active tests without a reason, including expected failures; excludes notLoaded.'),
|
|
270
273
|
fields: z
|
|
271
274
|
.array(z.enum(TEST_KEYS))
|
|
272
275
|
.min(1)
|
|
@@ -288,7 +291,7 @@ export function createServer(config) {
|
|
|
288
291
|
annotations: { title: 'Find tests', ...READ_ONLY },
|
|
289
292
|
}, ({ states, tags, grep, related, projects, only, withoutReason, fields, limit, cursor, ...scan }, { mcpReq: { signal } }) => answer(async () => {
|
|
290
293
|
const inventory = await scanProject(config, scan, signal);
|
|
291
|
-
const matched = filterTests(inventory, { states, tags, grep, related, only, withoutReason }, scan.directory);
|
|
294
|
+
const matched = await filterTests(inventory, { states, tags, grep, related, only, withoutReason }, config.root, scan.directory);
|
|
292
295
|
const run = projects
|
|
293
296
|
? matched.tests.filter((test) => test.projects?.some((name) => projects.includes(name)))
|
|
294
297
|
: matched.tests;
|
|
@@ -317,7 +320,7 @@ export function createServer(config) {
|
|
|
317
320
|
'title, describe or file changes; ids not in the current scan are returned in notFound. Example: ' +
|
|
318
321
|
'{"ids": ["3f9a0c1d2e4b5a69"]}. An answer that would be too long returns the first tests and the other ids in ' +
|
|
319
322
|
'remaining.',
|
|
320
|
-
inputSchema: z.
|
|
323
|
+
inputSchema: z.strictObject({
|
|
321
324
|
...scanArguments,
|
|
322
325
|
ids: z.array(z.string().min(1)).min(1).max(20).describe('Test ids, as find_tests returns them.'),
|
|
323
326
|
}),
|
|
@@ -373,7 +376,7 @@ export function createServer(config) {
|
|
|
373
376
|
'at run time, a file no config runs). They are ' +
|
|
374
377
|
'about reading the code, not test failures. Use it when another tool reports scanErrors, or to check why a ' +
|
|
375
378
|
'test is missing or notLoaded. Answers are paged: follow nextCursor. Example: {"levels": ["error"]}.',
|
|
376
|
-
inputSchema: z.
|
|
379
|
+
inputSchema: z.strictObject({
|
|
377
380
|
...scanArguments,
|
|
378
381
|
levels: z.array(z.enum(DIAGNOSTIC_LEVELS)).min(1).optional().describe('Keeps problems of these levels.'),
|
|
379
382
|
codes: z.array(z.enum(DIAGNOSTIC_CODES)).min(1).optional().describe('Keeps problems with these codes.'),
|
|
@@ -415,7 +418,7 @@ export function createServer(config) {
|
|
|
415
418
|
'Use the same framework, root, patterns, filters and expandCases for both saved scans. Hash comparisons and rename matching ' +
|
|
416
419
|
'are disabled across tool versions. Follow nextCursor for more changes. For Playwright, Vitest, Jest, Mocha, Jasmine, ' +
|
|
417
420
|
'Cypress, WebdriverIO, node:test and Bun inventories. Example: {"before":"inventories/base.json","after":"inventories/head.json"}.',
|
|
418
|
-
inputSchema: z.
|
|
421
|
+
inputSchema: z.strictObject({
|
|
419
422
|
before: z
|
|
420
423
|
.string()
|
|
421
424
|
.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.1",
|
|
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": [
|
|
@@ -49,6 +49,8 @@
|
|
|
49
49
|
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
|
|
50
50
|
"prepack": "npm run build",
|
|
51
51
|
"typecheck": "tsc -p tsconfig.json",
|
|
52
|
+
"docs:tools": "node scripts/tool-docs.ts",
|
|
53
|
+
"docs:check": "node scripts/tool-docs.ts --check",
|
|
52
54
|
"test": "vitest run",
|
|
53
55
|
"test:watch": "vitest",
|
|
54
56
|
"coverage": "vitest run --coverage",
|
|
@@ -77,7 +79,7 @@
|
|
|
77
79
|
},
|
|
78
80
|
"dependencies": {
|
|
79
81
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
80
|
-
"test-inventory": "^0.10.
|
|
82
|
+
"test-inventory": "^0.10.2",
|
|
81
83
|
"zod": "^4.6.7"
|
|
82
84
|
}
|
|
83
85
|
}
|