@qcentriq/mcp 0.4.6 → 0.5.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.
Files changed (4) hide show
  1. package/LICENSE +202 -202
  2. package/README.md +348 -348
  3. package/dist/index.js +144 -58
  4. package/package.json +51 -51
package/dist/index.js CHANGED
@@ -117,24 +117,24 @@ var QCentriqApiClient = class {
117
117
  * Authenticated GET against the QCentriq backend (/api/v1/mcp-client/...).
118
118
  * Undefined and null params are left out of the query string.
119
119
  */
120
- async request(path6, params = {}) {
120
+ async request(path7, params = {}) {
121
121
  const query = new URLSearchParams();
122
122
  for (const [key, value] of Object.entries(params)) {
123
123
  if (value !== void 0 && value !== null) {
124
124
  query.set(key, String(value));
125
125
  }
126
126
  }
127
- return this.call("GET", path6, query);
127
+ return this.call("GET", path7, query);
128
128
  }
129
129
  /**
130
130
  * Authenticated JSON write against the QCentriq backend. `timeoutMs`
131
131
  * overrides the configured timeout for a call known to be slow.
132
132
  */
133
- async send(method, path6, body, opts = {}) {
134
- return this.call(method, path6, void 0, body, opts.timeoutMs);
133
+ async send(method, path7, body, opts = {}) {
134
+ return this.call(method, path7, void 0, body, opts.timeoutMs);
135
135
  }
136
- async call(method, path6, query, body, timeoutMs) {
137
- const cleanPath = path6.startsWith("/") ? path6 : `/${path6}`;
136
+ async call(method, path7, query, body, timeoutMs) {
137
+ const cleanPath = path7.startsWith("/") ? path7 : `/${path7}`;
138
138
  const qs = query?.toString();
139
139
  const url = `${this.config.baseUrl}/api/v1/mcp-client${cleanPath}${qs ? `?${qs}` : ""}`;
140
140
  logger.debug(`[mcp-client] HTTP ${method} ${url}`);
@@ -159,12 +159,12 @@ var QCentriqApiClient = class {
159
159
  * Issue a request that is aborted after the configured timeout, reporting
160
160
  * the timeout as such rather than as a bare AbortError.
161
161
  */
162
- async fetchWithTimeout(method, path6, url, init, timeoutMs) {
162
+ async fetchWithTimeout(method, path7, url, init, timeoutMs) {
163
163
  try {
164
164
  return await fetch(url, { ...init, method, signal: AbortSignal.timeout(timeoutMs) });
165
165
  } catch (err) {
166
166
  if (err?.name === "TimeoutError") {
167
- throw new Error(`${method} ${path6} timed out after ${timeoutMs}ms`);
167
+ throw new Error(`${method} ${path7} timed out after ${timeoutMs}ms`);
168
168
  }
169
169
  throw err;
170
170
  }
@@ -257,30 +257,71 @@ function registerGetTestGroupsTool(server, client, config) {
257
257
 
258
258
  // src/tools/download-script.ts
259
259
  import { z as z5 } from "zod";
260
+ import * as path3 from "path";
260
261
 
261
262
  // src/tools/save-script.ts
262
263
  import { z as z4 } from "zod";
264
+ import * as fs2 from "fs/promises";
265
+ import * as path2 from "path";
266
+
267
+ // src/local/group-files.ts
263
268
  import * as fs from "fs/promises";
264
269
  import * as path from "path";
270
+ var RESERVED_FILE_NAMES = /* @__PURE__ */ new Set(["conftest.py", "qc_inputs.json", "qc_state.json"]);
271
+ var PYTEST_CONFIG_NAMES = /* @__PURE__ */ new Set(["pytest.ini", "pyproject.toml", "tox.ini", "setup.cfg"]);
272
+ var HELPER_EXTENSIONS = /* @__PURE__ */ new Set([".py", ".json", ".txt", ".csv", ".yaml", ".yml", ".ini", ".cfg", ".toml"]);
273
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
274
+ var MAX_GROUP_HELPERS = 20;
275
+ var SKIPPED_FOLDERS = /* @__PURE__ */ new Set(["__pycache__", "__snapshots__", "snapshot_failures"]);
276
+ var skippedFolder = (name) => name.startsWith(".") || SKIPPED_FOLDERS.has(name);
277
+ function isGroupHelper(relative) {
278
+ const name = path.basename(relative);
279
+ const topLevel = !relative.includes("/");
280
+ if (topLevel && (name.startsWith("test_") && name.endsWith(".py") || PYTEST_CONFIG_NAMES.has(name))) return false;
281
+ return !RESERVED_FILE_NAMES.has(name) && HELPER_EXTENSIONS.has(path.extname(name).toLowerCase());
282
+ }
283
+ async function listGroupHelpers(dir) {
284
+ const found = [];
285
+ async function walk(relative) {
286
+ for (const entry of await fs.readdir(path.join(dir, relative), { withFileTypes: true })) {
287
+ if (found.length > MAX_GROUP_HELPERS) return;
288
+ const child = relative ? `${relative}/${entry.name}` : entry.name;
289
+ if (entry.isDirectory()) {
290
+ if (!skippedFolder(entry.name) && !(relative === "" && UUID.test(entry.name))) await walk(child);
291
+ } else if (entry.isFile() && isGroupHelper(child)) {
292
+ found.push(child);
293
+ }
294
+ }
295
+ }
296
+ await walk("");
297
+ return found.sort();
298
+ }
299
+ function resolveInside(dir, relative) {
300
+ const root = path.resolve(dir);
301
+ const target = path.resolve(root, relative);
302
+ return target.startsWith(root + path.sep) ? target : null;
303
+ }
304
+
305
+ // src/tools/save-script.ts
265
306
  var DEFAULT_SCRIPT_DIR = "./qcentriq_tests";
266
307
  function registerSaveScriptTool(server) {
267
308
  server.registerTool(
268
309
  "qcentriq_save_script",
269
310
  {
270
- description: "Save downloaded Playwright Python test script and fixtures directly to the local workspace disk so they can be run or edited locally.",
311
+ description: `Save a Playwright Python test script and its helper files to the local workspace so they can be run or edited locally. Keep each group in its own folder, '${DEFAULT_SCRIPT_DIR}/<group_id>/', as qcentriq_download_script does; helpers keep their relative paths there (e.g. 'pages/login_page.py'), with folders created as needed.`,
271
312
  inputSchema: z4.object({
272
313
  file_name: z4.string().describe("Target filename (e.g. 'test_login.py')."),
273
314
  content: z4.string().describe("Python test script source code."),
274
- conftest_content: z4.string().optional().describe("Accompanying conftest.py source code if present."),
275
- destination_dir: z4.string().default(DEFAULT_SCRIPT_DIR).describe(`Destination directory in the local workspace (default '${DEFAULT_SCRIPT_DIR}'). Kept separate from a project's own ./tests so an existing conftest.py is never overwritten.`)
315
+ fixtures: z4.array(z4.object({ file_name: z4.string(), content: z4.string() })).optional().describe("Helper files, each file_name a path relative to destination_dir (e.g. 'pages/login_page.py'). A path leaving destination_dir is refused."),
316
+ destination_dir: z4.string().default(DEFAULT_SCRIPT_DIR).describe(`Destination directory in the local workspace (default '${DEFAULT_SCRIPT_DIR}'; use '${DEFAULT_SCRIPT_DIR}/<group_id>' for a group). Kept separate from a project's own ./tests so an existing conftest.py is never overwritten.`)
276
317
  })
277
318
  },
278
319
  async (args) => {
279
320
  try {
280
- const savedFiles = await saveScriptFiles(args.destination_dir ?? DEFAULT_SCRIPT_DIR, args.file_name, args.content, args.conftest_content);
321
+ const savedFiles = await saveScriptFiles(args.destination_dir, args.file_name, args.content, args.fixtures);
281
322
  return jsonResult({
282
323
  status: "success",
283
- message: `Successfully saved ${savedFiles.length} file(s) to ${path.dirname(savedFiles[0])}`,
324
+ message: `Successfully saved ${savedFiles.length} file(s) to ${path2.dirname(savedFiles[0])}`,
284
325
  saved_files: savedFiles
285
326
  });
286
327
  } catch (err) {
@@ -289,22 +330,26 @@ function registerSaveScriptTool(server) {
289
330
  }
290
331
  );
291
332
  }
292
- async function saveScriptFiles(destinationDir, fileName, content, conftest) {
293
- const safeFileName = path.basename(fileName);
333
+ async function saveScriptFiles(destinationDir, fileName, content, helpers = []) {
334
+ const safeFileName = path2.basename(fileName);
294
335
  if (!safeFileName || safeFileName === "." || safeFileName === "..") {
295
336
  throw new Error(`Invalid file name: "${fileName}"`);
296
337
  }
297
- const targetDir = path.resolve(process.cwd(), destinationDir);
298
- await fs.mkdir(targetDir, { recursive: true });
299
- const scriptPath = path.join(targetDir, safeFileName);
300
- await fs.writeFile(scriptPath, content, "utf-8");
338
+ const targetDir = path2.resolve(process.cwd(), destinationDir);
339
+ const writes = helpers.map((helper) => {
340
+ const helperPath = resolveInside(targetDir, helper.file_name);
341
+ if (!helperPath) throw new Error(`Helper path "${helper.file_name}" leaves ${targetDir}`);
342
+ return { helperPath, content: helper.content };
343
+ });
344
+ await fs2.mkdir(targetDir, { recursive: true });
345
+ const scriptPath = path2.join(targetDir, safeFileName);
346
+ await fs2.writeFile(scriptPath, content, "utf-8");
301
347
  logger.info(`Saved test script to: ${scriptPath}`);
302
348
  const saved = [scriptPath];
303
- if (conftest) {
304
- const conftestPath = path.join(targetDir, "conftest.py");
305
- await fs.writeFile(conftestPath, conftest, "utf-8");
306
- logger.info(`Saved conftest.py to: ${conftestPath}`);
307
- saved.push(conftestPath);
349
+ for (const { helperPath, content: helperContent } of writes) {
350
+ await fs2.mkdir(path2.dirname(helperPath), { recursive: true });
351
+ await fs2.writeFile(helperPath, helperContent, "utf-8");
352
+ saved.push(helperPath);
308
353
  }
309
354
  return saved;
310
355
  }
@@ -314,13 +359,13 @@ function registerDownloadScriptTool(server, client, config, versions) {
314
359
  server.registerTool(
315
360
  "qcentriq_download_script",
316
361
  {
317
- description: `Download test group script and accompanying helper files for local test execution and editing (qcentriq_run_local_test supplies the QCentriq conftest.py). By default the files are written to '${DEFAULT_SCRIPT_DIR}', the same directory qcentriq_save_script uses, and their paths are returned in saved_files.`,
362
+ description: `Download a test group's script and its helper files (page objects, utilities, test data) for local test execution and editing (qcentriq_run_local_test supplies the QCentriq conftest.py). By default they are written to the group's own folder, '${DEFAULT_SCRIPT_DIR}/<group_id>/', each helper at its path relative to that folder (e.g. 'pages/login_page.py'), and their paths are returned in saved_files. Edit and run the script there: qcentriq_save_group_script uploads the folder's complete helper set, and any helper missing from a save is deleted.`,
318
363
  inputSchema: z5.object({
319
364
  group_id: z5.uuid().describe("UUID of the target test group."),
320
365
  project_id: z5.uuid().optional().describe("Optional project UUID (inferred from API key if omitted)."),
321
366
  include_fixtures: z5.boolean().default(true).describe("Whether to retrieve accompanying helper files (default True)."),
322
367
  save_to_disk: z5.boolean().default(true).describe("Saves the downloaded test script and fixtures to destination_dir (default True). Set false to only return the content."),
323
- destination_dir: z5.string().default(DEFAULT_SCRIPT_DIR).describe(`Destination directory when save_to_disk is true (default '${DEFAULT_SCRIPT_DIR}'). Kept separate from a project's own ./tests so an existing conftest.py is never overwritten.`)
368
+ destination_dir: z5.string().default(DEFAULT_SCRIPT_DIR).describe(`Directory the group's folder is created in when save_to_disk is true (default '${DEFAULT_SCRIPT_DIR}'); files go to <destination_dir>/<group_id>/. Kept separate from a project's own ./tests so an existing conftest.py is never overwritten.`)
324
369
  })
325
370
  },
326
371
  async (args) => {
@@ -335,8 +380,9 @@ function registerDownloadScriptTool(server, client, config, versions) {
335
380
  }
336
381
  if (data?.script_version) versions.set(args.group_id, data.script_version);
337
382
  if (!args.save_to_disk || !data?.file_name || !data?.content) return jsonResult(data);
383
+ const groupDir = path3.join(args.destination_dir, args.group_id);
338
384
  try {
339
- data.saved_files = await saveScriptFiles(args.destination_dir, data.file_name, data.content, data.conftest_content);
385
+ data.saved_files = await saveScriptFiles(groupDir, data.file_name, data.content, data.fixtures ?? []);
340
386
  return jsonResult(data);
341
387
  } catch (writeErr) {
342
388
  logger.warn(`Failed to write downloaded script to disk: ${writeErr.message}`);
@@ -345,7 +391,7 @@ function registerDownloadScriptTool(server, client, config, versions) {
345
391
  content: [
346
392
  {
347
393
  type: "text",
348
- text: `The script was downloaded but could not be saved to "${args.destination_dir}": ${writeErr.message}. The downloaded content follows; save it with qcentriq_save_script.`
394
+ text: `The script was downloaded but could not be saved to "${groupDir}": ${writeErr.message}. The downloaded content follows; save it with qcentriq_save_script.`
349
395
  },
350
396
  ...jsonResult(data).content
351
397
  ]
@@ -454,8 +500,7 @@ import { z as z10 } from "zod";
454
500
 
455
501
  // src/local/passing-runs.ts
456
502
  import { createHash } from "crypto";
457
- import * as fs2 from "fs/promises";
458
- import * as path2 from "path";
503
+ import * as fs3 from "fs/promises";
459
504
  var PassingRunLedger = class {
460
505
  runs = /* @__PURE__ */ new Map();
461
506
  record(content, run) {
@@ -480,16 +525,16 @@ function reportsPassedTests(stdout) {
480
525
  }
481
526
  async function fixtureMismatch(run, fixtures) {
482
527
  for (const fixture of fixtures) {
483
- const localPath = path2.resolve(run.dir, fixture.file_name);
484
- if (path2.dirname(localPath) !== run.dir) {
485
- return `companion file "${fixture.file_name}" is not a plain file name next to the script`;
528
+ const localPath = resolveInside(run.dir, fixture.file_name);
529
+ if (!localPath) {
530
+ return `companion file "${fixture.file_name}" is not inside the script's folder (${run.dir})`;
486
531
  }
487
532
  let local;
488
533
  let modifiedAt;
489
534
  try {
490
- [local, modifiedAt] = await Promise.all([fs2.readFile(localPath, "utf-8"), fs2.stat(localPath).then((s) => s.mtimeMs)]);
535
+ [local, modifiedAt] = await Promise.all([fs3.readFile(localPath, "utf-8"), fs3.stat(localPath).then((s) => s.mtimeMs)]);
491
536
  } catch {
492
- return `companion file "${fixture.file_name}" was not next to the script (${run.dir}) when it passed`;
537
+ return `companion file "${fixture.file_name}" was not in the script's folder (${run.dir}) when it passed`;
493
538
  }
494
539
  if (local !== fixture.content) {
495
540
  return `companion file "${fixture.file_name}" differs from ${localPath}, which the passing run used`;
@@ -498,13 +543,27 @@ async function fixtureMismatch(run, fixtures) {
498
543
  return `companion file "${fixture.file_name}" changed after the passing run`;
499
544
  }
500
545
  }
546
+ let helpers;
547
+ try {
548
+ helpers = await listGroupHelpers(run.dir);
549
+ } catch {
550
+ return `the script's folder (${run.dir}) can no longer be read`;
551
+ }
552
+ if (helpers.length > MAX_GROUP_HELPERS) {
553
+ return `the script's folder (${run.dir}) holds more than ${MAX_GROUP_HELPERS} helper files; keep each group in its own folder, qcentriq_tests/<group_id>/`;
554
+ }
555
+ const sent = new Set(fixtures.map((f) => f.file_name));
556
+ const missing = helpers.filter((helper) => !sent.has(helper));
557
+ if (missing.length) {
558
+ return `in the script's folder (${run.dir}) but not in fixtures: ${missing.join(", ")}. A save replaces the group's whole helper set, so a helper left out would be deleted from QCentriq; pass every helper in fixtures, or delete the ones the script no longer uses`;
559
+ }
501
560
  return null;
502
561
  }
503
562
 
504
563
  // src/local/environment-setup.ts
505
564
  import { spawn } from "child_process";
506
- import * as fs3 from "fs/promises";
507
- import * as path3 from "path";
565
+ import * as fs4 from "fs/promises";
566
+ import * as path4 from "path";
508
567
  var MANAGER_PRIORITY = ["uv", "poetry", "conda", "venv"];
509
568
  var PROBE_TIMEOUT_MS = 5e3;
510
569
  var DEFAULT_PYTHON_VERSION = "3.12";
@@ -567,7 +626,7 @@ async function probePython() {
567
626
  }
568
627
  async function fileExists(filePath) {
569
628
  try {
570
- await fs3.access(filePath);
629
+ await fs4.access(filePath);
571
630
  return true;
572
631
  } catch {
573
632
  return false;
@@ -584,7 +643,7 @@ async function detectProjectFiles(workingDir) {
584
643
  ];
585
644
  const found = [];
586
645
  for (const candidate of candidates) {
587
- if (await fileExists(path3.join(workingDir, candidate))) {
646
+ if (await fileExists(path4.join(workingDir, candidate))) {
588
647
  found.push(candidate);
589
648
  }
590
649
  }
@@ -735,7 +794,7 @@ function detectActiveEnvironment() {
735
794
  return null;
736
795
  }
737
796
  async function buildEnvironmentSetupPlan(params = {}) {
738
- const workingDir = params.workingDir ? path3.resolve(params.workingDir) : process.cwd();
797
+ const workingDir = params.workingDir ? path4.resolve(params.workingDir) : process.cwd();
739
798
  const [packageManagers, projectFiles] = await Promise.all([detectPackageManagers(), detectProjectFiles(workingDir)]);
740
799
  const availability = new Map(packageManagers.map((m) => [m.name, m.available]));
741
800
  const preferred = params.preferredManager;
@@ -801,18 +860,21 @@ function registerSaveGroupScriptTool(server, client, config, passingRuns, versio
801
860
  server.registerTool(
802
861
  "qcentriq_save_group_script",
803
862
  {
804
- description: "Save a test script you wrote back to QCentriq so the cloud runner executes exactly what you ran locally. Only a script that passed qcentriq_run_local_test as a whole file, with this exact content, is uploaded; each fixture must match the file next to it when it ran. The script is validated before it is stored: valid Python, and every unblocked test case in the group present exactly once as @allure.id('<case_id>') (blocked cases may be left out) \u2014 no duplicates, no ids from other groups. A rejection names the offending id or line so you can correct it. The save is checked against the version from your last qcentriq_download_script (or save) of this group, so if someone else changed the script since, it is refused rather than overwritten; download again, reapply your change and save. conftest.py cannot be saved; QCentriq provides it. Requires the 'test:write' scope.",
863
+ description: "Save a test script you wrote back to QCentriq so the cloud runner executes exactly what you ran locally. Only a script that passed qcentriq_run_local_test as a whole file, with this exact content, is uploaded. Keep the script and its helpers in the group's folder, qcentriq_tests/<group_id>/; helpers may sit in nested folders and are imported normally (e.g. from pages.login_page import LoginPage). Pass every helper in that folder in fixtures, each file_name its path relative to the folder (e.g. 'pages/login_page.py') and matching the file the passing run used: a save replaces the group's whole helper set, so a helper left out is deleted, and a save that leaves out a helper still in the folder is refused. The script is validated before it is stored: valid Python, and every unblocked test case in the group present exactly once as @allure.id('<case_id>') (blocked cases may be left out) \u2014 no duplicates, no ids from other groups. A rejection names the offending id or line so you can correct it. The save is checked against the version from your last qcentriq_download_script (or save) of this group, so if someone else changed the script since, it is refused rather than overwritten; download again, reapply your change and save. conftest.py cannot be saved; QCentriq provides it. Requires the 'test:write' scope.",
805
864
  inputSchema: z10.object({
806
865
  group_id: z10.uuid().describe("UUID of the target test group."),
807
866
  content: z10.string().describe("The Python test script source."),
808
867
  project_id: z10.uuid().optional().describe("Optional project UUID (inferred from the API key if omitted)."),
809
868
  filename: z10.string().optional().describe("Optional script filename; derived from the group title if omitted."),
810
- fixtures: z10.array(z10.object({ file_name: z10.string(), content: z10.string() })).optional().describe("Companion files to store next to the script (page objects, test data). conftest.py is rejected.")
869
+ fixtures: z10.array(z10.object({ file_name: z10.string(), content: z10.string() })).optional().describe("The group's complete helper set (page objects, utilities, test data), each file_name relative to the script's folder, e.g. 'pages/login_page.py'. Replaces every helper stored before. conftest.py is rejected."),
870
+ visual_testing_enabled: z10.boolean().optional().describe("Optional per-group visual testing override (omit to keep existing group setting)."),
871
+ visual_masking_enabled: z10.boolean().optional().describe("Optional per-group dynamic content masking override."),
872
+ visual_diff_threshold: z10.number().min(0).max(1).optional().describe("Optional per-group visual diff threshold percentage from 0.0 (0.0%) to 1.0 (1.0%).")
811
873
  }),
812
874
  annotations: {
813
875
  readOnlyHint: false,
814
876
  destructiveHint: true,
815
- // Replaces the group's existing script.
877
+ // Replaces the group's script and its whole helper set.
816
878
  idempotentHint: true,
817
879
  // Saving the same content twice leaves the same state.
818
880
  openWorldHint: false
@@ -934,12 +996,12 @@ function registerUpdateTestCaseTool(server, client, config) {
934
996
 
935
997
  // src/tools/local-run.ts
936
998
  import { z as z13 } from "zod";
937
- import * as fs4 from "fs/promises";
938
- import * as path5 from "path";
999
+ import * as fs5 from "fs/promises";
1000
+ import * as path6 from "path";
939
1001
 
940
1002
  // src/local/runner.ts
941
1003
  import { spawn as spawn2 } from "child_process";
942
- import * as path4 from "path";
1004
+ import * as path5 from "path";
943
1005
  function buildTestEnv(params) {
944
1006
  const env = {
945
1007
  ...process.env,
@@ -957,12 +1019,18 @@ function buildTestEnv(params) {
957
1019
  if (params.groupId) {
958
1020
  env.QCENTRIQ_TEST_GROUP_ID = params.groupId;
959
1021
  }
1022
+ if (params.visualTestingEnabled !== void 0) {
1023
+ env.QCENTRIQ_VISUAL_TESTING_ENABLED = params.visualTestingEnabled ? "true" : "false";
1024
+ }
1025
+ if (params.visualMaskingEnabled !== void 0) {
1026
+ env.QCENTRIQ_VISUAL_MASKING_ENABLED = params.visualMaskingEnabled ? "true" : "false";
1027
+ }
960
1028
  return env;
961
1029
  }
962
1030
  function resolvePytestCommand() {
963
1031
  const venv = process.env.VIRTUAL_ENV;
964
1032
  if (!venv) return "pytest";
965
- return process.platform === "win32" ? path4.join(venv, "Scripts", "pytest.exe") : path4.join(venv, "bin", "pytest");
1033
+ return process.platform === "win32" ? path5.join(venv, "Scripts", "pytest.exe") : path5.join(venv, "bin", "pytest");
966
1034
  }
967
1035
  function killProcessTree(child) {
968
1036
  if (child.pid && process.platform !== "win32") {
@@ -1006,7 +1074,7 @@ function attempt(cmd, args, cwd, env, timeoutMs) {
1006
1074
  }
1007
1075
  async function runLocalPytest(params) {
1008
1076
  const startTime = Date.now();
1009
- const cwd = params.workingDir ? path4.resolve(params.workingDir) : process.cwd();
1077
+ const cwd = params.workingDir ? path5.resolve(params.workingDir) : process.cwd();
1010
1078
  const timeoutSeconds = params.timeoutSeconds || 60;
1011
1079
  const args = [params.filePath];
1012
1080
  if (params.testName) {
@@ -1070,6 +1138,8 @@ function registerLocalRunTool(server, client, passingRuns) {
1070
1138
  browser: z13.enum(["chromium", "firefox", "webkit"]).default("chromium").describe("Browser engine to execute against (default 'chromium')."),
1071
1139
  base_url: z13.url().optional().describe("Target application base URL (e.g. from qcentriq_get_environment). Injected as BASE_URL env var."),
1072
1140
  group_id: z13.string().optional().describe("Test group UUID this script belongs to. Injected as QCENTRIQ_TEST_GROUP_ID so the Allure results stay mappable back to the QCentriq group."),
1141
+ visual_testing_enabled: z13.boolean().optional().describe("Whether to enable visual snapshot capture during this local run. Injected as QCENTRIQ_VISUAL_TESTING_ENABLED."),
1142
+ visual_masking_enabled: z13.boolean().optional().describe("Whether to enable dynamic content masking during this local run. Injected as QCENTRIQ_VISUAL_MASKING_ENABLED."),
1073
1143
  env_vars: z13.record(z13.string(), z13.string()).optional().describe("Environment variables to inject into the local test process."),
1074
1144
  extra_args: z13.array(z13.string()).optional().describe("Additional CLI arguments to pass to pytest (e.g. ['-s', '--alluredir=allure-results'])."),
1075
1145
  timeout_seconds: z13.number().int().min(5).max(300).default(60).describe("Timeout in seconds for test execution (default 60)."),
@@ -1078,10 +1148,14 @@ function registerLocalRunTool(server, client, passingRuns) {
1078
1148
  },
1079
1149
  async (args) => {
1080
1150
  try {
1081
- const scriptPath = path5.resolve(args.working_dir ?? process.cwd(), args.file_path.split("::")[0]);
1082
- const ownDir = qcentriqDirAbove(path5.dirname(scriptPath));
1083
- if (ownDir) await refreshConftest(client, ownDir);
1084
- const content = await fs4.readFile(scriptPath, "utf-8").catch(() => null);
1151
+ const scriptPath = path6.resolve(args.working_dir ?? process.cwd(), args.file_path.split("::")[0]);
1152
+ const cwd = args.working_dir ? path6.resolve(args.working_dir) : process.cwd();
1153
+ const ownDir = qcentriqDirAbove(path6.dirname(scriptPath));
1154
+ if (ownDir) {
1155
+ await refreshConftest(client, ownDir);
1156
+ await clearLocalSnapshots(cwd, ownDir, path6.dirname(scriptPath));
1157
+ }
1158
+ const content = await fs5.readFile(scriptPath, "utf-8").catch(() => null);
1085
1159
  const startedAt = Date.now();
1086
1160
  const result = await runLocalPytest({
1087
1161
  filePath: args.file_path,
@@ -1090,12 +1164,17 @@ function registerLocalRunTool(server, client, passingRuns) {
1090
1164
  browser: args.browser,
1091
1165
  baseUrl: args.base_url,
1092
1166
  groupId: args.group_id,
1167
+ visualTestingEnabled: args.visual_testing_enabled,
1168
+ visualMaskingEnabled: args.visual_masking_enabled,
1093
1169
  envVars: args.env_vars,
1094
1170
  extraArgs: args.extra_args,
1095
1171
  timeoutSeconds: args.timeout_seconds,
1096
1172
  workingDir: args.working_dir
1097
1173
  });
1098
- if (ownDir) await fs4.rm(path5.join(ownDir, "qc_state.json"), { force: true });
1174
+ if (ownDir) {
1175
+ await fs5.rm(path6.join(ownDir, "qc_state.json"), { force: true });
1176
+ await clearLocalSnapshots(cwd, ownDir, path6.dirname(scriptPath));
1177
+ }
1099
1178
  const statusText = result.passed ? "PASSED" : "FAILED";
1100
1179
  const summary = [
1101
1180
  `Local Test Run Result: ${statusText} (exit code ${result.exitCode})`,
@@ -1110,7 +1189,7 @@ function registerLocalRunTool(server, client, passingRuns) {
1110
1189
  ];
1111
1190
  const next = await nextStep(result, args, content !== null);
1112
1191
  if (next.uploadable && content !== null) {
1113
- passingRuns.record(content, { filePath: scriptPath, dir: path5.dirname(scriptPath), startedAt });
1192
+ passingRuns.record(content, { filePath: scriptPath, dir: path6.dirname(scriptPath), startedAt });
1114
1193
  }
1115
1194
  if (next.text) summary.push("", next.text);
1116
1195
  return { isError: !result.passed, content: [{ type: "text", text: summary.join("\n") }] };
@@ -1120,16 +1199,23 @@ function registerLocalRunTool(server, client, passingRuns) {
1120
1199
  }
1121
1200
  );
1122
1201
  }
1202
+ async function clearLocalSnapshots(...dirs) {
1203
+ const unique = new Set(dirs.map((d) => path6.resolve(d)));
1204
+ for (const dir of unique) {
1205
+ await fs5.rm(path6.join(dir, "__snapshots__"), { recursive: true, force: true });
1206
+ await fs5.rm(path6.join(dir, "snapshot_failures"), { recursive: true, force: true });
1207
+ }
1208
+ }
1123
1209
  function qcentriqDirAbove(dir) {
1124
- for (let d = dir; ; d = path5.dirname(d)) {
1125
- if (path5.basename(d) === path5.basename(DEFAULT_SCRIPT_DIR)) return d;
1126
- if (path5.dirname(d) === d) return null;
1210
+ for (let d = dir; ; d = path6.dirname(d)) {
1211
+ if (path6.basename(d) === path6.basename(DEFAULT_SCRIPT_DIR)) return d;
1212
+ if (path6.dirname(d) === d) return null;
1127
1213
  }
1128
1214
  }
1129
1215
  async function refreshConftest(client, dir) {
1130
1216
  try {
1131
1217
  const { content } = await client.request("/conftest");
1132
- await fs4.writeFile(path5.join(dir, "conftest.py"), content, "utf-8");
1218
+ await fs5.writeFile(path6.join(dir, "conftest.py"), content, "utf-8");
1133
1219
  } catch (err) {
1134
1220
  logger.warn(`Could not refresh conftest.py: ${err.message}`);
1135
1221
  }
package/package.json CHANGED
@@ -1,51 +1,51 @@
1
- {
2
- "name": "@qcentriq/mcp",
3
- "version": "0.4.6",
4
- "description": "Official Model Context Protocol (MCP) server for QCentriq automated test discovery, diagnostics, and execution.",
5
- "type": "module",
6
- "bin": {
7
- "qcentriq-mcp": "dist/index.js"
8
- },
9
- "files": [
10
- "dist"
11
- ],
12
- "engines": {
13
- "node": ">=22.12.0"
14
- },
15
- "publishConfig": {
16
- "access": "public"
17
- },
18
- "scripts": {
19
- "build": "tsup",
20
- "dev": "tsx src/index.ts",
21
- "test": "vitest run",
22
- "typecheck": "tsc --noEmit",
23
- "prepublishOnly": "npm run typecheck && npm test && npm run build"
24
- },
25
- "keywords": [
26
- "mcp",
27
- "model-context-protocol",
28
- "qcentriq",
29
- "playwright",
30
- "testing",
31
- "ai",
32
- "automation",
33
- "claude-desktop",
34
- "cursor"
35
- ],
36
- "author": "QCentriq",
37
- "license": "Apache-2.0",
38
- "dependencies": {
39
- "@modelcontextprotocol/server": "^2.2.0",
40
- "commander": "^15.0.0",
41
- "zod": "^4.5.4"
42
- },
43
- "devDependencies": {
44
- "@modelcontextprotocol/client": "^2.2.0",
45
- "@types/node": "^22.20.4",
46
- "tsup": "^8.4.0",
47
- "tsx": "^4.19.3",
48
- "typescript": "^5.8.2",
49
- "vitest": "^5.0.0"
50
- }
51
- }
1
+ {
2
+ "name": "@qcentriq/mcp",
3
+ "version": "0.5.1",
4
+ "description": "Official Model Context Protocol (MCP) server for QCentriq automated test discovery, diagnostics, and execution.",
5
+ "type": "module",
6
+ "bin": {
7
+ "qcentriq-mcp": "dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "engines": {
13
+ "node": ">=22.12.0"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "scripts": {
19
+ "build": "tsup",
20
+ "dev": "tsx src/index.ts",
21
+ "test": "vitest run",
22
+ "typecheck": "tsc --noEmit",
23
+ "prepublishOnly": "npm run typecheck && npm test && npm run build"
24
+ },
25
+ "keywords": [
26
+ "mcp",
27
+ "model-context-protocol",
28
+ "qcentriq",
29
+ "playwright",
30
+ "testing",
31
+ "ai",
32
+ "automation",
33
+ "claude-desktop",
34
+ "cursor"
35
+ ],
36
+ "author": "QCentriq",
37
+ "license": "Apache-2.0",
38
+ "dependencies": {
39
+ "@modelcontextprotocol/server": "^2.2.0",
40
+ "commander": "^15.0.0",
41
+ "zod": "^4.5.4"
42
+ },
43
+ "devDependencies": {
44
+ "@modelcontextprotocol/client": "^2.2.0",
45
+ "@types/node": "^22.20.4",
46
+ "tsup": "^8.4.0",
47
+ "tsx": "^4.19.3",
48
+ "typescript": "^5.8.2",
49
+ "vitest": "^5.0.0"
50
+ }
51
+ }