test-inventory-mcp 0.5.0 → 0.7.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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # test-inventory-mcp
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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`
8
+ and every tool's `framework` take `mocha`, `jasmine`, `cypress`, `webdriverio`, `node` and `bun`. A tool call the client
9
+ cancels stops its scan between files.
10
+
11
+ ## 0.6.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#22](https://github.com/Huldoser/test-inventory-mcp/pull/22) [`fad31c9`](https://github.com/Huldoser/test-inventory-mcp/commit/fad31c91e3bc3150cdb4e440795abf0940a7cee8) - Requires test-inventory 0.8.0 and reads Jest 29 and 30 projects: `framework` and `--framework` take `jest`. Without a
16
+ framework from the start command or the call, a call scans with the runner the project in `directory` uses; in a
17
+ project with several, the error names them and asks for `framework`. Globs on the command line no longer need
18
+ `--framework`.
19
+
3
20
  ## 0.5.0
4
21
 
5
22
  ### 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 and Vitest 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
- Node.js 22.12 or newer. The client starts the server with `npx` and talks to it over standard input and output. Give
12
- it the framework, and the server scans the test files your `playwright.config` or `vitest.config` runs. Globs after
13
- it pick the files instead, as on test-inventory's command line.
12
+ Node.js 22.12 or newer. The client starts the server with `npx` and talks to it over standard input and output. The
13
+ server scans the test files your test runner's config runs, with the runner `--framework` names or, without
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.5 --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.5 -
25
26
  "mcpServers": {
26
27
  "test-inventory": {
27
28
  "command": "npx",
28
- "args": ["-y", "test-inventory-mcp@0.5", "--framework", "playwright"]
29
+ "args": ["-y", "test-inventory-mcp@0.7", "--framework", "playwright"]
29
30
  }
30
31
  }
31
32
  }
@@ -39,14 +40,15 @@ claude mcp add --scope project test-inventory -- npx -y test-inventory-mcp@0.5 -
39
40
  "test-inventory": {
40
41
  "type": "stdio",
41
42
  "command": "npx",
42
- "args": ["-y", "test-inventory-mcp@0.5", "--framework", "playwright"]
43
+ "args": ["-y", "test-inventory-mcp@0.7", "--framework", "playwright"]
43
44
  }
44
45
  }
45
46
  }
46
47
  ```
47
48
 
48
- Without `--framework`, as in a configuration shared by every project, the agent passes `framework` in each call, and
49
- `patterns` when it wants other files than the configs run; the tools say so when the framework is missing.
49
+ Without `--framework`, as in a configuration shared by every project, each call scans with the runner the project
50
+ uses. In a project with several runners the agent passes `framework`, as the tools tell it, and `patterns` when it
51
+ wants other files than the configs run.
50
52
 
51
53
  The project is the folder given with `--root`, otherwise the one Claude Code names in `CLAUDE_PROJECT_DIR`, otherwise
52
54
  the folder the client starts the server in.
@@ -54,15 +56,16 @@ the folder the client starts the server in.
54
56
  ## Command line
55
57
 
56
58
  ```text
57
- test-inventory-mcp [--framework <playwright|vitest> [<glob...>]] [--root <dir>]
59
+ test-inventory-mcp [--framework <name>] [<glob...>] [--root <dir>]
58
60
  ```
59
61
 
60
- | Option | Meaning |
61
- | --------------------- | -------------------------------------------------------------------------------------------------------- |
62
- | `--framework <name>` | `playwright` or `vitest`. A tool call can pass the other. |
63
- | `<glob...>` | The test files, relative to the project, in place of those the configs run. A tool call can pass others. |
64
- | `--root <dir>` | The project. Tool calls can scan folders inside it, never outside. |
65
- | `--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. |
66
69
 
67
70
  ## Tools
68
71
 
@@ -70,25 +73,27 @@ test-inventory-mcp [--framework <playwright|vitest> [<glob...>]] [--root <dir>]
70
73
  | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------- |
71
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. |
72
75
  | `find_tests` | The tests that match `states`, `tags`, `grep`, `related`, `projects`, `only` or `withoutReason`, with the `fields` you pick. |
73
- | `get_tests` | Every key of up to 20 tests by id, with the scan's diagnostics about them. |
74
- | `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`. |
75
78
 
76
79
  `related` takes the files a change touches, from the project root as `git diff --name-only` writes them, and keeps
77
80
  the tests whose `dependencies` include one of them, and those that reach code the scan can't follow, as
78
81
  test-inventory's [`--related`](https://huldoser.github.io/test-inventory/guide/cli#tests-a-change-can-affect) does.
79
82
  `dependencies` can list hundreds of files, so it isn't among the default `fields`, and `get_tests` returns as many
80
- 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.
81
85
 
82
- Every tool also takes `directory`, a folder inside the project to scan, and `framework` and `patterns` to override
83
- the command line, and `expandCases`, which lists each case of a `.each` or `.for` table and each pass of a loop as
84
- 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
85
89
  [`--expand-cases`](https://huldoser.github.io/test-inventory/guide/cli) does. Ids differ with it, so `get_tests` takes
86
90
  the same `expandCases` as the `find_tests` call the ids came from. Records have the keys of test-inventory's
87
91
  [output format](https://huldoser.github.io/test-inventory/reference/output).
88
92
 
89
93
  Answers are JSON, sent both as structured content and as text. Lists come 50 items at a time (`limit` takes up to
90
- 200), and an answer stays under about 30,000 characters; `nextCursor` gets the next page. `scanErrors` counts the
91
- 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.
92
97
 
93
98
  ## Security
94
99
 
@@ -102,7 +107,7 @@ as content of that project, not as instructions. To report a vulnerability, see
102
107
  ## Versioning
103
108
 
104
109
  Tool names, their arguments and their answers are the server's API. Before 1.0, a change that breaks them raises the
105
- minor version, so `test-inventory-mcp@0.5` in the setup above gets fixes only.
110
+ minor version, so `test-inventory-mcp@0.7` in the setup above gets fixes only.
106
111
 
107
112
  ## License
108
113
 
@@ -3,12 +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> [<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 or vitest; a tool call can pass the other
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
12
28
  <glob...> test files to scan, relative to the root; without them, those the configs
13
29
  run; a tool call can pass others
14
30
  --root <dir> the project; defaults to $CLAUDE_PROJECT_DIR, then the current folder
@@ -16,7 +32,7 @@ tests of a project from their source code, without running them.
16
32
  -v, --version show the version
17
33
 
18
34
  Example, in an MCP client's configuration:
19
- npx -y test-inventory-mcp --framework playwright
35
+ npx -y test-inventory-mcp
20
36
  `;
21
37
  function usageError(message) {
22
38
  return { exitCode: 2, text: `test-inventory-mcp: ${message}\nRun test-inventory-mcp --help for the options.\n` };
@@ -44,11 +60,8 @@ export function parseCommandLine(args, env, cwd) {
44
60
  if (values.version === true)
45
61
  return { exitCode: 0, text: `${serverVersion}\n` };
46
62
  const framework = values.framework ?? null;
47
- if (framework !== null && framework !== 'playwright' && framework !== 'vitest') {
48
- return usageError(`--framework must be playwright or vitest; got "${framework}".`);
49
- }
50
- if (framework === null && positionals.length > 0) {
51
- return usageError('the globs need --framework, the runner they are for.');
63
+ if (framework !== null && !isFramework(framework)) {
64
+ return usageError(`--framework must be ${FRAMEWORKS.slice(0, -1).join(', ')} or ${FRAMEWORKS.at(-1)}; got "${framework}".`);
52
65
  }
53
66
  const given = values.root ?? env.CLAUDE_PROJECT_DIR ?? cwd;
54
67
  let root;
package/dist/project.js CHANGED
@@ -1,8 +1,6 @@
1
1
  import { realpath, stat } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { scan } from 'test-inventory';
4
- const MISSING = 'This server was started without a test runner, so pass `framework`: "playwright" or "vitest". Without ' +
5
- '`patterns`, the test files are those the configs in `directory` and the folders below it run.';
6
4
  /** A pattern from a tool call stays inside the folder it is scanned from: no absolute path and no `..`. */
7
5
  function checkPattern(pattern) {
8
6
  if (path.posix.isAbsolute(pattern) || path.win32.isAbsolute(pattern) || pattern.split(/[\\/]/).includes('..')) {
@@ -42,12 +40,20 @@ async function directoryIn(root, directory) {
42
40
  return real;
43
41
  }
44
42
  /** Scans what the arguments name, falling back to what the server was started with. */
45
- export async function scanProject(config, args) {
46
- const framework = args.framework ?? config.framework;
47
- if (framework === null)
48
- throw new Error(MISSING);
43
+ export async function scanProject(config, args, signal) {
44
+ const framework = args.framework ?? config.framework ?? undefined;
49
45
  args.patterns?.forEach(checkPattern);
50
46
  const root = args.directory === undefined ? config.root : await directoryIn(config.root, args.directory);
51
47
  const patterns = args.patterns ?? (config.patterns.length > 0 ? config.patterns : undefined);
52
- return scan({ root, patterns, framework, expandCases: args.expandCases });
48
+ try {
49
+ return await scan({ root, patterns, framework, expandCases: args.expandCases, signal });
50
+ }
51
+ catch (error) {
52
+ // A request the client cancelled stops the scan, with the reason the client gave.
53
+ if (signal?.aborted)
54
+ throw error;
55
+ // The scan throws only for its options. Without a runner named, it takes the one the project uses, and with none
56
+ // or several it says what to pass, named as the tool argument.
57
+ throw new Error(error.message.replace('options.framework', '`framework`'));
58
+ }
53
59
  }
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 or Vitest 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,9 +29,9 @@ 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'])
32
+ .enum(FRAMEWORKS)
32
33
  .optional()
33
- .describe('The test runner. Default: the one the server was started with.'),
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
35
36
  .array(z.string().min(1))
36
37
  .min(1)
@@ -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.5.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.0",
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,7 @@
10
10
  "testing",
11
11
  "playwright",
12
12
  "vitest",
13
+ "jest",
13
14
  "test-inventory",
14
15
  "ai-agents"
15
16
  ],
@@ -60,17 +61,17 @@
60
61
  "@changesets/cli": "^3.0.3",
61
62
  "@modelcontextprotocol/client": "^2.3.1",
62
63
  "@types/node": "~22.12.0",
63
- "@vitest/coverage-v8": "5.0.5",
64
- "eslint": "~10.13.0",
64
+ "@vitest/coverage-v8": "5.1.0",
65
+ "eslint": "~10.14.0",
65
66
  "prettier": "3.9.10",
66
67
  "publint": "^0.3.25",
67
68
  "typescript": "~6.0.3",
68
- "typescript-eslint": "~8.71.2",
69
- "vitest": "5.0.5"
69
+ "typescript-eslint": "~8.72.1",
70
+ "vitest": "5.1.0"
70
71
  },
71
72
  "dependencies": {
72
73
  "@modelcontextprotocol/server": "^2.3.1",
73
- "test-inventory": "^0.7.0",
74
+ "test-inventory": "^0.9.0",
74
75
  "zod": "^4.6.7"
75
76
  }
76
77
  }