test-inventory-mcp 0.6.0 → 0.7.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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # test-inventory-mcp
2
2
 
3
+ ## 0.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#30](https://github.com/Huldoser/test-inventory-mcp/pull/30) [`1a503e3`](https://github.com/Huldoser/test-inventory-mcp/commit/1a503e307a613557e1e8f1f0dca775f9d7eb2050) - A pattern that reaches outside the project through a backslash escape, as `.\./secret/*.test.ts`, is refused on every
8
+ system. On Linux and macOS the glob reads `\.` as `.`, so the check, which looked for `..` between slashes and
9
+ backslashes, let it through, and the answer listed tests from outside the project.
10
+
11
+ - [#31](https://github.com/Huldoser/test-inventory-mcp/pull/31) [`de056b0`](https://github.com/Huldoser/test-inventory-mcp/commit/de056b0b6f205ac0f6ce5a9416c07bc730f050c4) - The server requires test-inventory 0.9.1, so its answers have that release's fixes: tests written as
12
+ `(process.env.CI ? it.skip : it)(...)` are listed, `.mocharc.yml`, `bunfig.toml`, Cypress and WebdriverIO spec patterns,
13
+ Jest's `moduleNameMapper` and Vite's `'@': '/src'` alias are read as the runners read them, Playwright 1.65's
14
+ `test.skip('reason')` gives the reason, and node:test and Bun skip states follow their describes. A `bunfig.toml` in a
15
+ scanned project can no longer change what later calls of a running server read.
16
+
17
+ ## 0.7.0
18
+
19
+ ### Minor Changes
20
+
21
+ - [#27](https://github.com/Huldoser/test-inventory-mcp/pull/27) [`ad1c66d`](https://github.com/Huldoser/test-inventory-mcp/commit/ad1c66d529e43640af7befc0573bd20869c54473) - Reads Mocha, Jasmine, Cypress, WebdriverIO, node:test and Bun projects too, with test-inventory 0.9.0: `--framework`
22
+ and every tool's `framework` take `mocha`, `jasmine`, `cypress`, `webdriverio`, `node` and `bun`. A tool call the client
23
+ cancels stops its scan between files.
24
+
3
25
  ## 0.6.0
4
26
 
5
27
  ### Minor Changes
package/README.md CHANGED
@@ -3,19 +3,20 @@
3
3
  An MCP server for [test-inventory](https://github.com/Huldoser/test-inventory): AI agents ask which tests a project
4
4
  has, which are skipped and why, and which tests a change can affect, without running them.
5
5
 
6
- It reads Playwright, Vitest and Jest test files with test-inventory and answers from their source code. Nothing runs,
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. Nothing runs,
7
8
  nothing is written, and nothing leaves your machine.
8
9
 
9
10
  ## Setup
10
11
 
11
12
  Node.js 22.12 or newer. The client starts the server with `npx` and talks to it over standard input and output. The
12
- server scans the test files your Playwright, Vitest or Jest config runs, with the runner `--framework` names or, without
13
+ server scans the test files your test runner's config runs, with the runner `--framework` names or, without
13
14
  it, the one the project uses. Globs pick the files instead, as on test-inventory's command line.
14
15
 
15
16
  **Claude Code**, in the project folder. `--scope project` writes `.mcp.json`, for everyone who works on the project:
16
17
 
17
18
  ```sh
18
- claude mcp add --scope project test-inventory -- npx -y test-inventory-mcp@0.6 --framework playwright
19
+ claude mcp add --scope project test-inventory -- npx -y test-inventory-mcp@0.7 --framework playwright
19
20
  ```
20
21
 
21
22
  **Cursor**, in `.cursor/mcp.json`:
@@ -25,7 +26,7 @@ claude mcp add --scope project test-inventory -- npx -y test-inventory-mcp@0.6 -
25
26
  "mcpServers": {
26
27
  "test-inventory": {
27
28
  "command": "npx",
28
- "args": ["-y", "test-inventory-mcp@0.6", "--framework", "playwright"]
29
+ "args": ["-y", "test-inventory-mcp@0.7", "--framework", "playwright"]
29
30
  }
30
31
  }
31
32
  }
@@ -39,7 +40,7 @@ claude mcp add --scope project test-inventory -- npx -y test-inventory-mcp@0.6 -
39
40
  "test-inventory": {
40
41
  "type": "stdio",
41
42
  "command": "npx",
42
- "args": ["-y", "test-inventory-mcp@0.6", "--framework", "playwright"]
43
+ "args": ["-y", "test-inventory-mcp@0.7", "--framework", "playwright"]
43
44
  }
44
45
  }
45
46
  }
@@ -55,15 +56,16 @@ the folder the client starts the server in.
55
56
  ## Command line
56
57
 
57
58
  ```text
58
- test-inventory-mcp [--framework <playwright|vitest|jest>] [<glob...>] [--root <dir>]
59
+ test-inventory-mcp [--framework <name>] [<glob...>] [--root <dir>]
59
60
  ```
60
61
 
61
- | Option | Meaning |
62
- | --------------------- | -------------------------------------------------------------------------------------------------------- |
63
- | `--framework <name>` | `playwright`, `vitest` or `jest`. Without it, the runner the project uses. A tool call can pass another. |
64
- | `<glob...>` | The test files, relative to the project, in place of those the configs run. A tool call can pass others. |
65
- | `--root <dir>` | The project. Tool calls can scan folders inside it, never outside. |
66
- | `--help`, `--version` | Print the help or the version. |
62
+ | Option | Meaning |
63
+ | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
64
+ | `--framework <name>` | `playwright`, `vitest`, `jest`, `mocha`, `jasmine`, `cypress`, `webdriverio`, `node` or `bun`. Without it, the runner the project uses. A tool call can pass another. |
65
+ | `<glob...>` | The test files, relative to the project, in place of those the configs run. A tool call can pass others. |
66
+ | `--root <dir>` | The project. Tool calls can scan folders inside it, never outside. |
67
+ | `-h`, `--help` | Print the help. |
68
+ | `-v`, `--version` | Print the version. |
67
69
 
68
70
  ## Tools
69
71
 
@@ -71,25 +73,27 @@ test-inventory-mcp [--framework <playwright|vitest|jest>] [<glob...>] [--root <d
71
73
  | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------- |
72
74
  | `test_summary` | Counts by state, tag and annotation, and the configs with their projects; with `groupBy`, the counts of each file, tag or project. |
73
75
  | `find_tests` | The tests that match `states`, `tags`, `grep`, `related`, `projects`, `only` or `withoutReason`, with the `fields` you pick. |
74
- | `get_tests` | Every key of up to 20 tests by id, with the scan's diagnostics about them. |
75
- | `scan_diagnostics` | The problems the scan found, such as a file that failed to parse, by level, code or path. |
76
+ | `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
+ | `scan_diagnostics` | The problems the scan found, such as a file that failed to parse, by `levels`, `codes` or `path`. |
76
78
 
77
79
  `related` takes the files a change touches, from the project root as `git diff --name-only` writes them, and keeps
78
80
  the tests whose `dependencies` include one of them, and those that reach code the scan can't follow, as
79
81
  test-inventory's [`--related`](https://huldoser.github.io/test-inventory/guide/cli#tests-a-change-can-affect) does.
80
82
  `dependencies` can list hundreds of files, so it isn't among the default `fields`, and `get_tests` returns as many
81
- tests as fit in one answer, with the other ids in `remaining`.
83
+ tests as fit in one answer, with the other ids in `remaining`. An id stays the same when a test moves to another
84
+ line, and changes when its title, describes or file change.
82
85
 
83
- Every tool also takes `directory`, a folder inside the project to scan, and `framework` and `patterns` to override
84
- the command line, and `expandCases`, which lists each case of a `.each` or `.for` table and each pass of a loop as
85
- its own test, with the name the runner gives it, as test-inventory's
86
+ Every tool also takes `directory`, a folder inside the project to scan, and `framework` and `patterns`, relative to
87
+ `directory`, to override the command line, and `expandCases`, which lists each case of a `.each` or `.for` table and
88
+ each pass of a loop as its own test, with the name the runner gives it, as test-inventory's
86
89
  [`--expand-cases`](https://huldoser.github.io/test-inventory/guide/cli) does. Ids differ with it, so `get_tests` takes
87
90
  the same `expandCases` as the `find_tests` call the ids came from. Records have the keys of test-inventory's
88
91
  [output format](https://huldoser.github.io/test-inventory/reference/output).
89
92
 
90
93
  Answers are JSON, sent both as structured content and as text. Lists come 50 items at a time (`limit` takes up to
91
- 200), and an answer stays under about 30,000 characters; `nextCursor` gets the next page. `scanErrors` counts the
92
- problems that may leave tests out, and `hint` says what to do next when there is something to say.
94
+ 200), and an answer stays under about 30,000 characters; passing `nextCursor` back as `cursor` gets the next page.
95
+ `scanErrors` counts the problems that may leave tests out, and `hint` says what to do next when there is something to
96
+ say.
93
97
 
94
98
  ## Security
95
99
 
@@ -103,7 +107,7 @@ as content of that project, not as instructions. To report a vulnerability, see
103
107
  ## Versioning
104
108
 
105
109
  Tool names, their arguments and their answers are the server's API. Before 1.0, a change that breaks them raises the
106
- minor version, so `test-inventory-mcp@0.6` in the setup above gets fixes only.
110
+ minor version, so `test-inventory-mcp@0.7` in the setup above gets fixes only.
107
111
 
108
112
  ## License
109
113
 
@@ -3,13 +3,28 @@ import path from 'node:path';
3
3
  import { parseArgs } from 'node:util';
4
4
  /** The version of this package, read from its package.json in both the sources and the build. */
5
5
  export const serverVersion = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
6
- export const HELP = `Usage: test-inventory-mcp [--framework <playwright|vitest|jest>] [<glob...>] [--root <dir>]
6
+ /** The runners test-inventory reads, as `--framework` and the tools' `framework` name them. */
7
+ export const FRAMEWORKS = [
8
+ 'playwright',
9
+ 'vitest',
10
+ 'jest',
11
+ 'mocha',
12
+ 'jasmine',
13
+ 'cypress',
14
+ 'webdriverio',
15
+ 'node',
16
+ 'bun',
17
+ ];
18
+ function isFramework(name) {
19
+ return FRAMEWORKS.includes(name);
20
+ }
21
+ export const HELP = `Usage: test-inventory-mcp [--framework <name>] [<glob...>] [--root <dir>]
7
22
 
8
23
  An MCP server on standard input and output. It answers an AI agent's questions about the
9
24
  tests of a project from their source code, without running them.
10
25
 
11
- --framework <name> playwright, vitest or jest; without it, the runner the project uses;
12
- a tool call can pass another
26
+ --framework <name> playwright, vitest, jest, mocha, jasmine, cypress, webdriverio, node or
27
+ bun; without it, the runner the project uses; a tool call can pass another
13
28
  <glob...> test files to scan, relative to the root; without them, those the configs
14
29
  run; a tool call can pass others
15
30
  --root <dir> the project; defaults to $CLAUDE_PROJECT_DIR, then the current folder
@@ -45,8 +60,8 @@ export function parseCommandLine(args, env, cwd) {
45
60
  if (values.version === true)
46
61
  return { exitCode: 0, text: `${serverVersion}\n` };
47
62
  const framework = values.framework ?? null;
48
- if (framework !== null && framework !== 'playwright' && framework !== 'vitest' && framework !== 'jest') {
49
- return usageError(`--framework must be playwright, vitest or jest; got "${framework}".`);
63
+ if (framework !== null && !isFramework(framework)) {
64
+ return usageError(`--framework must be ${FRAMEWORKS.slice(0, -1).join(', ')} or ${FRAMEWORKS.at(-1)}; got "${framework}".`);
50
65
  }
51
66
  const given = values.root ?? env.CLAUDE_PROJECT_DIR ?? cwd;
52
67
  let root;
package/dist/project.js CHANGED
@@ -1,9 +1,16 @@
1
1
  import { realpath, stat } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { scan } from 'test-inventory';
4
- /** A pattern from a tool call stays inside the folder it is scanned from: no absolute path and no `..`. */
4
+ /**
5
+ * A pattern from a tool call stays inside the folder it is scanned from: no absolute path and no `..`. On Windows a
6
+ * backslash separates folders, and elsewhere it escapes the next character, so `.\./` is `../` to the glob; a pattern
7
+ * is refused when either reading leaves the folder, so the answer is the same on every system.
8
+ */
5
9
  function checkPattern(pattern) {
6
- if (path.posix.isAbsolute(pattern) || path.win32.isAbsolute(pattern) || pattern.split(/[\\/]/).includes('..')) {
10
+ const unescaped = pattern.replaceAll(/\\(.)/gs, '$1');
11
+ if (path.posix.isAbsolute(unescaped) ||
12
+ path.win32.isAbsolute(pattern) ||
13
+ [...pattern.split(/[\\/]/), ...unescaped.split('/')].includes('..')) {
7
14
  throw new Error(`The pattern "${pattern}" reaches outside the folder it is scanned from. Patterns are relative to ` +
8
15
  '`directory` (the project root by default) and cannot start with "/" or a drive, or contain "..".');
9
16
  }
@@ -40,15 +47,18 @@ async function directoryIn(root, directory) {
40
47
  return real;
41
48
  }
42
49
  /** Scans what the arguments name, falling back to what the server was started with. */
43
- export async function scanProject(config, args) {
50
+ export async function scanProject(config, args, signal) {
44
51
  const framework = args.framework ?? config.framework ?? undefined;
45
52
  args.patterns?.forEach(checkPattern);
46
53
  const root = args.directory === undefined ? config.root : await directoryIn(config.root, args.directory);
47
54
  const patterns = args.patterns ?? (config.patterns.length > 0 ? config.patterns : undefined);
48
55
  try {
49
- return await scan({ root, patterns, framework, expandCases: args.expandCases });
56
+ return await scan({ root, patterns, framework, expandCases: args.expandCases, signal });
50
57
  }
51
58
  catch (error) {
59
+ // A request the client cancelled stops the scan, with the reason the client gave.
60
+ if (signal?.aborted)
61
+ throw error;
52
62
  // The scan throws only for its options. Without a runner named, it takes the one the project uses, and with none
53
63
  // or several it says what to pass, named as the tool argument.
54
64
  throw new Error(error.message.replace('options.framework', '`framework`'));
package/dist/server.js CHANGED
@@ -1,17 +1,18 @@
1
1
  import { fromJsonSchema, McpServer } from '@modelcontextprotocol/server';
2
2
  import { filterInventory, pickTestFields, } from 'test-inventory';
3
3
  import * as z from 'zod/v4';
4
- import { serverVersion } from "./command-line.js";
4
+ import { FRAMEWORKS, serverVersion } from "./command-line.js";
5
5
  import { DEFAULT_LIMIT, MAX_CHARACTERS, MAX_LIMIT, paginate } from "./page.js";
6
6
  import { relatedIn, scanProject } from "./project.js";
7
7
  import { DIAGNOSTIC_CODES, DIAGNOSTIC_LEVELS, outputSchema, pickedTest, ref, TEST_KEYS, TEST_STATES, } from "./schema.js";
8
- export const INSTRUCTIONS = "test-inventory reads a project's Playwright, Vitest or Jest test files and configs and reports every test from its " +
8
+ export const INSTRUCTIONS = "test-inventory reads a project's Playwright, Vitest, Jest, Mocha, Jasmine, Cypress, WebdriverIO, node:test or Bun " +
9
+ 'test files and configs and reports every test from its ' +
9
10
  'source code, without running anything: its state (active, skip, fixme, todo, expectedToFail, notLoaded), skip ' +
10
11
  'reasons and conditions, tags, annotations and location, the projects that run it, the hooks around it, timeouts ' +
11
12
  'and retries and where they are set, fixtures, assertion counts and steps, and the files each test runs ' +
12
13
  '(dependencies, with dependencyHash). Use it for questions such as which tests are skipped and why, which tests ' +
13
14
  'carry a tag or a project runs, which tests retry or have no assertions, how many tests a file has, whether a ' +
14
- '.only was left in that forbidOnly fails in CI, or which tests a change can affect (related, with the changed ' +
15
+ '.only was left in that forbidOnly or allowOnly fails in CI, or which tests a change can affect (related, with the changed ' +
15
16
  'files). Pass expandCases for one test per .each case and loop pass, with the names the runner gives them. ' +
16
17
  'Start with test_summary ' +
17
18
  'for counts, find_tests to list matching tests, get_tests for every key of known ids, and scan_diagnostics when an ' +
@@ -28,7 +29,7 @@ const scanArguments = {
28
29
  .optional()
29
30
  .describe('A folder inside the project to scan, relative to its root, such as "packages/web". Default: the root.'),
30
31
  framework: z
31
- .enum(['playwright', 'vitest', 'jest'])
32
+ .enum(FRAMEWORKS)
32
33
  .optional()
33
34
  .describe('The test runner. Default: the one the server was started with, otherwise the one the project in `directory` uses.'),
34
35
  patterns: z
@@ -213,8 +214,8 @@ export function createServer(config) {
213
214
  ...hintKey,
214
215
  })),
215
216
  annotations: { title: 'Test summary', ...READ_ONLY },
216
- }, ({ states, tags, grep, related, groupBy, limit, cursor, ...scan }) => answer(async () => {
217
- const inventory = await scanProject(config, scan);
217
+ }, ({ states, tags, grep, related, groupBy, limit, cursor, ...scan }, { mcpReq: { signal } }) => answer(async () => {
218
+ const inventory = await scanProject(config, scan, signal);
218
219
  const matched = filterTests(inventory, { states, tags, grep, related }, scan.directory);
219
220
  const base = { ...scanOutput(inventory), summary: matched.summary, configs: inventory.configs };
220
221
  if (groupBy === undefined) {
@@ -282,8 +283,8 @@ export function createServer(config) {
282
283
  ...hintKey,
283
284
  })),
284
285
  annotations: { title: 'Find tests', ...READ_ONLY },
285
- }, ({ states, tags, grep, related, projects, only, withoutReason, fields, limit, cursor, ...scan }) => answer(async () => {
286
- const inventory = await scanProject(config, scan);
286
+ }, ({ states, tags, grep, related, projects, only, withoutReason, fields, limit, cursor, ...scan }, { mcpReq: { signal } }) => answer(async () => {
287
+ const inventory = await scanProject(config, scan, signal);
287
288
  const matched = filterTests(inventory, { states, tags, grep, related, only, withoutReason }, scan.directory);
288
289
  const run = projects
289
290
  ? matched.tests.filter((test) => test.projects?.some((name) => projects.includes(name)))
@@ -335,8 +336,8 @@ export function createServer(config) {
335
336
  ...hintKey,
336
337
  })),
337
338
  annotations: { title: 'Get tests', ...READ_ONLY },
338
- }, ({ ids, ...scan }) => answer(async () => {
339
- const inventory = await scanProject(config, scan);
339
+ }, ({ ids, ...scan }, { mcpReq: { signal } }) => answer(async () => {
340
+ const inventory = await scanProject(config, scan, signal);
340
341
  const byId = new Map(inventory.tests.map((test) => [test.id, test]));
341
342
  const wanted = [...new Set(ids)];
342
343
  const notFound = wanted.filter((id) => !byId.has(id));
@@ -387,8 +388,8 @@ export function createServer(config) {
387
388
  ...hintKey,
388
389
  })),
389
390
  annotations: { title: 'Scan diagnostics', ...READ_ONLY },
390
- }, ({ levels, codes, path, limit, cursor, ...scan }) => answer(async () => {
391
- const inventory = await scanProject(config, scan);
391
+ }, ({ levels, codes, path, limit, cursor, ...scan }, { mcpReq: { signal } }) => answer(async () => {
392
+ const inventory = await scanProject(config, scan, signal);
392
393
  const folder = path?.endsWith('/') ? path : `${path}/`;
393
394
  const diagnostics = inventory.diagnostics.filter((diagnostic) => (levels === undefined || levels.includes(diagnostic.level)) &&
394
395
  (codes === undefined || codes.includes(diagnostic.code)) &&
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "test-inventory-mcp",
3
- "version": "0.6.0",
4
- "description": "MCP server for test-inventory: AI agents read a project's tests from source code, without running them.",
3
+ "version": "0.7.1",
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": [
7
7
  "mcp",
@@ -10,6 +10,13 @@
10
10
  "testing",
11
11
  "playwright",
12
12
  "vitest",
13
+ "jest",
14
+ "mocha",
15
+ "jasmine",
16
+ "cypress",
17
+ "webdriverio",
18
+ "bun",
19
+ "node-test",
13
20
  "test-inventory",
14
21
  "ai-agents"
15
22
  ],
@@ -60,17 +67,17 @@
60
67
  "@changesets/cli": "^3.0.3",
61
68
  "@modelcontextprotocol/client": "^2.3.1",
62
69
  "@types/node": "~22.12.0",
63
- "@vitest/coverage-v8": "5.0.5",
64
- "eslint": "~10.13.0",
70
+ "@vitest/coverage-v8": "5.1.0",
71
+ "eslint": "~10.14.0",
65
72
  "prettier": "3.9.10",
66
73
  "publint": "^0.3.25",
67
74
  "typescript": "~6.0.3",
68
- "typescript-eslint": "~8.71.2",
69
- "vitest": "5.0.5"
75
+ "typescript-eslint": "~8.72.1",
76
+ "vitest": "5.1.0"
70
77
  },
71
78
  "dependencies": {
72
79
  "@modelcontextprotocol/server": "^2.3.1",
73
- "test-inventory": "^0.8.0",
80
+ "test-inventory": "^0.9.1",
74
81
  "zod": "^4.6.7"
75
82
  }
76
83
  }