@qcentriq/mcp 0.4.3 → 0.4.5

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 (3) hide show
  1. package/README.md +9 -7
  2. package/dist/index.js +134 -41
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -14,7 +14,7 @@ Connect your AI coding assistants (**Cursor**, **Claude Desktop**, **VS Code Cli
14
14
  - **Remote Cloud Discovery & Diagnostics**: Instantly query test cases, groups, run logs, failure stack traces, and environment variables via authenticated REST client endpoints.
15
15
  - **Local Playwright Test Execution**: Safely execute tests locally with `pytest` without triggering unwanted cloud runners. Supports headless and headed modes across Chromium, Firefox, and WebKit.
16
16
  - **Smart Environment Setup**: Probes installed local Python package managers (`uv`, `poetry`, `conda`, or standard `venv`) and generates ready-to-run setup commands (prefers `uv` for lightning-fast setup).
17
- - **Direct Workspace Script Saving**: Download test scripts and accompanying fixtures (`conftest.py`) into a dedicated `qcentriq_tests/` workspace directory (kept apart from your own `tests/`, so an existing `conftest.py` is never overwritten) with path traversal protections.
17
+ - **Direct Workspace Script Saving**: Download test scripts and their helper files into a dedicated `qcentriq_tests/` workspace directory (kept apart from your own `tests/`, so an existing `conftest.py` is never overwritten). Before each local run there, `qcentriq_run_local_test` refreshes the `conftest.py` QCentriq cloud runs use with path traversal protections.
18
18
  - **Zero-Leak Redaction**: Automatically filters all outgoing tool payloads, masking API keys (`qc_...`), bearer tokens, and URL credentials before sending them to the LLM.
19
19
  - **Strict Stdio Isolation**: Protocol JSON-RPC frames communicate cleanly over `stdout`, while all diagnostic logs route to `stderr`.
20
20
 
@@ -240,7 +240,7 @@ The QCentriq MCP Server cleanly separates **remote cloud discovery/diagnostics**
240
240
  | `qcentriq_list_tests` | Discover test cases and test groups with status, priority, and update timestamps. Script availability is highlighted. | `project_id` *(uuid)*, `group_id` *(uuid)*, `priority` *("low"\|"medium"\|"high"\|"critical")*, `test_type` *("web"\|"api"\|"mobile")*, `limit` *(int)*, `offset` *(int)* |
241
241
  | `qcentriq_get_test` | Retrieve full test case definitions, step descriptions, preconditions, latest execution diagnostics, and error stack traces. | `test_case_id` *(uuid, required)*, `project_id` *(uuid)* |
242
242
  | `qcentriq_get_test_groups` | Discover and inspect test groups, member test cases, test counts, and script availability. | `project_id` *(uuid)*, `group_id` *(uuid)*, `limit` *(int)*, `offset` *(int)* |
243
- | `qcentriq_download_script` | Download Playwright Python test script and accompanying fixtures (`conftest.py`) and save them to `./qcentriq_tests/` (the same directory `qcentriq_save_script` uses). Pass `save_to_disk=false` to only return the content. | `group_id` *(uuid, required)*, `project_id` *(uuid)*, `include_fixtures` *(bool, default true)*, `save_to_disk` *(bool, default true)*, `destination_dir` *(string, default "./qcentriq_tests")* |
243
+ | `qcentriq_download_script` | Download Playwright Python test script and its helper files and save them to `./qcentriq_tests/` (the same directory `qcentriq_save_script` uses). Pass `save_to_disk=false` to only return the content. | `group_id` *(uuid, required)*, `project_id` *(uuid)*, `include_fixtures` *(bool, default true)*, `save_to_disk` *(bool, default true)*, `destination_dir` *(string, default "./qcentriq_tests")* |
244
244
  | `qcentriq_get_environment` | Retrieve target environment configuration, base URL (`BASE_URL`), environment variables, and required secret variable names for local execution. | `project_id` *(uuid)*, `environment_id` *(uuid)*, `environment_name` *(string)* |
245
245
  | `qcentriq_get_test_run_logs` | Fetch execution history, logs, stdout/stderr, and stack traces across single-case and suite runs. | `test_case_id` *(uuid, required)*, `project_id` *(uuid)*, `run_id` *(uuid)*, `status` *("failed"\|"passed"\|"error")*, `latest_only` *(bool)*, `from_date` *(ISO date)*, `to_date` *(ISO date)*, `limit` *(int)*, `offset` *(int)* |
246
246
 
@@ -253,8 +253,10 @@ Both write tools send to QCentriq as soon as they are called; your MCP client's
253
253
  | Tool Name | Description | Key Arguments |
254
254
  | :--- | :--- | :--- |
255
255
  | `qcentriq_get_authoring_guide` | Fetch the contract for plans and scripts: the TaskPlan JSON schema, the `${VAR}` environment-variable convention, the `@allure.id` rules, and the available conftest fixtures. Read-only. | — |
256
- | `qcentriq_create_plan` | Create test groups and test cases from an authored plan. Returns one UUID per created test case. **Writes.** | `plan` *(object, required)*, `project_id` *(uuid)* |
257
- | `qcentriq_save_group_script` | Validate and store a test script for a group, replacing the existing one. Every case in the group must appear exactly once as `@allure.id('<case_id>')`. Only uploads a script that passed `qcentriq_run_local_test` with this exact content (see [Local pass before upload](#-security--privacy)). Checked against the version from the last download or save of the group in this session, so someone else's newer edit is refused as a conflict instead of overwritten. **Writes.** | `group_id` *(uuid, required)*, `content` *(string, required)*, `project_id` *(uuid)*, `filename` *(string)*, `fixtures` *(array)* |
256
+ | `qcentriq_create_plan` | Create test groups and test cases from an authored plan. Returns one UUID per created test case. A case whose flow failed in the browser can be created with `status: "blocked"` and an evidence `block_reason`; QCentriq re-validates it live and keeps it blocked only if it sees the same failure (`block_source` shows `client` until then). **Writes.** | `plan` *(object, required)*, `project_id` *(uuid)* |
257
+ | `qcentriq_save_group_script` | Validate and store a test script for a group, replacing the existing one. Every unblocked case in the group must appear exactly once as `@allure.id('<case_id>')`; blocked cases may be left out. Only uploads a script that passed `qcentriq_run_local_test` with this exact content (see [Local pass before upload](#-security--privacy)). Checked against the version from the last download or save of the group in this session, so someone else's newer edit is refused as a conflict instead of overwritten. **Writes.** | `group_id` *(uuid, required)*, `content` *(string, required)*, `project_id` *(uuid)*, `filename` *(string)*, `fixtures` *(array)* |
258
+ | `qcentriq_update_test_case` | Edit an existing test case (title, description, priority, preconditions, steps, expected result, target URL) instead of creating a duplicate. Requires `last_updated_at` from `qcentriq_get_test`; a newer edit by someone else is refused as a conflict. Reports `script_stale` when the change means the group script needs updating. Blocked status is not editable. **Writes.** | `test_case_id` *(uuid, required)*, `expected_last_updated_at` *(string, required)*, plus the fields to change, `project_id` *(uuid)* |
259
+ | `qcentriq_recheck_blocked_case` | Ask QCentriq to re-validate a blocked test case against the live site. QCentriq's own agent decides the verdict: `active` unblocks the case and adds it to the group script (in a group whose script you wrote, you add the test yourself), `blocked` refreshes `block_reason`. The caller cannot set the verdict. Can take several minutes (client timeout 7 min). **Writes.** | `test_case_id` *(uuid, required)*, `project_id` *(uuid)* |
258
260
 
259
261
  ### 💻 Local Client Tools (Executed in Your Local Workspace)
260
262
 
@@ -294,8 +296,8 @@ sequenceDiagram
294
296
 
295
297
  AI->>MCP: qcentriq_download_script(group_id="...")
296
298
  MCP->>API: GET /api/v1/mcp-client/groups/{id}/script
297
- API-->>MCP: Script & conftest.py content
298
- MCP->>Local: Write qcentriq_tests/test_login.py & conftest.py
299
+ API-->>MCP: Script & helper files
300
+ MCP->>Local: Write qcentriq_tests/test_login.py
299
301
  MCP-->>AI: File paths confirmed
300
302
 
301
303
  AI->>Local: Inspect and update selector in test_login.py
@@ -309,7 +311,7 @@ sequenceDiagram
309
311
 
310
312
  ## 🔒 Security & Privacy
311
313
 
312
- - **Safe Network Boundary**: The client MCP server connects **exclusively** to `${baseUrl}/api/v1/mcp-client/` using HTTPS. Discovery and diagnostics tools only read. The authoring tools `qcentriq_create_plan` and `qcentriq_save_group_script` write to your project (creating test groups/cases and replacing a group's script), and the backend rejects them unless the API key carries the `test:write` scope.
314
+ - **Safe Network Boundary**: The client MCP server connects **exclusively** to `${baseUrl}/api/v1/mcp-client/` using HTTPS. Discovery and diagnostics tools only read. The authoring tools `qcentriq_create_plan`, `qcentriq_update_test_case`, `qcentriq_save_group_script` and `qcentriq_recheck_blocked_case` write to your project (creating and editing test groups/cases, replacing a group's script, and unblocking a case when QCentriq's live recheck confirms it works), and the backend rejects them unless the API key carries the `test:write` scope.
313
315
  - **Local Pass Before Upload**: `qcentriq_save_group_script` refuses a script unless that exact content passed `qcentriq_run_local_test` in the current server session, as a whole file: no `test_name`, node id, or `-k`/`-m`/`--deselect`/`--lf`-style filters, and at least one test passed (not all skipped). Each companion file must match the file that sat next to the script during that run and not have changed since. Passing runs are kept in memory, so after a restart the script has to be run again. If no Python package manager is installed, the refusal says to install [`uv`](https://docs.astral.sh/uv/getting-started/installation/) first (recommended), then use `qcentriq_get_setup_instructions`.
314
316
  - **Client-Side Control**: Test executions, script modifications, and environment setups happen **locally on your machine**. No local code or files are uploaded without your knowledge.
315
317
  - **Zero-Leak Redaction**: The server actively scans and redacts API keys (`qc_...`), bearer tokens, and embedded basic-auth credentials before returning data to the LLM.
package/dist/index.js CHANGED
@@ -126,11 +126,14 @@ var QCentriqApiClient = class {
126
126
  }
127
127
  return this.call("GET", path6, query);
128
128
  }
129
- /** Authenticated JSON write against the QCentriq backend. */
130
- async send(method, path6, body) {
131
- return this.call(method, path6, void 0, body);
129
+ /**
130
+ * Authenticated JSON write against the QCentriq backend. `timeoutMs`
131
+ * overrides the configured timeout for a call known to be slow.
132
+ */
133
+ async send(method, path6, body, opts = {}) {
134
+ return this.call(method, path6, void 0, body, opts.timeoutMs);
132
135
  }
133
- async call(method, path6, query, body) {
136
+ async call(method, path6, query, body, timeoutMs) {
134
137
  const cleanPath = path6.startsWith("/") ? path6 : `/${path6}`;
135
138
  const qs = query?.toString();
136
139
  const url = `${this.config.baseUrl}/api/v1/mcp-client${cleanPath}${qs ? `?${qs}` : ""}`;
@@ -140,10 +143,13 @@ var QCentriqApiClient = class {
140
143
  Accept: "application/json"
141
144
  };
142
145
  if (body) headers["Content-Type"] = "application/json";
143
- const res = await this.fetchWithTimeout(method, cleanPath, url, {
144
- headers,
145
- body: body ? JSON.stringify(body) : void 0
146
- });
146
+ const res = await this.fetchWithTimeout(
147
+ method,
148
+ cleanPath,
149
+ url,
150
+ { headers, body: body ? JSON.stringify(body) : void 0 },
151
+ timeoutMs ?? this.config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS
152
+ );
147
153
  if (!res.ok) {
148
154
  throw new Error(`API error (${res.status}): ${await readErrorDetail(res)}`);
149
155
  }
@@ -153,8 +159,7 @@ var QCentriqApiClient = class {
153
159
  * Issue a request that is aborted after the configured timeout, reporting
154
160
  * the timeout as such rather than as a bare AbortError.
155
161
  */
156
- async fetchWithTimeout(method, path6, url, init) {
157
- const timeoutMs = this.config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
162
+ async fetchWithTimeout(method, path6, url, init, timeoutMs) {
158
163
  try {
159
164
  return await fetch(url, { ...init, method, signal: AbortSignal.timeout(timeoutMs) });
160
165
  } catch (err) {
@@ -309,11 +314,11 @@ function registerDownloadScriptTool(server, client, config, versions) {
309
314
  server.registerTool(
310
315
  "qcentriq_download_script",
311
316
  {
312
- description: `Download test group script and accompanying fixture files (e.g. conftest.py) for local test execution and editing. 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.`,
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.`,
313
318
  inputSchema: z5.object({
314
319
  group_id: z5.uuid().describe("UUID of the target test group."),
315
320
  project_id: z5.uuid().optional().describe("Optional project UUID (inferred from API key if omitted)."),
316
- include_fixtures: z5.boolean().default(true).describe("Whether to retrieve accompanying conftest.py / fixtures (default True)."),
321
+ include_fixtures: z5.boolean().default(true).describe("Whether to retrieve accompanying helper files (default True)."),
317
322
  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."),
318
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.`)
319
324
  })
@@ -402,7 +407,7 @@ function registerAuthoringGuideTool(server, client) {
402
407
  server.registerTool(
403
408
  "qcentriq_get_authoring_guide",
404
409
  {
405
- description: "Fetch the contract for authoring QCentriq test plans and scripts: the TaskPlan JSON schema, the ${VAR} environment-variable convention, the @allure.id rules a saved script is validated against, and the conftest fixtures a script may use. Call this before writing a plan or a test script \u2014 a script that violates the contract is rejected on save. Then explore the app under test with the Playwright MCP server (browser_navigate, browser_snapshot) before writing, so the plan and locators match what the app really shows.",
410
+ description: "Fetch the contract for authoring QCentriq test plans and scripts: the TaskPlan JSON schema, the ${VAR} environment-variable convention, the @allure.id rules and data-driven `state` placeholder rules a saved script is validated against, and the conftest fixtures a script may use. Call this before writing a plan or a test script \u2014 a script that violates the contract is rejected on save. Then explore the app under test with the Playwright MCP server (browser_navigate, browser_snapshot) before writing, so the plan and locators match what the app really shows.",
406
411
  inputSchema: z8.object({}),
407
412
  annotations: {
408
413
  readOnlyHint: true,
@@ -423,7 +428,7 @@ function registerCreatePlanTool(server, client, config) {
423
428
  server.registerTool(
424
429
  "qcentriq_create_plan",
425
430
  {
426
- description: "Create test groups and test cases in QCentriq from a plan you authored. Call qcentriq_get_authoring_guide first, and walk through every flow in the plan with the Playwright MCP server (browser_navigate, browser_snapshot) when it is connected, so each test case describes behaviour you saw rather than guessed. The plan must match the TaskPlan schema, and any value that exists as a project environment variable must be written as ${VAR_NAME} rather than inlined. Returns one UUID per created test case; each must appear exactly once as @allure.id('<case_id>') in the script you then save with qcentriq_save_group_script. Requires an API key with the 'test:write' scope.",
431
+ description: "Create test groups and test cases in QCentriq from a plan you authored. Call qcentriq_get_authoring_guide first, and walk through every flow in the plan with the Playwright MCP server (browser_navigate, browser_snapshot) when it is connected, so each test case describes behaviour you saw rather than guessed. The plan must match the TaskPlan schema, and any value that exists as a project environment variable must be written as ${VAR_NAME} rather than inlined. Returns one UUID per created test case; each unblocked one must appear exactly once as @allure.id('<case_id>') in the script you then save with qcentriq_save_group_script. A case whose flow you saw fail in the browser may be created with status 'blocked' and a block_reason describing the failure: it is left out of the script, and QCentriq re-validates it live, keeping it blocked only if it sees the same failure. Never block a case because your script fails. Requires an API key with the 'test:write' scope.",
427
432
  inputSchema: z9.object({
428
433
  plan: z9.record(z9.string(), z9.any()).describe("The plan object, matching the TaskPlan schema from qcentriq_get_authoring_guide."),
429
434
  project_id: z9.uuid().optional().describe("Optional project UUID (inferred from the API key if omitted).")
@@ -510,8 +515,8 @@ var FALLBACK_TEST_PACKAGES = [
510
515
  "allure-pytest",
511
516
  "httpx",
512
517
  "nest-asyncio",
513
- "pytest-playwright-visual-snapshot",
514
- "Pillow"
518
+ "Pillow",
519
+ "numpy"
515
520
  ];
516
521
  function testDependencies(playwrightVersion, packages) {
517
522
  const base = packages && packages.length > 0 ? packages : FALLBACK_TEST_PACKAGES;
@@ -796,7 +801,7 @@ function registerSaveGroupScriptTool(server, client, config, passingRuns, versio
796
801
  server.registerTool(
797
802
  "qcentriq_save_group_script",
798
803
  {
799
- 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 test case in the group present exactly once as @allure.id('<case_id>') \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.",
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.",
800
805
  inputSchema: z10.object({
801
806
  group_id: z10.uuid().describe("UUID of the target test group."),
802
807
  content: z10.string().describe("The Python test script source."),
@@ -852,8 +857,83 @@ ${notice}` : reason;
852
857
  return null;
853
858
  }
854
859
 
855
- // src/tools/local-run.ts
860
+ // src/tools/recheck-blocked-case.ts
856
861
  import { z as z11 } from "zod";
862
+ var RECHECK_TIMEOUT_MS = 42e4;
863
+ function registerRecheckBlockedCaseTool(server, client, config) {
864
+ server.registerTool(
865
+ "qcentriq_recheck_blocked_case",
866
+ {
867
+ description: "Ask QCentriq to re-validate a blocked test case against the live site. QCentriq's own agent replays the case in a browser and decides: an 'active' verdict unblocks the case and adds it to the group script (for a group whose script you wrote, QCentriq leaves the script alone and next_step tells you to add the test); 'blocked' keeps it blocked with fresh evidence in block_reason. You cannot choose the verdict. Use it after the cause of the block (a broken page, wrong data) has been fixed; find blocked cases with qcentriq_list_tests. Takes up to a few minutes. After an unblock, re-download the group script before editing it. Requires an API key with the 'test:write' scope.",
868
+ inputSchema: z11.object({
869
+ test_case_id: z11.uuid().describe("UUID of the blocked test case."),
870
+ project_id: z11.uuid().optional().describe("Optional project UUID (inferred from the API key if omitted).")
871
+ }),
872
+ annotations: {
873
+ readOnlyHint: false,
874
+ destructiveHint: false,
875
+ // Changes only blocked status, and only on the server's verdict.
876
+ idempotentHint: false,
877
+ // Each call is a fresh live run whose verdict can differ.
878
+ openWorldHint: true
879
+ // Drives a browser against the project's live site.
880
+ }
881
+ },
882
+ async ({ test_case_id, project_id }) => {
883
+ try {
884
+ return jsonResult(
885
+ await client.send(
886
+ "POST",
887
+ `/tests/${test_case_id}/recheck`,
888
+ { project_id: project_id || config.defaultProjectId },
889
+ { timeoutMs: RECHECK_TIMEOUT_MS }
890
+ )
891
+ );
892
+ } catch (err) {
893
+ const hint = /timed out/.test(err.message) ? " The recheck may still complete on the server; call qcentriq_get_test for this case to see whether it is still blocked." : "";
894
+ return errorResult(`Error in qcentriq_recheck_blocked_case: ${err.message}${hint}`);
895
+ }
896
+ }
897
+ );
898
+ }
899
+
900
+ // src/tools/update-test-case.ts
901
+ import { z as z12 } from "zod";
902
+ function registerUpdateTestCaseTool(server, client, config) {
903
+ server.registerTool(
904
+ "qcentriq_update_test_case",
905
+ {
906
+ description: "Edit an existing test case's content instead of creating a duplicate with qcentriq_create_plan. Read the case with qcentriq_get_test first and pass its last_updated_at as expected_last_updated_at; if someone edited it since, the call fails with 409 and you must re-read and reapply. Send only the fields you change. Blocked/active status cannot be edited here (use qcentriq_recheck_blocked_case). If the response says script_stale, update the group script to match: qcentriq_download_script, edit, qcentriq_run_local_test, qcentriq_save_group_script. Requires an API key with the 'test:write' scope.",
907
+ inputSchema: z12.object({
908
+ test_case_id: z12.uuid().describe("UUID of the test case to edit."),
909
+ expected_last_updated_at: z12.string().describe("last_updated_at from your latest qcentriq_get_test of this case."),
910
+ title: z12.string().min(1).max(255).optional(),
911
+ description: z12.string().optional(),
912
+ priority: z12.enum(["high", "medium", "low"]).optional(),
913
+ preconditions: z12.string().optional(),
914
+ steps_description: z12.string().optional(),
915
+ expected_result: z12.string().optional(),
916
+ target_url: z12.string().optional().describe("Write project environment values as ${VAR_NAME}."),
917
+ project_id: z12.uuid().optional().describe("Optional project UUID (inferred from the API key if omitted).")
918
+ }),
919
+ annotations: {
920
+ readOnlyHint: false,
921
+ destructiveHint: true,
922
+ // Overwrites the fields it is given.
923
+ idempotentHint: false,
924
+ // A repeat carries a stale version and is refused.
925
+ openWorldHint: false
926
+ }
927
+ },
928
+ async ({ test_case_id, project_id, ...edit }) => backendCall(
929
+ "qcentriq_update_test_case",
930
+ () => client.send("PATCH", `/tests/${test_case_id}`, { project_id: project_id || config.defaultProjectId, ...edit })
931
+ )
932
+ );
933
+ }
934
+
935
+ // src/tools/local-run.ts
936
+ import { z as z13 } from "zod";
857
937
  import * as fs4 from "fs/promises";
858
938
  import * as path5 from "path";
859
939
 
@@ -875,7 +955,7 @@ function buildTestEnv(params) {
875
955
  env.HEADLESS = params.headless ? "true" : "false";
876
956
  }
877
957
  if (params.groupId) {
878
- env.QCAQ_TEST_GROUP_ID = params.groupId;
958
+ env.QCENTRIQ_TEST_GROUP_ID = params.groupId;
879
959
  }
880
960
  return env;
881
961
  }
@@ -978,27 +1058,29 @@ async function runLocalPytest(params) {
978
1058
  }
979
1059
 
980
1060
  // src/tools/local-run.ts
981
- function registerLocalRunTool(server, passingRuns) {
1061
+ function registerLocalRunTool(server, client, passingRuns) {
982
1062
  server.registerTool(
983
1063
  "qcentriq_run_local_test",
984
1064
  {
985
- description: "Execute a downloaded Playwright/pytest test script locally in the developer's environment. Runs pytest as a local subprocess and returns stdout, stderr, exit code, and test diagnostics without using QCentriq cloud runners. A script must pass here, as a whole file (no test_name or other test filters), before qcentriq_save_group_script will upload it.",
986
- inputSchema: z11.object({
987
- file_path: z11.string().describe("Path to the local test file to run (e.g. 'tests/test_login.py')."),
988
- test_name: z11.string().optional().describe("Optional specific test function name or expression to run (passed to pytest -k)."),
989
- headless: z11.boolean().default(true).describe("Whether to run the browser in headless mode (default True). Set False to watch the browser execution live."),
990
- browser: z11.enum(["chromium", "firefox", "webkit"]).default("chromium").describe("Browser engine to execute against (default 'chromium')."),
991
- base_url: z11.url().optional().describe("Target application base URL (e.g. from qcentriq_get_environment). Injected as BASE_URL env var."),
992
- group_id: z11.string().optional().describe("Test group UUID this script belongs to. Injected as QCAQ_TEST_GROUP_ID so the Allure results stay mappable back to the QCentriq group."),
993
- env_vars: z11.record(z11.string(), z11.string()).optional().describe("Environment variables to inject into the local test process."),
994
- extra_args: z11.array(z11.string()).optional().describe("Additional CLI arguments to pass to pytest (e.g. ['-s', '--alluredir=allure-results'])."),
995
- timeout_seconds: z11.number().int().min(5).max(300).default(60).describe("Timeout in seconds for test execution (default 60)."),
996
- working_dir: z11.string().optional().describe("Working directory to run pytest in (defaults to current project directory).")
1065
+ description: "Execute a downloaded Playwright/pytest test script locally in the developer's environment. Runs pytest as a local subprocess (in qcentriq_tests/ it first refreshes the conftest.py QCentriq cloud runs use) and returns stdout, stderr, exit code, and test diagnostics without using QCentriq cloud runners. A script must pass here, as a whole file (no test_name or other test filters), before qcentriq_save_group_script will upload it.",
1066
+ inputSchema: z13.object({
1067
+ file_path: z13.string().describe("Path to the local test file to run (e.g. 'tests/test_login.py')."),
1068
+ test_name: z13.string().optional().describe("Optional specific test function name or expression to run (passed to pytest -k)."),
1069
+ headless: z13.boolean().default(true).describe("Whether to run the browser in headless mode (default True). Set False to watch the browser execution live."),
1070
+ browser: z13.enum(["chromium", "firefox", "webkit"]).default("chromium").describe("Browser engine to execute against (default 'chromium')."),
1071
+ base_url: z13.url().optional().describe("Target application base URL (e.g. from qcentriq_get_environment). Injected as BASE_URL env var."),
1072
+ 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."),
1073
+ env_vars: z13.record(z13.string(), z13.string()).optional().describe("Environment variables to inject into the local test process."),
1074
+ extra_args: z13.array(z13.string()).optional().describe("Additional CLI arguments to pass to pytest (e.g. ['-s', '--alluredir=allure-results'])."),
1075
+ timeout_seconds: z13.number().int().min(5).max(300).default(60).describe("Timeout in seconds for test execution (default 60)."),
1076
+ working_dir: z13.string().optional().describe("Working directory to run pytest in (defaults to current project directory).")
997
1077
  })
998
1078
  },
999
1079
  async (args) => {
1000
1080
  try {
1001
1081
  const scriptPath = path5.resolve(args.working_dir ?? process.cwd(), args.file_path.split("::")[0]);
1082
+ const ownDir = path5.basename(path5.dirname(scriptPath)) === path5.basename(DEFAULT_SCRIPT_DIR) ? path5.dirname(scriptPath) : null;
1083
+ if (ownDir) await refreshConftest(client, ownDir);
1002
1084
  const content = await fs4.readFile(scriptPath, "utf-8").catch(() => null);
1003
1085
  const startedAt = Date.now();
1004
1086
  const result = await runLocalPytest({
@@ -1013,6 +1095,7 @@ function registerLocalRunTool(server, passingRuns) {
1013
1095
  timeoutSeconds: args.timeout_seconds,
1014
1096
  workingDir: args.working_dir
1015
1097
  });
1098
+ if (ownDir) await fs4.rm(path5.join(ownDir, "qc_state.json"), { force: true });
1016
1099
  const statusText = result.passed ? "PASSED" : "FAILED";
1017
1100
  const summary = [
1018
1101
  `Local Test Run Result: ${statusText} (exit code ${result.exitCode})`,
@@ -1037,6 +1120,14 @@ function registerLocalRunTool(server, passingRuns) {
1037
1120
  }
1038
1121
  );
1039
1122
  }
1123
+ async function refreshConftest(client, dir) {
1124
+ try {
1125
+ const { content } = await client.request("/conftest");
1126
+ await fs4.writeFile(path5.join(dir, "conftest.py"), content, "utf-8");
1127
+ } catch (err) {
1128
+ logger.warn(`Could not refresh conftest.py: ${err.message}`);
1129
+ }
1130
+ }
1040
1131
  async function nextStep(result, args, scriptReadable) {
1041
1132
  if (result.pytestMissing) {
1042
1133
  const notice = installUvNotice(await detectPackageManagers());
@@ -1059,7 +1150,7 @@ async function nextStep(result, args, scriptReadable) {
1059
1150
  }
1060
1151
 
1061
1152
  // src/tools/setup-instructions.ts
1062
- import { z as z12 } from "zod";
1153
+ import { z as z14 } from "zod";
1063
1154
  async function fetchRuntimeRequirements(client) {
1064
1155
  try {
1065
1156
  const res = await client.request("/runtime-requirements");
@@ -1077,12 +1168,12 @@ function registerSetupInstructionsTool(server, client) {
1077
1168
  "qcentriq_get_setup_instructions",
1078
1169
  {
1079
1170
  description: "Check which Python package managers (uv, poetry, conda, or the stdlib venv module) are installed on the developer's machine and return step-by-step commands for creating an environment that can run QCentriq Playwright/pytest tests locally. Prefers uv when it is available; if no package manager is installed, the steps start by installing uv. Returns instructions only \u2014 it does not create the environment.",
1080
- inputSchema: z12.object({
1081
- preferred_manager: z12.enum(["uv", "poetry", "conda", "venv"]).optional().describe("Force instructions for a specific package manager. Falls back to the best available one if it is not installed."),
1082
- working_dir: z12.string().optional().describe("Directory to inspect for pyproject.toml / lockfiles / requirements.txt (defaults to the current project directory)."),
1083
- env_name: z12.string().default("qcentriq-tests").describe("Name for the created environment (used by conda, default 'qcentriq-tests')."),
1084
- python_version: z12.string().default("3.12").describe("Python version to request when creating the environment (default '3.12', matching the QCentriq execution container)."),
1085
- playwright_version: z12.string().optional().describe("Playwright version to pin when installing test dependencies. Defaults to the version the project's active execution image is built against, as reported by the backend.")
1171
+ inputSchema: z14.object({
1172
+ preferred_manager: z14.enum(["uv", "poetry", "conda", "venv"]).optional().describe("Force instructions for a specific package manager. Falls back to the best available one if it is not installed."),
1173
+ working_dir: z14.string().optional().describe("Directory to inspect for pyproject.toml / lockfiles / requirements.txt (defaults to the current project directory)."),
1174
+ env_name: z14.string().default("qcentriq-tests").describe("Name for the created environment (used by conda, default 'qcentriq-tests')."),
1175
+ python_version: z14.string().default("3.12").describe("Python version to request when creating the environment (default '3.12', matching the QCentriq execution container)."),
1176
+ playwright_version: z14.string().optional().describe("Playwright version to pin when installing test dependencies. Defaults to the version the project's active execution image is built against, as reported by the backend.")
1086
1177
  }),
1087
1178
  annotations: {
1088
1179
  readOnlyHint: true,
@@ -1124,8 +1215,10 @@ function registerAllTools(server, client, config) {
1124
1215
  registerAuthoringGuideTool(server, client);
1125
1216
  registerCreatePlanTool(server, client, config);
1126
1217
  registerSaveGroupScriptTool(server, client, config, passingRuns, versions);
1218
+ registerUpdateTestCaseTool(server, client, config);
1219
+ registerRecheckBlockedCaseTool(server, client, config);
1127
1220
  registerSaveScriptTool(server);
1128
- registerLocalRunTool(server, passingRuns);
1221
+ registerLocalRunTool(server, client, passingRuns);
1129
1222
  registerSetupInstructionsTool(server, client);
1130
1223
  logger.info("Registered QCentriq MCP tools.");
1131
1224
  }
@@ -1141,7 +1234,7 @@ To write a new test plan or script:
1141
1234
  1. Call qcentriq_get_authoring_guide for the plan schema and script rules, and qcentriq_get_environment for the BASE_URL of the app under test.
1142
1235
  2. Explore the app with the Playwright MCP server before writing anything. Start by navigating to the actual BASE_URL, then open each page under test (for example with browser_navigate), read it with browser_snapshot, and click through every flow the plan will cover. Take URLs, labels, roles and selectors from what the browser shows; do not guess them. If the Playwright MCP server is not connected, tell the user that the plan and script will be based on guesses about the app and recommend connecting it (npx @playwright/mcp@latest) before going on.
1143
1236
  3. Create the plan with qcentriq_create_plan, describing only flows you saw.
1144
- 4. Write the script using the locators you found, run it with qcentriq_run_local_test until the whole file passes, then upload it with qcentriq_save_group_script.
1237
+ 4. Write the script using the locators you found, reading every typed value through the state fixture as the guide's test_data_rules describe. Run it with qcentriq_run_local_test until the whole file passes, passing each variable an env.* placeholder reads in env_vars (env.admin_password reads ADMIN_PASSWORD; base_url covers env.base_url), then upload it with qcentriq_save_group_script. The first upload turns the script's defaults into each test case's data set.
1145
1238
 
1146
1239
  HTTP basic auth: a site behind basic auth answers 401 before any app content loads, so the page comes back blank (browser_snapshot shows nothing; browser_network_requests shows the 401). This is not the app's own login form. Do not stop there, and do not plan from the blank page:
1147
1240
  - Find the credentials the user defined: in their request, or in the variables from qcentriq_get_environment, either BASIC_AUTH_USERNAME and BASIC_AUTH_PASSWORD or the keys named by QCENTRIQ_BASIC_AUTH_USERNAME_KEY and QCENTRIQ_BASIC_AUTH_PASSWORD_KEY.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qcentriq/mcp",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Official Model Context Protocol (MCP) server for QCentriq automated test discovery, diagnostics, and execution.",
5
5
  "type": "module",
6
6
  "bin": {