@qcentriq/mcp 0.4.1 → 0.4.2

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/README.md CHANGED
@@ -26,7 +26,7 @@ Connect your AI coding assistants (**Cursor**, **Claude Desktop**, **VS Code Cli
26
26
  Launch the MCP server directly using `npx`:
27
27
 
28
28
  ```bash
29
- npx -y @qcentriq/mcp --api-key "qc_your_api_key_here"
29
+ npx -y @qcentriq/mcp@latest --api-key "qc_your_api_key_here"
30
30
  ```
31
31
 
32
32
  Or pass your configuration via environment variables:
@@ -36,7 +36,7 @@ export QCENTRIQ_API_KEY="qc_your_api_key_here"
36
36
  export QCENTRIQ_BASE_URL="https://api.qcentriq.com" # Optional, defaults to production
37
37
  export QCENTRIQ_PROJECT_ID="your-project-uuid" # Optional default project ID
38
38
 
39
- npx -y @qcentriq/mcp
39
+ npx -y @qcentriq/mcp@latest
40
40
  ```
41
41
 
42
42
  ### Global Installation
@@ -72,7 +72,7 @@ Add QCentriq to your configuration file:
72
72
  "mcpServers": {
73
73
  "qcentriq": {
74
74
  "command": "npx",
75
- "args": ["-y", "@qcentriq/mcp"],
75
+ "args": ["-y", "@qcentriq/mcp@latest"],
76
76
  "env": {
77
77
  "QCENTRIQ_API_KEY": "qc_your_api_key_here",
78
78
  "QCENTRIQ_BASE_URL": "https://api.qcentriq.com",
@@ -93,7 +93,7 @@ In Cursor, open **Settings** $\to$ **Features** $\to$ **MCP Servers** $\to$ **Ad
93
93
  "mcpServers": {
94
94
  "qcentriq": {
95
95
  "command": "npx",
96
- "args": ["-y", "@qcentriq/mcp"],
96
+ "args": ["-y", "@qcentriq/mcp@latest"],
97
97
  "env": {
98
98
  "QCENTRIQ_API_KEY": "qc_your_api_key_here",
99
99
  "QCENTRIQ_BASE_URL": "https://api.qcentriq.com"
@@ -113,7 +113,7 @@ In VS Code with the Cline or Roo Code extension, open `cline_mcp_settings.json`:
113
113
  "mcpServers": {
114
114
  "qcentriq": {
115
115
  "command": "npx",
116
- "args": ["-y", "@qcentriq/mcp"],
116
+ "args": ["-y", "@qcentriq/mcp@latest"],
117
117
  "env": {
118
118
  "QCENTRIQ_API_KEY": "qc_your_api_key_here"
119
119
  },
@@ -139,7 +139,7 @@ In `~/.codeium/windsurf/mcp_config.json`:
139
139
  "mcpServers": {
140
140
  "qcentriq": {
141
141
  "command": "npx",
142
- "args": ["-y", "@qcentriq/mcp"],
142
+ "args": ["-y", "@qcentriq/mcp@latest"],
143
143
  "env": {
144
144
  "QCENTRIQ_API_KEY": "qc_your_api_key_here"
145
145
  }
@@ -158,7 +158,7 @@ In your Zed `settings.json` (under `experimental.context_servers`):
158
158
  "context_servers": {
159
159
  "qcentriq": {
160
160
  "command": "npx",
161
- "args": ["-y", "@qcentriq/mcp"],
161
+ "args": ["-y", "@qcentriq/mcp@latest"],
162
162
  "env": {
163
163
  "QCENTRIQ_API_KEY": "qc_your_api_key_here"
164
164
  }
@@ -177,7 +177,7 @@ In `~/.gemini/config/mcp_config.json` (or `.agents/mcp_config.json` in workspace
177
177
  "mcpServers": {
178
178
  "qcentriq": {
179
179
  "command": "npx",
180
- "args": ["-y", "@qcentriq/mcp"],
180
+ "args": ["-y", "@qcentriq/mcp@latest"],
181
181
  "env": {
182
182
  "QCENTRIQ_API_KEY": "qc_your_api_key_here",
183
183
  "QCENTRIQ_BASE_URL": "https://api.qcentriq.com"
@@ -193,7 +193,7 @@ In `~/.gemini/config/mcp_config.json` (or `.agents/mcp_config.json` in workspace
193
193
  Add the QCentriq MCP server using the Claude CLI:
194
194
 
195
195
  ```bash
196
- claude mcp add qcentriq -- npx -y @qcentriq/mcp --api-key "qc_your_api_key_here"
196
+ claude mcp add qcentriq -- npx -y @qcentriq/mcp@latest --api-key "qc_your_api_key_here"
197
197
  ```
198
198
 
199
199
 
package/dist/index.js CHANGED
@@ -561,8 +561,9 @@ function probeCommand(cmd, args) {
561
561
  child.on("close", (code) => finish(code === 0 ? output.trim().split("\n")[0].trim() || "unknown" : null));
562
562
  });
563
563
  }
564
+ var PYTHON_BIN = process.platform === "win32" ? "python" : "python3";
564
565
  async function probePython() {
565
- for (const bin of ["python3", "python"]) {
566
+ for (const bin of [PYTHON_BIN, "python"]) {
566
567
  const version = await probeCommand(bin, ["-c", "import venv, sys; print(sys.version.split()[0])"]);
567
568
  if (version) {
568
569
  return { bin, version };
@@ -610,7 +611,7 @@ async function detectPackageManagers() {
610
611
  name: "venv",
611
612
  available: Boolean(python),
612
613
  version: python ? `${python.bin} ${python.version}` : void 0,
613
- probe_command: "python3 -m venv"
614
+ probe_command: `${PYTHON_BIN} -m venv`
614
615
  }
615
616
  ];
616
617
  }
@@ -690,7 +691,7 @@ function buildCondaSteps(ctx) {
690
691
  function buildVenvSteps(ctx) {
691
692
  const deps = testDependencies(ctx.playwrightVersion, ctx.packages);
692
693
  const steps = [
693
- { description: "Create a virtual environment in .venv.", command: "python3 -m venv .venv" },
694
+ { description: "Create a virtual environment in .venv.", command: `${PYTHON_BIN} -m venv .venv` },
694
695
  { description: "Activate the virtual environment.", command: activateCommand(ctx) },
695
696
  { description: "Upgrade pip inside the environment.", command: "python -m pip install --upgrade pip" }
696
697
  ];
@@ -723,12 +724,12 @@ var INSTALL_HINTS = {
723
724
  uv: "uv: https://docs.astral.sh/uv/getting-started/installation/",
724
725
  poetry: "poetry: https://python-poetry.org/docs/#installation",
725
726
  conda: "conda (miniconda): https://docs.conda.io/projects/miniconda/en/latest/",
726
- venv: "python3 with the venv module: https://www.python.org/downloads/"
727
+ venv: "Python with the venv module: https://www.python.org/downloads/"
727
728
  };
728
729
  function installUvNotice(managers) {
729
730
  if (managers.some((m) => m.available)) return null;
730
731
  const command = process.platform === "win32" ? UV_INSTALL_COMMANDS.windows : UV_INSTALL_COMMANDS.unix;
731
- return `No Python package manager (uv, poetry, conda or python3 with venv) was found on this machine. Ask the user to install uv first, the recommended option: \`${command}\` (see https://docs.astral.sh/uv/getting-started/installation/). Then call qcentriq_get_setup_instructions for the commands that create the test environment, and restart the MCP client from that environment.`;
732
+ return `No Python package manager (uv, poetry, conda or python with venv) was found on this machine. Ask the user to install uv first, the recommended option: \`${command}\` (see https://docs.astral.sh/uv/getting-started/installation/). Then call qcentriq_get_setup_instructions for the commands that create the test environment, and restart the MCP client from that environment.`;
732
733
  }
733
734
  function detectActiveEnvironment() {
734
735
  if (process.env.VIRTUAL_ENV) {
@@ -955,13 +956,13 @@ async function runLocalPytest(params) {
955
956
  if (outcome.error.code !== "ENOENT") {
956
957
  return failure(`Failed to spawn process: ${outcome.error.message}. Ensure pytest is installed in your Python environment.`, `${cmd} ${cmdArgs.join(" ")}`, false);
957
958
  }
958
- logger.warn("pytest binary not found directly, falling back to python3 -m pytest...");
959
+ logger.warn(`pytest binary not found directly, falling back to ${PYTHON_BIN} -m pytest...`);
959
960
  const primary = `${cmd} ${cmdArgs.join(" ")}`;
960
- cmd = "python3";
961
+ cmd = PYTHON_BIN;
961
962
  cmdArgs = ["-m", "pytest", ...args];
962
963
  outcome = await attempt(cmd, cmdArgs, cwd, env, timeoutSeconds * 1e3);
963
964
  if (!outcome.launched) {
964
- return failure(`Failed to execute pytest or python3 -m pytest: ${outcome.error.message}. Ensure pytest is installed in your Python environment.`, primary, true);
965
+ return failure(`Failed to execute pytest or ${PYTHON_BIN} -m pytest: ${outcome.error.message}. Ensure pytest is installed in your Python environment.`, primary, true);
965
966
  }
966
967
  }
967
968
  return {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/utils/logger.ts","../src/utils/sanitizer.ts","../src/client/api.ts","../src/server.ts","../src/tools/list-tests.ts","../src/tools/results.ts","../src/tools/get-test.ts","../src/tools/get-groups.ts","../src/tools/download-script.ts","../src/tools/save-script.ts","../src/tools/environment.ts","../src/tools/run-logs.ts","../src/tools/authoring-guide.ts","../src/tools/create-plan.ts","../src/tools/save-group-script.ts","../src/local/passing-runs.ts","../src/local/environment-setup.ts","../src/tools/local-run.ts","../src/local/runner.ts","../src/tools/setup-instructions.ts","../src/tools/index.ts","../src/version.ts"],"sourcesContent":["import { serveStdio } from \"@modelcontextprotocol/server/stdio\";\nimport { loadConfig } from \"./config.js\";\nimport { QCentriqApiClient } from \"./client/api.js\";\nimport { createServer } from \"./server.js\";\nimport { logger } from \"./utils/logger.js\";\n\nfunction main(): void {\n try {\n const config = loadConfig(process.argv);\n logger.info(`Starting QCentriq MCP Server against: ${config.baseUrl}`);\n\n const apiClient = new QCentriqApiClient(config);\n\n // serveStdio, not server.connect: a hand-wired transport only speaks the\n // 2025 protocol revisions, while this serves 2026-07-28 clients as well.\n const handle = serveStdio(() => createServer(apiClient, config));\n\n const cleanup = async () => {\n logger.info(\"Shutting down QCentriq MCP Server...\");\n await handle.close();\n process.exit(0);\n };\n\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n logger.info(\"QCentriq MCP Server is running on stdio.\");\n } catch (err: any) {\n logger.error(\"Fatal error during QCentriq MCP Server startup:\", err.message);\n process.exit(1);\n }\n}\n\nmain();\n","import { Command } from \"commander\";\nimport { QCentriqConfig } from \"./types.js\";\nimport { logger, setDebugLogging } from \"./utils/logger.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.qcentriq.com\";\n\nexport function loadConfig(argv: string[] = process.argv): QCentriqConfig {\n const program = new Command();\n\n program\n .name(\"qcentriq-mcp\")\n .description(\"QCentriq Model Context Protocol (MCP) Server for automated test discovery and execution\")\n .option(\"-k, --api-key <key>\", \"QCentriq API key (or QCENTRIQ_API_KEY env var)\")\n .option(\"-u, --base-url <url>\", \"QCentriq API base URL (or QCENTRIQ_BASE_URL env var)\")\n .option(\"-p, --project-id <id>\", \"Default QCentriq project UUID (or QCENTRIQ_PROJECT_ID env var)\")\n .option(\"-d, --debug\", \"Enable debug logging to stderr (or DEBUG/QCENTRIQ_DEBUG env var)\")\n .allowUnknownOption(true)\n .parse(argv);\n\n const opts = program.opts();\n\n const apiKey = opts.apiKey || process.env.QCENTRIQ_API_KEY || \"\";\n const rawBaseUrl = opts.baseUrl || process.env.QCENTRIQ_BASE_URL || DEFAULT_BASE_URL;\n const baseUrl = rawBaseUrl.replace(/\\/+$/, \"\");\n const defaultProjectId = opts.projectId || process.env.QCENTRIQ_PROJECT_ID;\n const debug = Boolean(opts.debug || process.env.DEBUG || process.env.QCENTRIQ_DEBUG);\n\n if (debug) {\n setDebugLogging(true);\n }\n\n if (!apiKey) {\n logger.error(\"Missing QCentriq API key!\");\n logger.error(\"Provide it via --api-key <key> or set the QCENTRIQ_API_KEY environment variable.\");\n logger.error(\"Example: QCENTRIQ_API_KEY=qc_xxxxxxxxxxxx npx -y @qcentriq/mcp\");\n process.exit(1);\n }\n\n return {\n apiKey,\n baseUrl,\n defaultProjectId,\n debug,\n };\n}\n","/**\n * Logger for QCentriq MCP Server.\n *\n * CRITICAL: In MCP stdio servers, standard output (stdout) is reserved\n * exclusively for JSON-RPC messages. Any text printed to stdout will\n * corrupt the MCP protocol stream. All logging MUST go to standard error (stderr).\n */\n\nlet isDebugEnabled = Boolean(process.env.DEBUG || process.env.QCENTRIQ_DEBUG);\n\nexport function setDebugLogging(enabled: boolean): void {\n isDebugEnabled = enabled;\n}\n\nfunction formatMessage(level: string, message: string, ...args: any[]): string {\n const timestamp = new Date().toISOString();\n const extra = args.length > 0 ? \" \" + args.map((a) => (typeof a === \"object\" ? JSON.stringify(a) : String(a))).join(\" \") : \"\";\n return `[${timestamp}] [QCentriq MCP] [${level}] ${message}${extra}\\n`;\n}\n\nexport const logger = {\n info(message: string, ...args: any[]): void {\n process.stderr.write(formatMessage(\"INFO\", message, ...args));\n },\n warn(message: string, ...args: any[]): void {\n process.stderr.write(formatMessage(\"WARN\", message, ...args));\n },\n error(message: string, ...args: any[]): void {\n process.stderr.write(formatMessage(\"ERROR\", message, ...args));\n },\n debug(message: string, ...args: any[]): void {\n if (isDebugEnabled) {\n process.stderr.write(formatMessage(\"DEBUG\", message, ...args));\n }\n },\n};\n","/**\n * Zero-Leak Credential Redactor for QCentriq MCP Server.\n *\n * Ensures API keys, bearer tokens, passwords, and sensitive values\n * are redacted before tool payloads are returned to the LLM.\n */\n\n// Matches QCentriq API keys: qc_ followed by 40 hex chars\nconst QCENTRIQ_KEY_REGEX = /qc_[0-9a-fA-F]{30,45}/g;\n\n// Matches Bearer JWT tokens\nconst BEARER_TOKEN_REGEX = /Bearer\\s+ey[A-Za-z0-9-_=]+\\.[A-Za-z0-9-_=]+\\.?[A-Za-z0-9-_.+/=]*/g;\n\n// Matches embedded credentials in URLs: https://user:pass@example.com -> https://example.com\nconst URL_CREDENTIALS_REGEX = /([a-zA-Z][a-zA-Z0-9+.-]*:\\/\\/)[^/\\s:@]+:[^/\\s:@]+@/g;\n\nexport function sanitizeText(text: string): string {\n if (!text) return text;\n return text\n .replace(QCENTRIQ_KEY_REGEX, \"[REDACTED_API_KEY]\")\n .replace(BEARER_TOKEN_REGEX, \"Bearer [REDACTED_TOKEN]\")\n .replace(URL_CREDENTIALS_REGEX, \"$1[REDACTED_USERINFO]@\");\n}\n\nexport function sanitizePayload<T>(value: T): T {\n if (value === null || value === undefined) {\n return value;\n }\n if (typeof value === \"string\") {\n return sanitizeText(value) as unknown as T;\n }\n if (Array.isArray(value)) {\n return value.map((item) => sanitizePayload(item)) as unknown as T;\n }\n if (typeof value === \"object\") {\n const copy: Record<string, any> = {};\n for (const [k, v] of Object.entries(value)) {\n // If the field name looks like a secret/token/password and the value is string, mask it\n if (\n /password|secret|token|api_?key|auth/i.test(k) &&\n typeof v === \"string\" &&\n v.length > 0\n ) {\n copy[k] = \"[REDACTED]\";\n } else {\n copy[k] = sanitizePayload(v);\n }\n }\n return copy as T;\n }\n return value;\n}\n","import { QCentriqConfig } from \"../types.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { sanitizePayload } from \"../utils/sanitizer.js\";\n\n/**\n * How long a backend call may take before it is aborted.\n *\n * Without a limit, a backend that accepts the connection and never answers\n * blocks the tool call indefinitely, and the agent has no way to recover.\n */\nexport const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;\n\n/**\n * Extract a readable message from a failed response.\n *\n * The body is read once as text and parsed afterwards: a body can only be\n * consumed once, so a failed `res.json()` would leave nothing for a text\n * fallback. Non-JSON bodies are common — a proxy in front of the backend\n * answers a 502 with HTML.\n */\nasync function readErrorDetail(res: Response): Promise<string> {\n let text: string;\n try {\n text = await res.text();\n } catch {\n return res.statusText;\n }\n if (!text) return res.statusText;\n\n try {\n const json: any = JSON.parse(text);\n // The backend's validation messages name the offending field, id or\n // line; passing them through is what lets the calling agent fix itself.\n return json?.detail || JSON.stringify(json);\n } catch {\n return text;\n }\n}\n\nexport class QCentriqApiClient {\n constructor(private readonly config: QCentriqConfig) {}\n\n /**\n * Authenticated GET against the QCentriq backend (/api/v1/mcp-client/...).\n * Undefined and null params are left out of the query string.\n */\n async request(path: string, params: Record<string, any> = {}): Promise<any> {\n const query = new URLSearchParams();\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined && value !== null) {\n query.set(key, String(value));\n }\n }\n return this.call(\"GET\", path, query);\n }\n\n /** Authenticated JSON write against the QCentriq backend. */\n async send(method: \"POST\" | \"PUT\", path: string, body: Record<string, any>): Promise<any> {\n return this.call(method, path, undefined, body);\n }\n\n private async call(method: string, path: string, query?: URLSearchParams, body?: Record<string, any>): Promise<any> {\n const cleanPath = path.startsWith(\"/\") ? path : `/${path}`;\n const qs = query?.toString();\n const url = `${this.config.baseUrl}/api/v1/mcp-client${cleanPath}${qs ? `?${qs}` : \"\"}`;\n logger.debug(`[mcp-client] HTTP ${method} ${url}`);\n\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.config.apiKey}`,\n Accept: \"application/json\",\n };\n if (body) headers[\"Content-Type\"] = \"application/json\";\n\n const res = await this.fetchWithTimeout(method, cleanPath, url, {\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!res.ok) {\n throw new Error(`API error (${res.status}): ${await readErrorDetail(res)}`);\n }\n\n return sanitizePayload(await res.json());\n }\n\n /**\n * Issue a request that is aborted after the configured timeout, reporting\n * the timeout as such rather than as a bare AbortError.\n */\n private async fetchWithTimeout(method: string, path: string, url: string, init: RequestInit): Promise<Response> {\n const timeoutMs = this.config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;\n try {\n return await fetch(url, { ...init, method, signal: AbortSignal.timeout(timeoutMs) });\n } catch (err: any) {\n if (err?.name === \"TimeoutError\") {\n throw new Error(`${method} ${path} timed out after ${timeoutMs}ms`);\n }\n throw err;\n }\n }\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { QCentriqApiClient } from \"./client/api.js\";\nimport { registerAllTools } from \"./tools/index.js\";\nimport { QCentriqConfig } from \"./types.js\";\nimport { PACKAGE_VERSION } from \"./version.js\";\n\n/**\n * Sent to the client at initialize; most clients add it to the assistant's\n * system prompt. This server cannot see or call other MCP servers, so the\n * Playwright MCP step is guidance, not something it can enforce.\n */\nexport const SERVER_INSTRUCTIONS = `QCentriq MCP finds, runs, diagnoses and writes QCentriq Playwright tests.\n\nTo write a new test plan or script:\n1. 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.\n2. 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.\n3. Create the plan with qcentriq_create_plan, describing only flows you saw.\n4. 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.\n\nHTTP 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:\n- 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.\n- Navigate again with them in the URL, https://<username>:<password>@host/path, percent-encoding reserved characters (@ as %40, : as %3A). Playwright MCP's default Chromium browser then remembers them for that origin, so later navigations and clicks need no credentials. Then explore as usual.\n- Ask the user only if the credentials are not there, for example when they are listed only in secret_keys: QCentriq never returns secret values.\n- In the plan, note the basic-auth precondition using the environment's variable names, never the values.\n- In the script, do not put credentials in URLs or call any auth API yourself: the conftest QCentriq ships applies basic auth to every browser context from BASIC_AUTH_USERNAME and BASIC_AUTH_PASSWORD (or the keys named by QCENTRIQ_BASIC_AUTH_USERNAME_KEY and QCENTRIQ_BASIC_AUTH_PASSWORD_KEY, as in the cloud). For qcentriq_run_local_test, pass BASIC_AUTH_USERNAME and BASIC_AUTH_PASSWORD in env_vars with the values you found.`;\n\nexport function createServer(client: QCentriqApiClient, config: QCentriqConfig): McpServer {\n const server = new McpServer({ name: \"@qcentriq/mcp\", version: PACKAGE_VERSION }, { instructions: SERVER_INSTRUCTIONS });\n registerAllTools(server, client, config);\n return server;\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { backendCall } from \"./results.js\";\n\nexport function registerListTestsTool(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n server.registerTool(\n \"qcentriq_list_tests\",\n {\n description:\n \"Discover and list automated test cases and test groups for a project with status, priority, and update dates. Test group script availability is indicated in test_groups. Blocked test cases have no script.\",\n inputSchema: z.object({\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from API key if omitted).\"),\n group_id: z.uuid().optional().describe(\"Optional test group UUID filter.\"),\n priority: z.enum([\"low\", \"medium\", \"high\", \"critical\"]).optional().describe(\"Filter by priority.\"),\n test_type: z.enum([\"web\", \"api\", \"mobile\"]).optional().describe(\"Filter by test type.\"),\n status: z.enum([\"failed\", \"passed\", \"error\", \"never_run\", \"blocked\", \"active\", \"flaky\"]).optional().describe(\"Filter by test status (e.g. 'failed' or 'blocked').\"),\n limit: z.number().int().min(1).max(100).default(50).describe(\"Max number of test cases to return (default 50).\"),\n offset: z.number().int().min(0).default(0).describe(\"Pagination offset.\"),\n }),\n },\n async (args) =>\n backendCall(\"qcentriq_list_tests\", () =>\n client.request(\"/tests\", { ...args, project_id: args.project_id || config.defaultProjectId })\n )\n );\n}\n","export type TextResult = { isError?: boolean; content: Array<{ type: \"text\"; text: string }> };\n\nexport function jsonResult(data: unknown): TextResult {\n return { content: [{ type: \"text\", text: JSON.stringify(data, null, 2) }] };\n}\n\nexport function errorResult(text: string): TextResult {\n return { isError: true, content: [{ type: \"text\", text }] };\n}\n\n/** Run a backend call for `tool`, returning its payload as JSON or its failure as a tool error. */\nexport async function backendCall(tool: string, run: () => Promise<unknown>): Promise<TextResult> {\n try {\n return jsonResult(await run());\n } catch (err: any) {\n return errorResult(`Error in ${tool}: ${err.message}`);\n }\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { backendCall } from \"./results.js\";\n\nexport function registerGetTestTool(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n server.registerTool(\n \"qcentriq_get_test\",\n {\n description:\n \"Retrieve detailed test case information including step definitions, preconditions, latest execution diagnostics, error stack traces, and parent test group script metadata.\",\n inputSchema: z.object({\n test_case_id: z.uuid().describe(\"UUID of the target test case.\"),\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from API key if omitted).\"),\n }),\n },\n async ({ test_case_id, ...query }) =>\n backendCall(\"qcentriq_get_test\", () =>\n client.request(`/tests/${test_case_id}`, { ...query, project_id: query.project_id || config.defaultProjectId })\n )\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { backendCall } from \"./results.js\";\n\nexport function registerGetTestGroupsTool(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n server.registerTool(\n \"qcentriq_get_test_groups\",\n {\n description:\n \"Discover and inspect test groups for a project. Returns what each group is about (title, description), total/active/blocked test case counts, and whether a test script exists. Provide group_id to inspect member test cases.\",\n inputSchema: z.object({\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from API key if omitted).\"),\n group_id: z.uuid().optional().describe(\"Optional test group UUID filter to inspect a specific group.\"),\n limit: z.number().int().min(1).max(100).default(50).describe(\"Max test groups to return (default 50).\"),\n offset: z.number().int().min(0).default(0).describe(\"Pagination offset.\"),\n }),\n },\n async (args) =>\n backendCall(\"qcentriq_get_test_groups\", () =>\n client.request(\"/groups\", { ...args, project_id: args.project_id || config.defaultProjectId })\n )\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { DEFAULT_SCRIPT_DIR, saveScriptFiles } from \"./save-script.js\";\nimport { jsonResult, errorResult } from \"./results.js\";\n\nexport function registerDownloadScriptTool(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n server.registerTool(\n \"qcentriq_download_script\",\n {\n description:\n `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.`,\n inputSchema: z.object({\n group_id: z.uuid().describe(\"UUID of the target test group.\"),\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from API key if omitted).\"),\n include_fixtures: z.boolean().default(true).describe(\"Whether to retrieve accompanying conftest.py / fixtures (default True).\"),\n save_to_disk: z.boolean().default(true).describe(\"Saves the downloaded test script and fixtures to destination_dir (default True). Set false to only return the content.\"),\n destination_dir: z.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.`),\n }),\n },\n async (args) => {\n let data: any;\n try {\n data = await client.request(`/groups/${args.group_id}/script`, {\n project_id: args.project_id || config.defaultProjectId,\n include_fixtures: args.include_fixtures,\n });\n } catch (err: any) {\n return errorResult(`Error in qcentriq_download_script: ${err.message}`);\n }\n\n if (!args.save_to_disk || !data?.file_name || !data?.content) return jsonResult(data);\n\n // Save where qcentriq_save_script writes, so both tools leave files in one place\n try {\n data.saved_files = await saveScriptFiles(args.destination_dir, data.file_name, data.content, data.conftest_content);\n return jsonResult(data);\n } catch (writeErr: any) {\n logger.warn(`Failed to write downloaded script to disk: ${writeErr.message}`);\n // The caller asked for files on disk, so reporting success would send\n // it to run a file that does not exist. The download itself is kept\n // so the script can still be saved with qcentriq_save_script.\n return {\n isError: true,\n content: [\n {\n type: \"text\" as const,\n 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.`,\n },\n ...jsonResult(data).content,\n ],\n };\n }\n }\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { logger } from \"../utils/logger.js\";\nimport { jsonResult, errorResult } from \"./results.js\";\n\n/**\n * Default destination for downloaded scripts.\n *\n * Deliberately not \"./tests\": that is where most Python projects keep their own\n * suite, and writing a QCentriq conftest.py there would overwrite the\n * developer's own. A dedicated directory keeps the two side by side.\n */\nexport const DEFAULT_SCRIPT_DIR = \"./qcentriq_tests\";\n\nexport function registerSaveScriptTool(server: McpServer): void {\n server.registerTool(\n \"qcentriq_save_script\",\n {\n description:\n \"Save downloaded Playwright Python test script and fixtures directly to the local workspace disk so they can be run or edited locally.\",\n inputSchema: z.object({\n file_name: z.string().describe(\"Target filename (e.g. 'test_login.py').\"),\n content: z.string().describe(\"Python test script source code.\"),\n conftest_content: z.string().optional().describe(\"Accompanying conftest.py source code if present.\"),\n destination_dir: z.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.`),\n }),\n },\n async (args) => {\n try {\n const savedFiles = await saveScriptFiles(args.destination_dir ?? DEFAULT_SCRIPT_DIR, args.file_name, args.content, args.conftest_content);\n return jsonResult({\n status: \"success\",\n message: `Successfully saved ${savedFiles.length} file(s) to ${path.dirname(savedFiles[0])}`,\n saved_files: savedFiles,\n });\n } catch (err: any) {\n return errorResult(`Failed to save test script to disk: ${err.message}`);\n }\n }\n );\n}\n\n/**\n * Write a script, and its conftest.py when given, into `destinationDir`\n * (relative to the working directory). Only the base name of `fileName` is\n * used, so a name like \"../../x.py\" cannot escape the directory.\n * Returns the absolute paths written.\n */\nexport async function saveScriptFiles(destinationDir: string, fileName: string, content: string, conftest?: string): Promise<string[]> {\n const safeFileName = path.basename(fileName);\n if (!safeFileName || safeFileName === \".\" || safeFileName === \"..\") {\n throw new Error(`Invalid file name: \"${fileName}\"`);\n }\n const targetDir = path.resolve(process.cwd(), destinationDir);\n await fs.mkdir(targetDir, { recursive: true });\n\n const scriptPath = path.join(targetDir, safeFileName);\n await fs.writeFile(scriptPath, content, \"utf-8\");\n logger.info(`Saved test script to: ${scriptPath}`);\n const saved = [scriptPath];\n\n if (conftest) {\n const conftestPath = path.join(targetDir, \"conftest.py\");\n await fs.writeFile(conftestPath, conftest, \"utf-8\");\n logger.info(`Saved conftest.py to: ${conftestPath}`);\n saved.push(conftestPath);\n }\n return saved;\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { backendCall } from \"./results.js\";\n\nexport function registerEnvironmentTool(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n server.registerTool(\n \"qcentriq_get_environment\",\n {\n description:\n \"Retrieve target test environment configuration, base URL (BASE_URL), environment variables, and required secret variable names for local test execution.\",\n inputSchema: z.object({\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from API key if omitted).\"),\n environment_id: z.uuid().optional().describe(\"Optional specific environment UUID.\"),\n environment_name: z.string().optional().describe(\"Optional environment name filter (e.g. 'staging', 'dev', 'production').\"),\n }),\n },\n async (args) =>\n backendCall(\"qcentriq_get_environment\", () =>\n client.request(\"/environment\", { ...args, project_id: args.project_id || config.defaultProjectId })\n )\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { backendCall } from \"./results.js\";\n\nexport function registerRunLogsTool(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n server.registerTool(\n \"qcentriq_get_test_run_logs\",\n {\n description:\n \"Retrieve execution history and logs for a test case: per-run status, timing, error message, stack trace, and raw output logs across runs.\",\n inputSchema: z.object({\n test_case_id: z.uuid().describe(\"UUID of the target test case.\"),\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from API key if omitted).\"),\n run_id: z.uuid().optional().describe(\"Optional specific run UUID to fetch a single run's full log.\"),\n status: z.enum([\"failed\", \"passed\", \"error\"]).optional().describe(\"Filter by result status.\"),\n latest_only: z.boolean().default(false).describe(\"If True, returns only the most recent matching run.\"),\n from_date: z.string().optional().describe(\"Optional ISO-8601 start date filter.\"),\n to_date: z.string().optional().describe(\"Optional ISO-8601 end date filter.\"),\n limit: z.number().int().min(1).max(100).default(20).describe(\"Max runs to return.\"),\n offset: z.number().int().min(0).default(0).describe(\"Pagination offset.\"),\n }),\n },\n async ({ test_case_id, ...query }) =>\n backendCall(\"qcentriq_get_test_run_logs\", () =>\n client.request(`/tests/${test_case_id}/run-logs`, { ...query, project_id: query.project_id || config.defaultProjectId })\n )\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\n\nexport function registerAuthoringGuideTool(server: McpServer, client: QCentriqApiClient): void {\n server.registerTool(\n \"qcentriq_get_authoring_guide\",\n {\n description:\n \"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 — 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.\",\n inputSchema: z.object({}),\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n },\n async () => {\n try {\n const guide = await client.request(\"/authoring-guide\");\n return {\n content: [{ type: \"text\", text: JSON.stringify(guide, null, 2) }],\n };\n } catch (err: any) {\n // Deliberately an error rather than a partial contract: an agent that\n // writes against an empty schema produces plans the backend rejects.\n return {\n isError: true,\n content: [{ type: \"text\", text: `Error fetching the authoring guide: ${err.message}` }],\n };\n }\n }\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { backendCall } from \"./results.js\";\n\nexport function registerCreatePlanTool(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n server.registerTool(\n \"qcentriq_create_plan\",\n {\n description:\n \"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.\",\n inputSchema: z.object({\n plan: z.record(z.string(), z.any()).describe(\"The plan object, matching the TaskPlan schema from qcentriq_get_authoring_guide.\"),\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from the API key if omitted).\"),\n }),\n annotations: {\n readOnlyHint: false,\n destructiveHint: false, // Creates new groups and cases; never modifies existing ones.\n idempotentHint: false, // Calling twice creates two plans.\n openWorldHint: false,\n },\n },\n async (args) =>\n backendCall(\"qcentriq_create_plan\", () =>\n client.send(\"POST\", \"/plans\", { plan: args.plan, project_id: args.project_id || config.defaultProjectId })\n )\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { backendCall, errorResult } from \"./results.js\";\nimport { PassingRunLedger, fixtureMismatch } from \"../local/passing-runs.js\";\nimport { detectPackageManagers, installUvNotice } from \"../local/environment-setup.js\";\n\nexport function registerSaveGroupScriptTool(\n server: McpServer,\n client: QCentriqApiClient,\n config: QCentriqConfig,\n passingRuns: PassingRunLedger\n): void {\n server.registerTool(\n \"qcentriq_save_group_script\",\n {\n description:\n \"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>') — no duplicates, no ids from other groups. A rejection names the offending id or line so you can correct it. Pass expected_updated_at from the last download to turn a concurrent edit into a conflict rather than a lost update. conftest.py cannot be saved; QCentriq provides it. Requires the 'test:write' scope.\",\n inputSchema: z.object({\n group_id: z.uuid().describe(\"UUID of the target test group.\"),\n content: z.string().describe(\"The Python test script source.\"),\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from the API key if omitted).\"),\n filename: z.string().optional().describe(\"Optional script filename; derived from the group title if omitted.\"),\n fixtures: z\n .array(z.object({ file_name: z.string(), content: z.string() }))\n .optional()\n .describe(\"Companion files to store next to the script (page objects, test data). conftest.py is rejected.\"),\n expected_updated_at: z\n .string()\n .optional()\n .describe(\"ISO-8601 timestamp from the last download. Supply it to get a conflict instead of silently overwriting someone else's edit.\"),\n }),\n annotations: {\n readOnlyHint: false,\n destructiveHint: true, // Replaces the group's existing script.\n idempotentHint: true, // Saving the same content twice leaves the same state.\n openWorldHint: false,\n },\n },\n async (args) => {\n const untested = await untestedReason(passingRuns, args);\n if (untested) return errorResult(untested);\n\n const { group_id, ...body } = args;\n return backendCall(\"qcentriq_save_group_script\", () =>\n client.send(\"PUT\", `/groups/${group_id}/script`, { ...body, project_id: body.project_id || config.defaultProjectId })\n );\n }\n );\n}\n\n/** Why this upload has not been proven locally, or null when it has. */\nasync function untestedReason(\n passingRuns: PassingRunLedger,\n args: { content: string; fixtures?: Array<{ file_name: string; content: string }> }\n): Promise<string | null> {\n const run = passingRuns.find(args.content);\n if (!run) {\n const reason =\n \"Upload refused: this script has not passed a local run, so nothing was sent to QCentriq. \" +\n \"Save it to disk, run it with qcentriq_run_local_test on the whole file until it passes, then call this tool again with exactly that content.\";\n const notice = installUvNotice(await detectPackageManagers());\n return notice ? `${reason}\\n\\n${notice}` : reason;\n }\n const mismatch = await fixtureMismatch(run, args.fixtures ?? []);\n if (mismatch) {\n return `Upload refused: ${mismatch}, so nothing was sent to QCentriq. Re-run ${run.filePath} with qcentriq_run_local_test and upload the files exactly as they were when it passed.`;\n }\n return null;\n}\n","import { createHash } from \"node:crypto\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nexport interface PassingRun {\n /** Absolute path of the script that passed. */\n filePath: string;\n /** Directory the script ran from; its companion files are looked up here. */\n dir: string;\n /** When the run started (epoch ms). A companion file modified later is not what ran. */\n startedAt: number;\n}\n\n/**\n * Scripts that passed a whole-file local run in this server process, keyed by\n * a hash of their exact content.\n *\n * This is what lets qcentriq_save_group_script upload only what was proven to\n * work locally: the agent passes content, not a path, so the content itself\n * has to be matched to a run. Kept in memory on purpose; after a restart the\n * script simply has to be run again.\n */\nexport class PassingRunLedger {\n private readonly runs = new Map<string, PassingRun>();\n\n record(content: string, run: PassingRun): void {\n this.runs.set(contentHash(content), run);\n }\n\n find(content: string): PassingRun | undefined {\n return this.runs.get(contentHash(content));\n }\n}\n\nfunction contentHash(content: string): string {\n return createHash(\"sha256\").update(content).digest(\"hex\");\n}\n\n/** pytest flags that run only part of a file, or none of it. */\nconst NARROWING_FLAGS = [\"-k\", \"-m\", \"--deselect\", \"--lf\", \"--last-failed\", \"--sw\", \"--stepwise\", \"--co\", \"--collect-only\", \"--setup-only\", \"--setup-plan\", \"--fixtures\"];\n\n/**\n * Whether a pass under these arguments says anything about the whole script.\n * A run filtered to some tests leaves the others unproven.\n */\nexport function coversWholeFile(filePath: string, testName?: string, extraArgs: string[] = []): boolean {\n if (testName || filePath.includes(\"::\")) return false;\n return !extraArgs.some((arg) =>\n NARROWING_FLAGS.some((flag) => arg === flag || arg.startsWith(`${flag}=`) || (/^-[a-z]$/.test(flag) && arg.startsWith(flag)))\n );\n}\n\n/** pytest exits 0 when every test is skipped; a pass needs at least one test that actually passed. */\nexport function reportsPassedTests(stdout: string): boolean {\n return /\\b[1-9]\\d* passed\\b/.test(stdout);\n}\n\n/**\n * Check that each companion file is the one that sat next to the script when\n * it passed: present, byte-identical, and not modified since the run began.\n * Returns why a file fails, or null when they all match.\n */\nexport async function fixtureMismatch(run: PassingRun, fixtures: Array<{ file_name: string; content: string }>): Promise<string | null> {\n for (const fixture of fixtures) {\n const localPath = path.resolve(run.dir, fixture.file_name);\n if (path.dirname(localPath) !== run.dir) {\n return `companion file \"${fixture.file_name}\" is not a plain file name next to the script`;\n }\n let local: string;\n let modifiedAt: number;\n try {\n [local, modifiedAt] = await Promise.all([fs.readFile(localPath, \"utf-8\"), fs.stat(localPath).then((s) => s.mtimeMs)]);\n } catch {\n return `companion file \"${fixture.file_name}\" was not next to the script (${run.dir}) when it passed`;\n }\n if (local !== fixture.content) {\n return `companion file \"${fixture.file_name}\" differs from ${localPath}, which the passing run used`;\n }\n if (modifiedAt > run.startedAt) {\n return `companion file \"${fixture.file_name}\" changed after the passing run`;\n }\n }\n return null;\n}\n","import { spawn } from \"node:child_process\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { logger } from \"../utils/logger.js\";\n\nexport type PackageManagerName = \"uv\" | \"poetry\" | \"conda\" | \"venv\";\n\nexport interface PackageManagerStatus {\n name: PackageManagerName;\n available: boolean;\n version?: string;\n probe_command: string;\n}\n\nexport interface SetupStep {\n description: string;\n command: string;\n}\n\nexport interface EnvironmentSetupParams {\n preferredManager?: PackageManagerName;\n workingDir?: string;\n envName?: string;\n pythonVersion?: string;\n playwrightVersion?: string;\n /** Package list from the backend. Omitted falls back to FALLBACK_TEST_PACKAGES. */\n packages?: readonly string[];\n}\n\nexport interface EnvironmentSetupPlan {\n working_dir: string;\n package_managers: PackageManagerStatus[];\n recommended_manager: PackageManagerName;\n active_environment: string | null;\n detected_project_files: string[];\n steps: SetupStep[];\n verify_command: string;\n notes: string[];\n}\n\n/**\n * Ordered by preference: uv first (fastest, and the standard for QCentriq test execution\n * containers), then poetry and conda, with the stdlib venv module as the universal fallback.\n */\nconst MANAGER_PRIORITY: PackageManagerName[] = [\"uv\", \"poetry\", \"conda\", \"venv\"];\n\nconst PROBE_TIMEOUT_MS = 5000;\n\n/** Default Python version for the QCentriq test environment (matches the execution container). */\nconst DEFAULT_PYTHON_VERSION = \"3.12\";\n\n/** Default Playwright version pin (matches issues-dev/Dockerfile.execution). */\nconst DEFAULT_PLAYWRIGHT_VERSION = \"1.56.0\";\n\n/**\n * Offline copy of the execution container's package list.\n *\n * The authoritative list is served by the backend at\n * /api/v1/mcp-client/runtime-requirements, which reads the same\n * execution-requirements.txt that Dockerfile.execution installs from. This copy\n * exists only so setup instructions still work without a reachable backend, and\n * a test asserts the two stay identical.\n *\n * playwright is absent on purpose: its version is pinned per execution image.\n */\nexport const FALLBACK_TEST_PACKAGES: readonly string[] = [\n \"pytest\",\n \"pytest-playwright\",\n \"allure-pytest\",\n \"httpx\",\n \"nest-asyncio\",\n \"pytest-playwright-visual-snapshot\",\n \"Pillow\",\n];\n\n/** Build the exact dependency set QCentriq Playwright test scripts need to run locally. */\nexport function testDependencies(playwrightVersion: string, packages?: readonly string[]): string {\n const base = packages && packages.length > 0 ? packages : FALLBACK_TEST_PACKAGES;\n return [...base, `playwright==${playwrightVersion}`].join(\" \");\n}\n\ninterface ProjectContext {\n workingDir: string;\n isWindows: boolean;\n envName: string;\n pythonVersion: string;\n playwrightVersion: string;\n /** Package list reported by the backend; falls back to FALLBACK_TEST_PACKAGES. */\n packages?: readonly string[];\n projectFiles: string[];\n}\n\n/**\n * Run `<cmd> --version` style probes without letting a hung binary stall the tool.\n * Commands are hardcoded constants, so the Windows `shell` hop (needed for .cmd/.bat\n * shims like poetry and conda) carries no injection risk.\n */\nfunction probeCommand(cmd: string, args: string[]): Promise<string | null> {\n return new Promise((resolve) => {\n let output = \"\";\n let settled = false;\n\n const finish = (value: string | null) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve(value);\n };\n\n let child;\n try {\n child = spawn(cmd, args, {\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n shell: process.platform === \"win32\",\n });\n } catch {\n resolve(null);\n return;\n }\n\n const timer = setTimeout(() => {\n try {\n child.kill(\"SIGKILL\");\n } catch {\n // Process already exited\n }\n finish(null);\n }, PROBE_TIMEOUT_MS);\n\n // Some tools (older conda, python) report their version on stderr\n child.stdout?.on(\"data\", (chunk) => (output += chunk.toString()));\n child.stderr?.on(\"data\", (chunk) => (output += chunk.toString()));\n child.on(\"error\", () => finish(null));\n child.on(\"close\", (code) => finish(code === 0 ? output.trim().split(\"\\n\")[0].trim() || \"unknown\" : null));\n });\n}\n\n/**\n * Locate a usable Python interpreter that can also create virtualenvs.\n * On Debian-family systems `venv` is packaged separately, so importing it is part of the probe.\n */\nasync function probePython(): Promise<{ bin: string; version: string } | null> {\n for (const bin of [\"python3\", \"python\"]) {\n const version = await probeCommand(bin, [\"-c\", \"import venv, sys; print(sys.version.split()[0])\"]);\n if (version) {\n return { bin, version };\n }\n }\n return null;\n}\n\nasync function fileExists(filePath: string): Promise<boolean> {\n try {\n await fs.access(filePath);\n return true;\n } catch {\n return false;\n }\n}\n\nasync function detectProjectFiles(workingDir: string): Promise<string[]> {\n const candidates = [\n \"pyproject.toml\",\n \"uv.lock\",\n \"poetry.lock\",\n \"requirements.txt\",\n \"environment.yml\",\n \"environment.yaml\",\n ];\n const found: string[] = [];\n for (const candidate of candidates) {\n if (await fileExists(path.join(workingDir, candidate))) {\n found.push(candidate);\n }\n }\n return found;\n}\n\n/** Detect which Python package managers are installed on the developer's machine. */\nexport async function detectPackageManagers(): Promise<PackageManagerStatus[]> {\n const [uv, poetry, conda, python] = await Promise.all([\n probeCommand(\"uv\", [\"--version\"]),\n probeCommand(\"poetry\", [\"--version\"]),\n probeCommand(\"conda\", [\"--version\"]),\n probePython(),\n ]);\n\n return [\n { name: \"uv\", available: Boolean(uv), version: uv ?? undefined, probe_command: \"uv --version\" },\n { name: \"poetry\", available: Boolean(poetry), version: poetry ?? undefined, probe_command: \"poetry --version\" },\n { name: \"conda\", available: Boolean(conda), version: conda ?? undefined, probe_command: \"conda --version\" },\n {\n name: \"venv\",\n available: Boolean(python),\n version: python ? `${python.bin} ${python.version}` : undefined,\n probe_command: \"python3 -m venv\",\n },\n ];\n}\n\nfunction activateCommand(ctx: ProjectContext): string {\n return ctx.isWindows ? \".venv\\\\Scripts\\\\activate\" : \"source .venv/bin/activate\";\n}\n\nfunction buildUvSteps(ctx: ProjectContext): SetupStep[] {\n const deps = testDependencies(ctx.playwrightVersion, ctx.packages);\n\n if (ctx.projectFiles.includes(\"uv.lock\")) {\n return [\n { description: \"Install the project's locked dependencies into a uv-managed virtualenv.\", command: \"uv sync\" },\n { description: \"Add the QCentriq test dependencies if they are not already in pyproject.toml.\", command: `uv add --dev ${deps}` },\n { description: \"Download the Playwright browser binaries.\", command: \"uv run playwright install chromium\" },\n ];\n }\n\n const steps: SetupStep[] = [\n { description: \"Create a virtual environment in .venv.\", command: `uv venv .venv --python ${ctx.pythonVersion}` },\n { description: \"Activate the virtual environment.\", command: activateCommand(ctx) },\n ];\n\n if (ctx.projectFiles.includes(\"requirements.txt\")) {\n steps.push({ description: \"Install the project's existing dependencies.\", command: \"uv pip install -r requirements.txt\" });\n }\n\n steps.push(\n { description: \"Install the QCentriq test dependencies (pytest, Playwright, Allure, and fixtures).\", command: `uv pip install ${deps}` },\n { description: \"Download the Playwright browser binaries.\", command: \"playwright install chromium\" }\n );\n\n return steps;\n}\n\n/** Install uv first, then the regular uv steps, for a machine with no package manager. */\nfunction buildUvBootstrapSteps(ctx: ProjectContext): SetupStep[] {\n return [\n {\n description: \"Install uv, the recommended package manager. It also downloads Python, so nothing else needs to be installed first.\",\n command: ctx.isWindows ? UV_INSTALL_COMMANDS.windows : UV_INSTALL_COMMANDS.unix,\n },\n { description: \"Open a new terminal so uv is on PATH, then confirm it is installed.\", command: \"uv --version\" },\n ...buildUvSteps(ctx),\n ];\n}\n\nfunction buildPoetrySteps(ctx: ProjectContext): SetupStep[] {\n const deps = testDependencies(ctx.playwrightVersion, ctx.packages);\n const steps: SetupStep[] = [\n {\n description: \"Keep the virtualenv inside the project so qcentriq_run_local_test can find it.\",\n command: \"poetry config virtualenvs.in-project true\",\n },\n ];\n\n if (!ctx.projectFiles.includes(\"pyproject.toml\")) {\n steps.push({\n description: \"Initialize a pyproject.toml for this test project.\",\n command: `poetry init --no-interaction --python \">=${ctx.pythonVersion}\"`,\n });\n }\n\n steps.push(\n { description: \"Add the QCentriq test dependencies (pytest, Playwright, Allure, and fixtures) as dev dependencies.\", command: `poetry add --group dev ${deps}` },\n { description: \"Install the environment.\", command: \"poetry install\" },\n { description: \"Download the Playwright browser binaries.\", command: \"poetry run playwright install chromium\" },\n { description: \"Activate the environment for your shell session.\", command: activateCommand(ctx) }\n );\n\n return steps;\n}\n\nfunction buildCondaSteps(ctx: ProjectContext): SetupStep[] {\n const deps = testDependencies(ctx.playwrightVersion, ctx.packages);\n const envFile = ctx.projectFiles.find((f) => f === \"environment.yml\" || f === \"environment.yaml\");\n\n const steps: SetupStep[] = envFile\n ? [{ description: \"Create the conda environment from the project's environment file.\", command: `conda env create -f ${envFile}` }]\n : [\n {\n description: \"Create a dedicated conda environment for QCentriq tests.\",\n command: `conda create -n ${ctx.envName} python=${ctx.pythonVersion} -y`,\n },\n ];\n\n steps.push(\n { description: \"Activate the conda environment.\", command: `conda activate ${ctx.envName}` },\n { description: \"Install the QCentriq test dependencies (pytest, Playwright, Allure, and fixtures).\", command: `pip install ${deps}` },\n { description: \"Download the Playwright browser binaries.\", command: \"playwright install chromium\" }\n );\n\n return steps;\n}\n\nfunction buildVenvSteps(ctx: ProjectContext): SetupStep[] {\n const deps = testDependencies(ctx.playwrightVersion, ctx.packages);\n const steps: SetupStep[] = [\n { description: \"Create a virtual environment in .venv.\", command: \"python3 -m venv .venv\" },\n { description: \"Activate the virtual environment.\", command: activateCommand(ctx) },\n { description: \"Upgrade pip inside the environment.\", command: \"python -m pip install --upgrade pip\" },\n ];\n\n if (ctx.projectFiles.includes(\"requirements.txt\")) {\n steps.push({ description: \"Install the project's existing dependencies.\", command: \"pip install -r requirements.txt\" });\n }\n\n steps.push(\n { description: \"Install the QCentriq test dependencies (pytest, Playwright, Allure, and fixtures).\", command: `pip install ${deps}` },\n { description: \"Download the Playwright browser binaries.\", command: \"playwright install chromium\" }\n );\n\n return steps;\n}\n\nconst STEP_BUILDERS: Record<PackageManagerName, (ctx: ProjectContext) => SetupStep[]> = {\n uv: buildUvSteps,\n poetry: buildPoetrySteps,\n conda: buildCondaSteps,\n venv: buildVenvSteps,\n};\n\nconst VERIFY_COMMANDS: Record<PackageManagerName, string> = {\n uv: \"pytest --version\",\n poetry: \"poetry run pytest --version\",\n conda: \"pytest --version\",\n venv: \"pytest --version\",\n};\n\n/**\n * Astral's official uv installers. Used when no package manager is on PATH at all:\n * uv needs no pre-existing Python (`uv venv --python` downloads one), so it is the\n * only option that bootstraps from nothing.\n */\nconst UV_INSTALL_COMMANDS = {\n unix: \"curl -LsSf https://astral.sh/uv/install.sh | sh\",\n windows: 'powershell -ExecutionPolicy ByPass -c \"irm https://astral.sh/uv/install.ps1 | iex\"',\n};\n\nconst INSTALL_HINTS: Record<PackageManagerName, string> = {\n uv: \"uv: https://docs.astral.sh/uv/getting-started/installation/\",\n poetry: \"poetry: https://python-poetry.org/docs/#installation\",\n conda: \"conda (miniconda): https://docs.conda.io/projects/miniconda/en/latest/\",\n venv: \"python3 with the venv module: https://www.python.org/downloads/\",\n};\n\n/**\n * What to tell the user when no package manager is installed, or null when one is.\n * Tests cannot run locally without one, so uv, which bootstraps from nothing,\n * has to be installed before anything else.\n */\nexport function installUvNotice(managers: PackageManagerStatus[]): string | null {\n if (managers.some((m) => m.available)) return null;\n const command = process.platform === \"win32\" ? UV_INSTALL_COMMANDS.windows : UV_INSTALL_COMMANDS.unix;\n return (\n \"No Python package manager (uv, poetry, conda or python3 with venv) was found on this machine. \" +\n `Ask the user to install uv first, the recommended option: \\`${command}\\` (see https://docs.astral.sh/uv/getting-started/installation/). ` +\n \"Then call qcentriq_get_setup_instructions for the commands that create the test environment, and restart the MCP client from that environment.\"\n );\n}\n\nfunction detectActiveEnvironment(): string | null {\n if (process.env.VIRTUAL_ENV) {\n return `virtualenv: ${process.env.VIRTUAL_ENV}`;\n }\n if (process.env.CONDA_DEFAULT_ENV) {\n return `conda: ${process.env.CONDA_DEFAULT_ENV}`;\n }\n return null;\n}\n\n/**\n * Detect the developer's available Python tooling and return the commands they should run\n * to create an environment capable of executing QCentriq Playwright tests locally.\n * This only inspects the machine and returns instructions; it never creates the environment.\n */\nexport async function buildEnvironmentSetupPlan(params: EnvironmentSetupParams = {}): Promise<EnvironmentSetupPlan> {\n const workingDir = params.workingDir ? path.resolve(params.workingDir) : process.cwd();\n\n const [packageManagers, projectFiles] = await Promise.all([detectPackageManagers(), detectProjectFiles(workingDir)]);\n\n const availability = new Map(packageManagers.map((m) => [m.name, m.available]));\n const preferred = params.preferredManager;\n const notes: string[] = [];\n\n let installed: PackageManagerName | undefined;\n if (preferred && availability.get(preferred)) {\n installed = preferred;\n } else {\n if (preferred) {\n notes.push(`Requested package manager \"${preferred}\" was not found on PATH; falling back to the best available option.`);\n }\n installed = MANAGER_PRIORITY.find((name) => availability.get(name));\n }\n // With nothing installed, uv is still the recommendation: the steps install it first.\n const recommended: PackageManagerName = installed ?? \"uv\";\n\n const ctx: ProjectContext = {\n workingDir,\n isWindows: process.platform === \"win32\",\n envName: params.envName || \"qcentriq-tests\",\n pythonVersion: params.pythonVersion || DEFAULT_PYTHON_VERSION,\n playwrightVersion: params.playwrightVersion || DEFAULT_PLAYWRIGHT_VERSION,\n packages: params.packages,\n projectFiles,\n };\n\n const activeEnvironment = detectActiveEnvironment();\n if (activeEnvironment) {\n notes.push(`An environment is already active (${activeEnvironment}). Reuse it instead of creating a new one if it already has pytest and playwright installed.`);\n }\n\n const steps = installed ? STEP_BUILDERS[installed](ctx) : buildUvBootstrapSteps(ctx);\n const verifyCommand = VERIFY_COMMANDS[recommended];\n\n if (installed) {\n if (recommended !== \"uv\" && availability.get(\"uv\")) {\n notes.push(\"uv is also available on this machine and is recommended over other package managers for faster, more reliable installs. Pass preferred_manager to override this choice.\");\n }\n\n const alternatives = MANAGER_PRIORITY.filter((name) => name !== recommended && availability.get(name));\n if (alternatives.length > 0) {\n notes.push(`Also available on this machine: ${alternatives.join(\", \")}. Re-run this tool with preferred_manager to get instructions for one of them.`);\n }\n } else {\n notes.push(\"No supported Python package manager was found on PATH. The steps below install uv, the recommended option. To use a different tool instead, install one of the following and run this tool again:\");\n for (const name of MANAGER_PRIORITY.filter((name) => name !== \"uv\")) {\n notes.push(` - ${INSTALL_HINTS[name]}`);\n }\n }\n\n notes.push(\n \"Run these commands in a terminal from the working directory below — this tool returns instructions only and does not create the environment for you.\",\n \"qcentriq_run_local_test resolves pytest from the VIRTUAL_ENV the MCP server was launched with, then falls back to pytest on PATH. After creating a new environment, restart your MCP client (Claude Desktop, Cursor, ...) from an activated shell so local runs pick it up.\"\n );\n\n logger.debug(`Environment setup plan: recommended=${recommended}, project files=[${projectFiles.join(\", \")}]`);\n\n return {\n working_dir: workingDir,\n package_managers: packageManagers,\n recommended_manager: recommended,\n active_environment: activeEnvironment,\n detected_project_files: projectFiles,\n steps,\n verify_command: verifyCommand,\n notes,\n };\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { runLocalPytest, LocalTestRunResult } from \"../local/runner.js\";\nimport { PassingRunLedger, coversWholeFile, reportsPassedTests } from \"../local/passing-runs.js\";\nimport { detectPackageManagers, installUvNotice } from \"../local/environment-setup.js\";\n\nexport function registerLocalRunTool(server: McpServer, passingRuns: PassingRunLedger): void {\n server.registerTool(\n \"qcentriq_run_local_test\",\n {\n description:\n \"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.\",\n inputSchema: z.object({\n file_path: z.string().describe(\"Path to the local test file to run (e.g. 'tests/test_login.py').\"),\n test_name: z.string().optional().describe(\"Optional specific test function name or expression to run (passed to pytest -k).\"),\n headless: z.boolean().default(true).describe(\"Whether to run the browser in headless mode (default True). Set False to watch the browser execution live.\"),\n browser: z.enum([\"chromium\", \"firefox\", \"webkit\"]).default(\"chromium\").describe(\"Browser engine to execute against (default 'chromium').\"),\n base_url: z.url().optional().describe(\"Target application base URL (e.g. from qcentriq_get_environment). Injected as BASE_URL env var.\"),\n group_id: z.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.\"),\n env_vars: z.record(z.string(), z.string()).optional().describe(\"Environment variables to inject into the local test process.\"),\n extra_args: z.array(z.string()).optional().describe(\"Additional CLI arguments to pass to pytest (e.g. ['-s', '--alluredir=allure-results']).\"),\n timeout_seconds: z.number().int().min(5).max(300).default(60).describe(\"Timeout in seconds for test execution (default 60).\"),\n working_dir: z.string().optional().describe(\"Working directory to run pytest in (defaults to current project directory).\"),\n }),\n },\n async (args) => {\n try {\n const scriptPath = path.resolve(args.working_dir ?? process.cwd(), args.file_path.split(\"::\")[0]);\n // Read before running, so what gets recorded is what pytest was given.\n const content = await fs.readFile(scriptPath, \"utf-8\").catch(() => null);\n const startedAt = Date.now();\n\n const result = await runLocalPytest({\n filePath: args.file_path,\n testName: args.test_name,\n headless: args.headless,\n browser: args.browser,\n baseUrl: args.base_url,\n groupId: args.group_id,\n envVars: args.env_vars,\n extraArgs: args.extra_args,\n timeoutSeconds: args.timeout_seconds,\n workingDir: args.working_dir,\n });\n\n const statusText = result.passed ? \"PASSED\" : \"FAILED\";\n const summary = [\n `Local Test Run Result: ${statusText} (exit code ${result.exitCode})`,\n `Duration: ${(result.durationMs / 1000).toFixed(2)}s`,\n `Command: ${result.command}`,\n \"\",\n \"--- STDOUT ---\",\n result.stdout || \"(no stdout)\",\n \"\",\n \"--- STDERR ---\",\n result.stderr || \"(no stderr)\",\n ];\n\n const next = await nextStep(result, args, content !== null);\n if (next.uploadable && content !== null) {\n passingRuns.record(content, { filePath: scriptPath, dir: path.dirname(scriptPath), startedAt });\n }\n if (next.text) summary.push(\"\", next.text);\n\n return {\n content: [\n {\n type: \"text\",\n text: summary.join(\"\\n\"),\n },\n ],\n isError: !result.passed,\n };\n } catch (err: any) {\n return {\n isError: true,\n content: [\n {\n type: \"text\",\n text: `Error executing local test: ${err.message}`,\n },\n ],\n };\n }\n }\n );\n}\n\n/** Whether this run qualifies the script for upload, and what to tell the agent about it. */\nasync function nextStep(\n result: LocalTestRunResult,\n args: { file_path: string; test_name?: string; extra_args?: string[] },\n scriptReadable: boolean\n): Promise<{ uploadable: boolean; text?: string }> {\n if (result.pytestMissing) {\n const notice = installUvNotice(await detectPackageManagers());\n return {\n uploadable: false,\n text: notice ?? \"pytest is not installed in the Python environment the MCP server runs with. Call qcentriq_get_setup_instructions for the commands that set one up.\",\n };\n }\n if (!result.passed) return { uploadable: false };\n if (!coversWholeFile(args.file_path, args.test_name, args.extra_args)) {\n return { uploadable: false, text: \"Only part of the script ran. Run the whole file, without test_name or test filters, before uploading it with qcentriq_save_group_script.\" };\n }\n if (!scriptReadable) {\n return { uploadable: false, text: \"file_path is not a readable script file, so this pass cannot qualify an upload. Run the single script file you intend to upload.\" };\n }\n if (!reportsPassedTests(result.stdout)) {\n return { uploadable: false, text: \"No test actually passed (all skipped or none collected), so this script cannot be uploaded yet.\" };\n }\n return { uploadable: true, text: \"This exact script passed locally and can now be uploaded with qcentriq_save_group_script.\" };\n}\n","import { spawn, ChildProcess } from \"node:child_process\";\nimport * as path from \"node:path\";\nimport { logger } from \"../utils/logger.js\";\n\nexport interface LocalTestRunParams {\n filePath: string;\n testName?: string;\n headless?: boolean;\n browser?: \"chromium\" | \"firefox\" | \"webkit\";\n baseUrl?: string;\n groupId?: string;\n envVars?: Record<string, string>;\n extraArgs?: string[];\n timeoutSeconds?: number;\n workingDir?: string;\n}\n\n/**\n * Build the environment pytest runs under.\n *\n * Each variable here has a reader on the Python side: BASE_URL and BROWSER are\n * consumed by the test script, while HEADLESS and QCAQ_TEST_GROUP_ID are read by\n * the QCentriq conftest. Leaving a variable unset is meaningful -- the conftest\n * falls back to the execution container's defaults.\n */\nexport function buildTestEnv(params: LocalTestRunParams): NodeJS.ProcessEnv {\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n ...(params.envVars || {}),\n };\n\n if (params.baseUrl) {\n env.BASE_URL = params.baseUrl;\n }\n if (params.browser) {\n env.BROWSER = params.browser;\n }\n if (params.headless !== undefined) {\n env.HEADLESS = params.headless ? \"true\" : \"false\";\n }\n if (params.groupId) {\n env.QCAQ_TEST_GROUP_ID = params.groupId;\n }\n\n return env;\n}\n\nexport interface LocalTestRunResult {\n passed: boolean;\n exitCode: number;\n stdout: string;\n stderr: string;\n durationMs: number;\n command: string;\n /** pytest could not be started: no Python interpreter, or pytest not installed in it. */\n pytestMissing: boolean;\n}\n\n/**\n * The pytest to launch: the active virtualenv's, else whatever is on PATH.\n */\nexport function resolvePytestCommand(): string {\n const venv = process.env.VIRTUAL_ENV;\n if (!venv) return \"pytest\";\n return process.platform === \"win32\" ? path.join(venv, \"Scripts\", \"pytest.exe\") : path.join(venv, \"bin\", \"pytest\");\n}\n\nfunction killProcessTree(child: ChildProcess): void {\n if (child.pid && process.platform !== \"win32\") {\n try {\n process.kill(-child.pid, \"SIGKILL\");\n return;\n } catch {\n // Process group kill may fail if group leader already died, fall back to killing child directly\n }\n }\n try {\n child.kill(\"SIGKILL\");\n } catch {\n // Process already terminated\n }\n}\n\ntype Attempt =\n | { launched: true; exitCode: number; stdout: string; stderr: string; timedOut: boolean }\n | { launched: false; error: NodeJS.ErrnoException };\n\n/** Run one command to completion or timeout, collecting its output. */\nfunction attempt(cmd: string, args: string[], cwd: string, env: NodeJS.ProcessEnv, timeoutMs: number): Promise<Attempt> {\n return new Promise((resolve) => {\n let stdout = \"\";\n let stderr = \"\";\n let settled = false;\n const settle = (result: Attempt) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve(result);\n };\n\n // Detached on POSIX so the child leads a process group, which a timeout kills as a whole\n const child = spawn(cmd, args, {\n cwd,\n env,\n detached: process.platform !== \"win32\",\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n\n const timer = setTimeout(() => {\n killProcessTree(child);\n settle({ launched: true, exitCode: -1, stdout, stderr, timedOut: true });\n }, timeoutMs);\n\n child.stdout?.on(\"data\", (chunk) => (stdout += chunk.toString()));\n child.stderr?.on(\"data\", (chunk) => (stderr += chunk.toString()));\n child.on(\"error\", (error) => settle({ launched: false, error }));\n child.on(\"close\", (code) => settle({ launched: true, exitCode: code ?? -1, stdout, stderr, timedOut: false }));\n });\n}\n\n/**\n * Execute pytest locally in the user's environment.\n */\nexport async function runLocalPytest(params: LocalTestRunParams): Promise<LocalTestRunResult> {\n const startTime = Date.now();\n const cwd = params.workingDir ? path.resolve(params.workingDir) : process.cwd();\n const timeoutSeconds = params.timeoutSeconds || 60;\n\n const args = [params.filePath];\n if (params.testName) {\n args.push(\"-k\", params.testName);\n }\n if (params.extraArgs) {\n args.push(...params.extraArgs);\n }\n // Always use verbose flag if not present\n if (!args.includes(\"-v\") && !args.includes(\"-vv\")) {\n args.push(\"-v\");\n }\n\n const env = buildTestEnv(params);\n const failure = (stderr: string, command: string, pytestMissing: boolean): LocalTestRunResult => ({\n passed: false,\n exitCode: -1,\n stdout: \"\",\n stderr,\n durationMs: Date.now() - startTime,\n command,\n pytestMissing,\n });\n\n let cmd = resolvePytestCommand();\n let cmdArgs = args;\n logger.info(`Running local test command: ${cmd} ${cmdArgs.join(\" \")} in ${cwd}`);\n let outcome = await attempt(cmd, cmdArgs, cwd, env, timeoutSeconds * 1000);\n\n if (!outcome.launched) {\n if (outcome.error.code !== \"ENOENT\") {\n return failure(`Failed to spawn process: ${outcome.error.message}. Ensure pytest is installed in your Python environment.`, `${cmd} ${cmdArgs.join(\" \")}`, false);\n }\n logger.warn(\"pytest binary not found directly, falling back to python3 -m pytest...\");\n const primary = `${cmd} ${cmdArgs.join(\" \")}`;\n cmd = \"python3\";\n cmdArgs = [\"-m\", \"pytest\", ...args];\n outcome = await attempt(cmd, cmdArgs, cwd, env, timeoutSeconds * 1000);\n if (!outcome.launched) {\n return failure(`Failed to execute pytest or python3 -m pytest: ${outcome.error.message}. Ensure pytest is installed in your Python environment.`, primary, true);\n }\n }\n\n return {\n passed: !outcome.timedOut && outcome.exitCode === 0,\n exitCode: outcome.exitCode,\n stdout: outcome.stdout,\n stderr: outcome.timedOut ? `${outcome.stderr}\\n[TIMEOUT] Test execution timed out after ${timeoutSeconds} seconds.` : outcome.stderr,\n durationMs: Date.now() - startTime,\n command: `${cmd} ${cmdArgs.join(\" \")}`,\n pytestMissing: /No module named pytest/.test(outcome.stderr),\n };\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { buildEnvironmentSetupPlan } from \"../local/environment-setup.js\";\nimport { logger } from \"../utils/logger.js\";\n\n/** Minimal shape of the backend client, so tests can supply a stub. */\ninterface RuntimeRequirementsSource {\n request(path: string, params?: Record<string, any>): Promise<any>;\n}\n\ninterface RuntimeRequirements {\n packages?: string[];\n playwright_version?: string;\n}\n\n/**\n * Ask the backend which packages the execution container installs.\n *\n * Setup instructions are still useful offline, so a failure here is downgraded\n * to the bundled fallback list rather than failing the tool.\n */\nasync function fetchRuntimeRequirements(\n client: RuntimeRequirementsSource | undefined\n): Promise<RuntimeRequirements> {\n if (!client) return {};\n try {\n const res = await client.request(\"/runtime-requirements\");\n return {\n packages: Array.isArray(res?.packages) ? res.packages : undefined,\n playwright_version: typeof res?.playwright_version === \"string\" ? res.playwright_version : undefined,\n };\n } catch (err: any) {\n logger.warn(`Could not fetch runtime requirements from the backend, using the bundled list: ${err.message}`);\n return {};\n }\n}\n\nexport function registerSetupInstructionsTool(server: McpServer, client?: RuntimeRequirementsSource): void {\n server.registerTool(\n \"qcentriq_get_setup_instructions\",\n {\n description:\n \"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 — it does not create the environment.\",\n inputSchema: z.object({\n preferred_manager: z\n .enum([\"uv\", \"poetry\", \"conda\", \"venv\"])\n .optional()\n .describe(\"Force instructions for a specific package manager. Falls back to the best available one if it is not installed.\"),\n working_dir: z.string().optional().describe(\"Directory to inspect for pyproject.toml / lockfiles / requirements.txt (defaults to the current project directory).\"),\n env_name: z.string().default(\"qcentriq-tests\").describe(\"Name for the created environment (used by conda, default 'qcentriq-tests').\"),\n python_version: z.string().default(\"3.12\").describe(\"Python version to request when creating the environment (default '3.12', matching the QCentriq execution container).\"),\n playwright_version: z.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.\"),\n }),\n annotations: {\n readOnlyHint: true, // Only probes local package managers and project files; never mutates local or remote state.\n destructiveHint: false,\n idempotentHint: false, // Machine state (installed tooling) can change between calls.\n openWorldHint: false, // Fixed set of local package managers, not open-ended.\n },\n },\n async (args) => {\n try {\n const runtime = await fetchRuntimeRequirements(client);\n\n const plan = await buildEnvironmentSetupPlan({\n preferredManager: args.preferred_manager,\n workingDir: args.working_dir,\n envName: args.env_name,\n pythonVersion: args.python_version,\n // An explicitly requested pin wins; otherwise use whatever the\n // project's active execution image is built against.\n playwrightVersion: args.playwright_version ?? runtime.playwright_version,\n packages: runtime.packages,\n });\n\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(plan, null, 2),\n },\n ],\n };\n } catch (err: any) {\n return {\n isError: true,\n content: [\n {\n type: \"text\",\n text: `Error in qcentriq_get_setup_instructions: ${err.message}`,\n },\n ],\n };\n }\n }\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { registerListTestsTool } from \"./list-tests.js\";\nimport { registerGetTestTool } from \"./get-test.js\";\nimport { registerGetTestGroupsTool } from \"./get-groups.js\";\nimport { registerDownloadScriptTool } from \"./download-script.js\";\nimport { registerEnvironmentTool } from \"./environment.js\";\nimport { registerRunLogsTool } from \"./run-logs.js\";\nimport { registerAuthoringGuideTool } from \"./authoring-guide.js\";\nimport { registerCreatePlanTool } from \"./create-plan.js\";\nimport { registerSaveGroupScriptTool } from \"./save-group-script.js\";\nimport { registerLocalRunTool } from \"./local-run.js\";\nimport { registerSaveScriptTool } from \"./save-script.js\";\nimport { registerSetupInstructionsTool } from \"./setup-instructions.js\";\nimport { PassingRunLedger } from \"../local/passing-runs.js\";\nimport { logger } from \"../utils/logger.js\";\n\nexport function registerAllTools(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n logger.debug(\"Registering QCentriq MCP tools...\");\n\n // Shared by the local runner, which records scripts that pass, and the\n // script upload, which refuses anything that has not.\n const passingRuns = new PassingRunLedger();\n\n // Remote discovery and diagnostics tools (proxying to backend /api/v1/mcp-client)\n registerListTestsTool(server, client, config);\n registerGetTestTool(server, client, config);\n registerGetTestGroupsTool(server, client, config);\n registerDownloadScriptTool(server, client, config);\n registerEnvironmentTool(server, client, config);\n registerRunLogsTool(server, client, config);\n registerAuthoringGuideTool(server, client);\n\n // Authoring tools. The backend rejects these unless the API key carries\n // 'test:write', which the coarse 'mcp' scope does not grant.\n registerCreatePlanTool(server, client, config);\n registerSaveGroupScriptTool(server, client, config, passingRuns);\n\n // Client-focused local execution tools (run strictly in developer environment)\n registerSaveScriptTool(server);\n registerLocalRunTool(server, passingRuns);\n registerSetupInstructionsTool(server, client);\n\n logger.info(\"Registered QCentriq MCP tools.\");\n}\n\n","import { createRequire } from \"node:module\";\n\n/**\n * The package version, read from package.json at runtime.\n *\n * Both src/ and the bundled dist/ sit one level below the package root, so the\n * same relative path resolves in development and in the published package.\n */\nexport const PACKAGE_VERSION: string = createRequire(import.meta.url)(\"../package.json\").version;\n"],"mappings":";;;AAAA,SAAS,kBAAkB;;;ACA3B,SAAS,eAAe;;;ACQxB,IAAI,iBAAiB,QAAQ,QAAQ,IAAI,SAAS,QAAQ,IAAI,cAAc;AAErE,SAAS,gBAAgB,SAAwB;AACtD,mBAAiB;AACnB;AAEA,SAAS,cAAc,OAAe,YAAoB,MAAqB;AAC7E,QAAM,aAAY,oBAAI,KAAK,GAAE,YAAY;AACzC,QAAM,QAAQ,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI,CAAC,MAAO,OAAO,MAAM,WAAW,KAAK,UAAU,CAAC,IAAI,OAAO,CAAC,CAAE,EAAE,KAAK,GAAG,IAA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yBAAuB,QAAQ,QAAQ,MAAM;AAC7C,8BAA4B,QAAQ,QAAQ,QAAQ,WAAW;AAG/D,yBAAuB,MAAM;AAC7B,uBAAqB,QAAQ,WAAW;AACxC,gCAA8B,QAAQ,MAAM;AAE5C,SAAO,KAAK,gCAAgC;AAC9C;;;AC7CA,SAAS,qBAAqB;AAQvB,IAAM,kBAA0B,cAAc,YAAY,GAAG,EAAE,iBAAiB,EAAE;;;AlBGlF,IAAM,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAe5B,SAAS,aAAa,QAA2B,QAAmC;AACzF,QAAM,SAAS,IAAI,UAAU,EAAE,MAAM,iBAAiB,SAAS,gBAAgB,GAAG,EAAE,cAAc,oBAAoB,CAAC;AACvH,mBAAiB,QAAQ,QAAQ,MAAM;AACvC,SAAO;AACT;;;ALxBA,SAAS,OAAa;AACpB,MAAI;AACF,UAAM,SAAS,WAAW,QAAQ,IAAI;AACtC,WAAO,KAAK,yCAAyC,OAAO,OAAO,EAAE;AAErE,UAAM,YAAY,IAAI,kBAAkB,MAAM;AAI9C,UAAM,SAAS,WAAW,MAAM,aAAa,WAAW,MAAM,CAAC;AAE/D,UAAM,UAAU,YAAY;AAC1B,aAAO,KAAK,sCAAsC;AAClD,YAAM,OAAO,MAAM;AACnB,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,YAAQ,GAAG,UAAU,OAAO;AAC5B,YAAQ,GAAG,WAAW,OAAO;AAE7B,WAAO,KAAK,0CAA0C;AAAA,EACxD,SAAS,KAAU;AACjB,WAAO,MAAM,mDAAmD,IAAI,OAAO;AAC3E,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,KAAK;","names":["path","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","fs","path","fs","path","resolve","name","z","z","fs","path","spawn","path","resolve","spawn","z","z","z"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/utils/logger.ts","../src/utils/sanitizer.ts","../src/client/api.ts","../src/server.ts","../src/tools/list-tests.ts","../src/tools/results.ts","../src/tools/get-test.ts","../src/tools/get-groups.ts","../src/tools/download-script.ts","../src/tools/save-script.ts","../src/tools/environment.ts","../src/tools/run-logs.ts","../src/tools/authoring-guide.ts","../src/tools/create-plan.ts","../src/tools/save-group-script.ts","../src/local/passing-runs.ts","../src/local/environment-setup.ts","../src/tools/local-run.ts","../src/local/runner.ts","../src/tools/setup-instructions.ts","../src/tools/index.ts","../src/version.ts"],"sourcesContent":["import { serveStdio } from \"@modelcontextprotocol/server/stdio\";\nimport { loadConfig } from \"./config.js\";\nimport { QCentriqApiClient } from \"./client/api.js\";\nimport { createServer } from \"./server.js\";\nimport { logger } from \"./utils/logger.js\";\n\nfunction main(): void {\n try {\n const config = loadConfig(process.argv);\n logger.info(`Starting QCentriq MCP Server against: ${config.baseUrl}`);\n\n const apiClient = new QCentriqApiClient(config);\n\n // serveStdio, not server.connect: a hand-wired transport only speaks the\n // 2025 protocol revisions, while this serves 2026-07-28 clients as well.\n const handle = serveStdio(() => createServer(apiClient, config));\n\n const cleanup = async () => {\n logger.info(\"Shutting down QCentriq MCP Server...\");\n await handle.close();\n process.exit(0);\n };\n\n process.on(\"SIGINT\", cleanup);\n process.on(\"SIGTERM\", cleanup);\n\n logger.info(\"QCentriq MCP Server is running on stdio.\");\n } catch (err: any) {\n logger.error(\"Fatal error during QCentriq MCP Server startup:\", err.message);\n process.exit(1);\n }\n}\n\nmain();\n","import { Command } from \"commander\";\nimport { QCentriqConfig } from \"./types.js\";\nimport { logger, setDebugLogging } from \"./utils/logger.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.qcentriq.com\";\n\nexport function loadConfig(argv: string[] = process.argv): QCentriqConfig {\n const program = new Command();\n\n program\n .name(\"qcentriq-mcp\")\n .description(\"QCentriq Model Context Protocol (MCP) Server for automated test discovery and execution\")\n .option(\"-k, --api-key <key>\", \"QCentriq API key (or QCENTRIQ_API_KEY env var)\")\n .option(\"-u, --base-url <url>\", \"QCentriq API base URL (or QCENTRIQ_BASE_URL env var)\")\n .option(\"-p, --project-id <id>\", \"Default QCentriq project UUID (or QCENTRIQ_PROJECT_ID env var)\")\n .option(\"-d, --debug\", \"Enable debug logging to stderr (or DEBUG/QCENTRIQ_DEBUG env var)\")\n .allowUnknownOption(true)\n .parse(argv);\n\n const opts = program.opts();\n\n const apiKey = opts.apiKey || process.env.QCENTRIQ_API_KEY || \"\";\n const rawBaseUrl = opts.baseUrl || process.env.QCENTRIQ_BASE_URL || DEFAULT_BASE_URL;\n const baseUrl = rawBaseUrl.replace(/\\/+$/, \"\");\n const defaultProjectId = opts.projectId || process.env.QCENTRIQ_PROJECT_ID;\n const debug = Boolean(opts.debug || process.env.DEBUG || process.env.QCENTRIQ_DEBUG);\n\n if (debug) {\n setDebugLogging(true);\n }\n\n if (!apiKey) {\n logger.error(\"Missing QCentriq API key!\");\n logger.error(\"Provide it via --api-key <key> or set the QCENTRIQ_API_KEY environment variable.\");\n logger.error(\"Example: QCENTRIQ_API_KEY=qc_xxxxxxxxxxxx npx -y @qcentriq/mcp\");\n process.exit(1);\n }\n\n return {\n apiKey,\n baseUrl,\n defaultProjectId,\n debug,\n };\n}\n","/**\n * Logger for QCentriq MCP Server.\n *\n * CRITICAL: In MCP stdio servers, standard output (stdout) is reserved\n * exclusively for JSON-RPC messages. Any text printed to stdout will\n * corrupt the MCP protocol stream. All logging MUST go to standard error (stderr).\n */\n\nlet isDebugEnabled = Boolean(process.env.DEBUG || process.env.QCENTRIQ_DEBUG);\n\nexport function setDebugLogging(enabled: boolean): void {\n isDebugEnabled = enabled;\n}\n\nfunction formatMessage(level: string, message: string, ...args: any[]): string {\n const timestamp = new Date().toISOString();\n const extra = args.length > 0 ? \" \" + args.map((a) => (typeof a === \"object\" ? JSON.stringify(a) : String(a))).join(\" \") : \"\";\n return `[${timestamp}] [QCentriq MCP] [${level}] ${message}${extra}\\n`;\n}\n\nexport const logger = {\n info(message: string, ...args: any[]): void {\n process.stderr.write(formatMessage(\"INFO\", message, ...args));\n },\n warn(message: string, ...args: any[]): void {\n process.stderr.write(formatMessage(\"WARN\", message, ...args));\n },\n error(message: string, ...args: any[]): void {\n process.stderr.write(formatMessage(\"ERROR\", message, ...args));\n },\n debug(message: string, ...args: any[]): void {\n if (isDebugEnabled) {\n process.stderr.write(formatMessage(\"DEBUG\", message, ...args));\n }\n },\n};\n","/**\n * Zero-Leak Credential Redactor for QCentriq MCP Server.\n *\n * Ensures API keys, bearer tokens, passwords, and sensitive values\n * are redacted before tool payloads are returned to the LLM.\n */\n\n// Matches QCentriq API keys: qc_ followed by 40 hex chars\nconst QCENTRIQ_KEY_REGEX = /qc_[0-9a-fA-F]{30,45}/g;\n\n// Matches Bearer JWT tokens\nconst BEARER_TOKEN_REGEX = /Bearer\\s+ey[A-Za-z0-9-_=]+\\.[A-Za-z0-9-_=]+\\.?[A-Za-z0-9-_.+/=]*/g;\n\n// Matches embedded credentials in URLs: https://user:pass@example.com -> https://example.com\nconst URL_CREDENTIALS_REGEX = /([a-zA-Z][a-zA-Z0-9+.-]*:\\/\\/)[^/\\s:@]+:[^/\\s:@]+@/g;\n\nexport function sanitizeText(text: string): string {\n if (!text) return text;\n return text\n .replace(QCENTRIQ_KEY_REGEX, \"[REDACTED_API_KEY]\")\n .replace(BEARER_TOKEN_REGEX, \"Bearer [REDACTED_TOKEN]\")\n .replace(URL_CREDENTIALS_REGEX, \"$1[REDACTED_USERINFO]@\");\n}\n\nexport function sanitizePayload<T>(value: T): T {\n if (value === null || value === undefined) {\n return value;\n }\n if (typeof value === \"string\") {\n return sanitizeText(value) as unknown as T;\n }\n if (Array.isArray(value)) {\n return value.map((item) => sanitizePayload(item)) as unknown as T;\n }\n if (typeof value === \"object\") {\n const copy: Record<string, any> = {};\n for (const [k, v] of Object.entries(value)) {\n // If the field name looks like a secret/token/password and the value is string, mask it\n if (\n /password|secret|token|api_?key|auth/i.test(k) &&\n typeof v === \"string\" &&\n v.length > 0\n ) {\n copy[k] = \"[REDACTED]\";\n } else {\n copy[k] = sanitizePayload(v);\n }\n }\n return copy as T;\n }\n return value;\n}\n","import { QCentriqConfig } from \"../types.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { sanitizePayload } from \"../utils/sanitizer.js\";\n\n/**\n * How long a backend call may take before it is aborted.\n *\n * Without a limit, a backend that accepts the connection and never answers\n * blocks the tool call indefinitely, and the agent has no way to recover.\n */\nexport const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;\n\n/**\n * Extract a readable message from a failed response.\n *\n * The body is read once as text and parsed afterwards: a body can only be\n * consumed once, so a failed `res.json()` would leave nothing for a text\n * fallback. Non-JSON bodies are common — a proxy in front of the backend\n * answers a 502 with HTML.\n */\nasync function readErrorDetail(res: Response): Promise<string> {\n let text: string;\n try {\n text = await res.text();\n } catch {\n return res.statusText;\n }\n if (!text) return res.statusText;\n\n try {\n const json: any = JSON.parse(text);\n // The backend's validation messages name the offending field, id or\n // line; passing them through is what lets the calling agent fix itself.\n return json?.detail || JSON.stringify(json);\n } catch {\n return text;\n }\n}\n\nexport class QCentriqApiClient {\n constructor(private readonly config: QCentriqConfig) {}\n\n /**\n * Authenticated GET against the QCentriq backend (/api/v1/mcp-client/...).\n * Undefined and null params are left out of the query string.\n */\n async request(path: string, params: Record<string, any> = {}): Promise<any> {\n const query = new URLSearchParams();\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined && value !== null) {\n query.set(key, String(value));\n }\n }\n return this.call(\"GET\", path, query);\n }\n\n /** Authenticated JSON write against the QCentriq backend. */\n async send(method: \"POST\" | \"PUT\", path: string, body: Record<string, any>): Promise<any> {\n return this.call(method, path, undefined, body);\n }\n\n private async call(method: string, path: string, query?: URLSearchParams, body?: Record<string, any>): Promise<any> {\n const cleanPath = path.startsWith(\"/\") ? path : `/${path}`;\n const qs = query?.toString();\n const url = `${this.config.baseUrl}/api/v1/mcp-client${cleanPath}${qs ? `?${qs}` : \"\"}`;\n logger.debug(`[mcp-client] HTTP ${method} ${url}`);\n\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.config.apiKey}`,\n Accept: \"application/json\",\n };\n if (body) headers[\"Content-Type\"] = \"application/json\";\n\n const res = await this.fetchWithTimeout(method, cleanPath, url, {\n headers,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!res.ok) {\n throw new Error(`API error (${res.status}): ${await readErrorDetail(res)}`);\n }\n\n return sanitizePayload(await res.json());\n }\n\n /**\n * Issue a request that is aborted after the configured timeout, reporting\n * the timeout as such rather than as a bare AbortError.\n */\n private async fetchWithTimeout(method: string, path: string, url: string, init: RequestInit): Promise<Response> {\n const timeoutMs = this.config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;\n try {\n return await fetch(url, { ...init, method, signal: AbortSignal.timeout(timeoutMs) });\n } catch (err: any) {\n if (err?.name === \"TimeoutError\") {\n throw new Error(`${method} ${path} timed out after ${timeoutMs}ms`);\n }\n throw err;\n }\n }\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { QCentriqApiClient } from \"./client/api.js\";\nimport { registerAllTools } from \"./tools/index.js\";\nimport { QCentriqConfig } from \"./types.js\";\nimport { PACKAGE_VERSION } from \"./version.js\";\n\n/**\n * Sent to the client at initialize; most clients add it to the assistant's\n * system prompt. This server cannot see or call other MCP servers, so the\n * Playwright MCP step is guidance, not something it can enforce.\n */\nexport const SERVER_INSTRUCTIONS = `QCentriq MCP finds, runs, diagnoses and writes QCentriq Playwright tests.\n\nTo write a new test plan or script:\n1. 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.\n2. 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.\n3. Create the plan with qcentriq_create_plan, describing only flows you saw.\n4. 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.\n\nHTTP 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:\n- 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.\n- Navigate again with them in the URL, https://<username>:<password>@host/path, percent-encoding reserved characters (@ as %40, : as %3A). Playwright MCP's default Chromium browser then remembers them for that origin, so later navigations and clicks need no credentials. Then explore as usual.\n- Ask the user only if the credentials are not there, for example when they are listed only in secret_keys: QCentriq never returns secret values.\n- In the plan, note the basic-auth precondition using the environment's variable names, never the values.\n- In the script, do not put credentials in URLs or call any auth API yourself: the conftest QCentriq ships applies basic auth to every browser context from BASIC_AUTH_USERNAME and BASIC_AUTH_PASSWORD (or the keys named by QCENTRIQ_BASIC_AUTH_USERNAME_KEY and QCENTRIQ_BASIC_AUTH_PASSWORD_KEY, as in the cloud). For qcentriq_run_local_test, pass BASIC_AUTH_USERNAME and BASIC_AUTH_PASSWORD in env_vars with the values you found.`;\n\nexport function createServer(client: QCentriqApiClient, config: QCentriqConfig): McpServer {\n const server = new McpServer({ name: \"@qcentriq/mcp\", version: PACKAGE_VERSION }, { instructions: SERVER_INSTRUCTIONS });\n registerAllTools(server, client, config);\n return server;\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { backendCall } from \"./results.js\";\n\nexport function registerListTestsTool(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n server.registerTool(\n \"qcentriq_list_tests\",\n {\n description:\n \"Discover and list automated test cases and test groups for a project with status, priority, and update dates. Test group script availability is indicated in test_groups. Blocked test cases have no script.\",\n inputSchema: z.object({\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from API key if omitted).\"),\n group_id: z.uuid().optional().describe(\"Optional test group UUID filter.\"),\n priority: z.enum([\"low\", \"medium\", \"high\", \"critical\"]).optional().describe(\"Filter by priority.\"),\n test_type: z.enum([\"web\", \"api\", \"mobile\"]).optional().describe(\"Filter by test type.\"),\n status: z.enum([\"failed\", \"passed\", \"error\", \"never_run\", \"blocked\", \"active\", \"flaky\"]).optional().describe(\"Filter by test status (e.g. 'failed' or 'blocked').\"),\n limit: z.number().int().min(1).max(100).default(50).describe(\"Max number of test cases to return (default 50).\"),\n offset: z.number().int().min(0).default(0).describe(\"Pagination offset.\"),\n }),\n },\n async (args) =>\n backendCall(\"qcentriq_list_tests\", () =>\n client.request(\"/tests\", { ...args, project_id: args.project_id || config.defaultProjectId })\n )\n );\n}\n","export type TextResult = { isError?: boolean; content: Array<{ type: \"text\"; text: string }> };\n\nexport function jsonResult(data: unknown): TextResult {\n return { content: [{ type: \"text\", text: JSON.stringify(data, null, 2) }] };\n}\n\nexport function errorResult(text: string): TextResult {\n return { isError: true, content: [{ type: \"text\", text }] };\n}\n\n/** Run a backend call for `tool`, returning its payload as JSON or its failure as a tool error. */\nexport async function backendCall(tool: string, run: () => Promise<unknown>): Promise<TextResult> {\n try {\n return jsonResult(await run());\n } catch (err: any) {\n return errorResult(`Error in ${tool}: ${err.message}`);\n }\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { backendCall } from \"./results.js\";\n\nexport function registerGetTestTool(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n server.registerTool(\n \"qcentriq_get_test\",\n {\n description:\n \"Retrieve detailed test case information including step definitions, preconditions, latest execution diagnostics, error stack traces, and parent test group script metadata.\",\n inputSchema: z.object({\n test_case_id: z.uuid().describe(\"UUID of the target test case.\"),\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from API key if omitted).\"),\n }),\n },\n async ({ test_case_id, ...query }) =>\n backendCall(\"qcentriq_get_test\", () =>\n client.request(`/tests/${test_case_id}`, { ...query, project_id: query.project_id || config.defaultProjectId })\n )\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { backendCall } from \"./results.js\";\n\nexport function registerGetTestGroupsTool(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n server.registerTool(\n \"qcentriq_get_test_groups\",\n {\n description:\n \"Discover and inspect test groups for a project. Returns what each group is about (title, description), total/active/blocked test case counts, and whether a test script exists. Provide group_id to inspect member test cases.\",\n inputSchema: z.object({\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from API key if omitted).\"),\n group_id: z.uuid().optional().describe(\"Optional test group UUID filter to inspect a specific group.\"),\n limit: z.number().int().min(1).max(100).default(50).describe(\"Max test groups to return (default 50).\"),\n offset: z.number().int().min(0).default(0).describe(\"Pagination offset.\"),\n }),\n },\n async (args) =>\n backendCall(\"qcentriq_get_test_groups\", () =>\n client.request(\"/groups\", { ...args, project_id: args.project_id || config.defaultProjectId })\n )\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { DEFAULT_SCRIPT_DIR, saveScriptFiles } from \"./save-script.js\";\nimport { jsonResult, errorResult } from \"./results.js\";\n\nexport function registerDownloadScriptTool(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n server.registerTool(\n \"qcentriq_download_script\",\n {\n description:\n `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.`,\n inputSchema: z.object({\n group_id: z.uuid().describe(\"UUID of the target test group.\"),\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from API key if omitted).\"),\n include_fixtures: z.boolean().default(true).describe(\"Whether to retrieve accompanying conftest.py / fixtures (default True).\"),\n save_to_disk: z.boolean().default(true).describe(\"Saves the downloaded test script and fixtures to destination_dir (default True). Set false to only return the content.\"),\n destination_dir: z.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.`),\n }),\n },\n async (args) => {\n let data: any;\n try {\n data = await client.request(`/groups/${args.group_id}/script`, {\n project_id: args.project_id || config.defaultProjectId,\n include_fixtures: args.include_fixtures,\n });\n } catch (err: any) {\n return errorResult(`Error in qcentriq_download_script: ${err.message}`);\n }\n\n if (!args.save_to_disk || !data?.file_name || !data?.content) return jsonResult(data);\n\n // Save where qcentriq_save_script writes, so both tools leave files in one place\n try {\n data.saved_files = await saveScriptFiles(args.destination_dir, data.file_name, data.content, data.conftest_content);\n return jsonResult(data);\n } catch (writeErr: any) {\n logger.warn(`Failed to write downloaded script to disk: ${writeErr.message}`);\n // The caller asked for files on disk, so reporting success would send\n // it to run a file that does not exist. The download itself is kept\n // so the script can still be saved with qcentriq_save_script.\n return {\n isError: true,\n content: [\n {\n type: \"text\" as const,\n 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.`,\n },\n ...jsonResult(data).content,\n ],\n };\n }\n }\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { logger } from \"../utils/logger.js\";\nimport { jsonResult, errorResult } from \"./results.js\";\n\n/**\n * Default destination for downloaded scripts.\n *\n * Deliberately not \"./tests\": that is where most Python projects keep their own\n * suite, and writing a QCentriq conftest.py there would overwrite the\n * developer's own. A dedicated directory keeps the two side by side.\n */\nexport const DEFAULT_SCRIPT_DIR = \"./qcentriq_tests\";\n\nexport function registerSaveScriptTool(server: McpServer): void {\n server.registerTool(\n \"qcentriq_save_script\",\n {\n description:\n \"Save downloaded Playwright Python test script and fixtures directly to the local workspace disk so they can be run or edited locally.\",\n inputSchema: z.object({\n file_name: z.string().describe(\"Target filename (e.g. 'test_login.py').\"),\n content: z.string().describe(\"Python test script source code.\"),\n conftest_content: z.string().optional().describe(\"Accompanying conftest.py source code if present.\"),\n destination_dir: z.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.`),\n }),\n },\n async (args) => {\n try {\n const savedFiles = await saveScriptFiles(args.destination_dir ?? DEFAULT_SCRIPT_DIR, args.file_name, args.content, args.conftest_content);\n return jsonResult({\n status: \"success\",\n message: `Successfully saved ${savedFiles.length} file(s) to ${path.dirname(savedFiles[0])}`,\n saved_files: savedFiles,\n });\n } catch (err: any) {\n return errorResult(`Failed to save test script to disk: ${err.message}`);\n }\n }\n );\n}\n\n/**\n * Write a script, and its conftest.py when given, into `destinationDir`\n * (relative to the working directory). Only the base name of `fileName` is\n * used, so a name like \"../../x.py\" cannot escape the directory.\n * Returns the absolute paths written.\n */\nexport async function saveScriptFiles(destinationDir: string, fileName: string, content: string, conftest?: string): Promise<string[]> {\n const safeFileName = path.basename(fileName);\n if (!safeFileName || safeFileName === \".\" || safeFileName === \"..\") {\n throw new Error(`Invalid file name: \"${fileName}\"`);\n }\n const targetDir = path.resolve(process.cwd(), destinationDir);\n await fs.mkdir(targetDir, { recursive: true });\n\n const scriptPath = path.join(targetDir, safeFileName);\n await fs.writeFile(scriptPath, content, \"utf-8\");\n logger.info(`Saved test script to: ${scriptPath}`);\n const saved = [scriptPath];\n\n if (conftest) {\n const conftestPath = path.join(targetDir, \"conftest.py\");\n await fs.writeFile(conftestPath, conftest, \"utf-8\");\n logger.info(`Saved conftest.py to: ${conftestPath}`);\n saved.push(conftestPath);\n }\n return saved;\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { backendCall } from \"./results.js\";\n\nexport function registerEnvironmentTool(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n server.registerTool(\n \"qcentriq_get_environment\",\n {\n description:\n \"Retrieve target test environment configuration, base URL (BASE_URL), environment variables, and required secret variable names for local test execution.\",\n inputSchema: z.object({\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from API key if omitted).\"),\n environment_id: z.uuid().optional().describe(\"Optional specific environment UUID.\"),\n environment_name: z.string().optional().describe(\"Optional environment name filter (e.g. 'staging', 'dev', 'production').\"),\n }),\n },\n async (args) =>\n backendCall(\"qcentriq_get_environment\", () =>\n client.request(\"/environment\", { ...args, project_id: args.project_id || config.defaultProjectId })\n )\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { backendCall } from \"./results.js\";\n\nexport function registerRunLogsTool(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n server.registerTool(\n \"qcentriq_get_test_run_logs\",\n {\n description:\n \"Retrieve execution history and logs for a test case: per-run status, timing, error message, stack trace, and raw output logs across runs.\",\n inputSchema: z.object({\n test_case_id: z.uuid().describe(\"UUID of the target test case.\"),\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from API key if omitted).\"),\n run_id: z.uuid().optional().describe(\"Optional specific run UUID to fetch a single run's full log.\"),\n status: z.enum([\"failed\", \"passed\", \"error\"]).optional().describe(\"Filter by result status.\"),\n latest_only: z.boolean().default(false).describe(\"If True, returns only the most recent matching run.\"),\n from_date: z.string().optional().describe(\"Optional ISO-8601 start date filter.\"),\n to_date: z.string().optional().describe(\"Optional ISO-8601 end date filter.\"),\n limit: z.number().int().min(1).max(100).default(20).describe(\"Max runs to return.\"),\n offset: z.number().int().min(0).default(0).describe(\"Pagination offset.\"),\n }),\n },\n async ({ test_case_id, ...query }) =>\n backendCall(\"qcentriq_get_test_run_logs\", () =>\n client.request(`/tests/${test_case_id}/run-logs`, { ...query, project_id: query.project_id || config.defaultProjectId })\n )\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\n\nexport function registerAuthoringGuideTool(server: McpServer, client: QCentriqApiClient): void {\n server.registerTool(\n \"qcentriq_get_authoring_guide\",\n {\n description:\n \"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 — 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.\",\n inputSchema: z.object({}),\n annotations: {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n },\n },\n async () => {\n try {\n const guide = await client.request(\"/authoring-guide\");\n return {\n content: [{ type: \"text\", text: JSON.stringify(guide, null, 2) }],\n };\n } catch (err: any) {\n // Deliberately an error rather than a partial contract: an agent that\n // writes against an empty schema produces plans the backend rejects.\n return {\n isError: true,\n content: [{ type: \"text\", text: `Error fetching the authoring guide: ${err.message}` }],\n };\n }\n }\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { backendCall } from \"./results.js\";\n\nexport function registerCreatePlanTool(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n server.registerTool(\n \"qcentriq_create_plan\",\n {\n description:\n \"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.\",\n inputSchema: z.object({\n plan: z.record(z.string(), z.any()).describe(\"The plan object, matching the TaskPlan schema from qcentriq_get_authoring_guide.\"),\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from the API key if omitted).\"),\n }),\n annotations: {\n readOnlyHint: false,\n destructiveHint: false, // Creates new groups and cases; never modifies existing ones.\n idempotentHint: false, // Calling twice creates two plans.\n openWorldHint: false,\n },\n },\n async (args) =>\n backendCall(\"qcentriq_create_plan\", () =>\n client.send(\"POST\", \"/plans\", { plan: args.plan, project_id: args.project_id || config.defaultProjectId })\n )\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { backendCall, errorResult } from \"./results.js\";\nimport { PassingRunLedger, fixtureMismatch } from \"../local/passing-runs.js\";\nimport { detectPackageManagers, installUvNotice } from \"../local/environment-setup.js\";\n\nexport function registerSaveGroupScriptTool(\n server: McpServer,\n client: QCentriqApiClient,\n config: QCentriqConfig,\n passingRuns: PassingRunLedger\n): void {\n server.registerTool(\n \"qcentriq_save_group_script\",\n {\n description:\n \"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>') — no duplicates, no ids from other groups. A rejection names the offending id or line so you can correct it. Pass expected_updated_at from the last download to turn a concurrent edit into a conflict rather than a lost update. conftest.py cannot be saved; QCentriq provides it. Requires the 'test:write' scope.\",\n inputSchema: z.object({\n group_id: z.uuid().describe(\"UUID of the target test group.\"),\n content: z.string().describe(\"The Python test script source.\"),\n project_id: z.uuid().optional().describe(\"Optional project UUID (inferred from the API key if omitted).\"),\n filename: z.string().optional().describe(\"Optional script filename; derived from the group title if omitted.\"),\n fixtures: z\n .array(z.object({ file_name: z.string(), content: z.string() }))\n .optional()\n .describe(\"Companion files to store next to the script (page objects, test data). conftest.py is rejected.\"),\n expected_updated_at: z\n .string()\n .optional()\n .describe(\"ISO-8601 timestamp from the last download. Supply it to get a conflict instead of silently overwriting someone else's edit.\"),\n }),\n annotations: {\n readOnlyHint: false,\n destructiveHint: true, // Replaces the group's existing script.\n idempotentHint: true, // Saving the same content twice leaves the same state.\n openWorldHint: false,\n },\n },\n async (args) => {\n const untested = await untestedReason(passingRuns, args);\n if (untested) return errorResult(untested);\n\n const { group_id, ...body } = args;\n return backendCall(\"qcentriq_save_group_script\", () =>\n client.send(\"PUT\", `/groups/${group_id}/script`, { ...body, project_id: body.project_id || config.defaultProjectId })\n );\n }\n );\n}\n\n/** Why this upload has not been proven locally, or null when it has. */\nasync function untestedReason(\n passingRuns: PassingRunLedger,\n args: { content: string; fixtures?: Array<{ file_name: string; content: string }> }\n): Promise<string | null> {\n const run = passingRuns.find(args.content);\n if (!run) {\n const reason =\n \"Upload refused: this script has not passed a local run, so nothing was sent to QCentriq. \" +\n \"Save it to disk, run it with qcentriq_run_local_test on the whole file until it passes, then call this tool again with exactly that content.\";\n const notice = installUvNotice(await detectPackageManagers());\n return notice ? `${reason}\\n\\n${notice}` : reason;\n }\n const mismatch = await fixtureMismatch(run, args.fixtures ?? []);\n if (mismatch) {\n return `Upload refused: ${mismatch}, so nothing was sent to QCentriq. Re-run ${run.filePath} with qcentriq_run_local_test and upload the files exactly as they were when it passed.`;\n }\n return null;\n}\n","import { createHash } from \"node:crypto\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nexport interface PassingRun {\n /** Absolute path of the script that passed. */\n filePath: string;\n /** Directory the script ran from; its companion files are looked up here. */\n dir: string;\n /** When the run started (epoch ms). A companion file modified later is not what ran. */\n startedAt: number;\n}\n\n/**\n * Scripts that passed a whole-file local run in this server process, keyed by\n * a hash of their exact content.\n *\n * This is what lets qcentriq_save_group_script upload only what was proven to\n * work locally: the agent passes content, not a path, so the content itself\n * has to be matched to a run. Kept in memory on purpose; after a restart the\n * script simply has to be run again.\n */\nexport class PassingRunLedger {\n private readonly runs = new Map<string, PassingRun>();\n\n record(content: string, run: PassingRun): void {\n this.runs.set(contentHash(content), run);\n }\n\n find(content: string): PassingRun | undefined {\n return this.runs.get(contentHash(content));\n }\n}\n\nfunction contentHash(content: string): string {\n return createHash(\"sha256\").update(content).digest(\"hex\");\n}\n\n/** pytest flags that run only part of a file, or none of it. */\nconst NARROWING_FLAGS = [\"-k\", \"-m\", \"--deselect\", \"--lf\", \"--last-failed\", \"--sw\", \"--stepwise\", \"--co\", \"--collect-only\", \"--setup-only\", \"--setup-plan\", \"--fixtures\"];\n\n/**\n * Whether a pass under these arguments says anything about the whole script.\n * A run filtered to some tests leaves the others unproven.\n */\nexport function coversWholeFile(filePath: string, testName?: string, extraArgs: string[] = []): boolean {\n if (testName || filePath.includes(\"::\")) return false;\n return !extraArgs.some((arg) =>\n NARROWING_FLAGS.some((flag) => arg === flag || arg.startsWith(`${flag}=`) || (/^-[a-z]$/.test(flag) && arg.startsWith(flag)))\n );\n}\n\n/** pytest exits 0 when every test is skipped; a pass needs at least one test that actually passed. */\nexport function reportsPassedTests(stdout: string): boolean {\n return /\\b[1-9]\\d* passed\\b/.test(stdout);\n}\n\n/**\n * Check that each companion file is the one that sat next to the script when\n * it passed: present, byte-identical, and not modified since the run began.\n * Returns why a file fails, or null when they all match.\n */\nexport async function fixtureMismatch(run: PassingRun, fixtures: Array<{ file_name: string; content: string }>): Promise<string | null> {\n for (const fixture of fixtures) {\n const localPath = path.resolve(run.dir, fixture.file_name);\n if (path.dirname(localPath) !== run.dir) {\n return `companion file \"${fixture.file_name}\" is not a plain file name next to the script`;\n }\n let local: string;\n let modifiedAt: number;\n try {\n [local, modifiedAt] = await Promise.all([fs.readFile(localPath, \"utf-8\"), fs.stat(localPath).then((s) => s.mtimeMs)]);\n } catch {\n return `companion file \"${fixture.file_name}\" was not next to the script (${run.dir}) when it passed`;\n }\n if (local !== fixture.content) {\n return `companion file \"${fixture.file_name}\" differs from ${localPath}, which the passing run used`;\n }\n if (modifiedAt > run.startedAt) {\n return `companion file \"${fixture.file_name}\" changed after the passing run`;\n }\n }\n return null;\n}\n","import { spawn } from \"node:child_process\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { logger } from \"../utils/logger.js\";\n\nexport type PackageManagerName = \"uv\" | \"poetry\" | \"conda\" | \"venv\";\n\nexport interface PackageManagerStatus {\n name: PackageManagerName;\n available: boolean;\n version?: string;\n probe_command: string;\n}\n\nexport interface SetupStep {\n description: string;\n command: string;\n}\n\nexport interface EnvironmentSetupParams {\n preferredManager?: PackageManagerName;\n workingDir?: string;\n envName?: string;\n pythonVersion?: string;\n playwrightVersion?: string;\n /** Package list from the backend. Omitted falls back to FALLBACK_TEST_PACKAGES. */\n packages?: readonly string[];\n}\n\nexport interface EnvironmentSetupPlan {\n working_dir: string;\n package_managers: PackageManagerStatus[];\n recommended_manager: PackageManagerName;\n active_environment: string | null;\n detected_project_files: string[];\n steps: SetupStep[];\n verify_command: string;\n notes: string[];\n}\n\n/**\n * Ordered by preference: uv first (fastest, and the standard for QCentriq test execution\n * containers), then poetry and conda, with the stdlib venv module as the universal fallback.\n */\nconst MANAGER_PRIORITY: PackageManagerName[] = [\"uv\", \"poetry\", \"conda\", \"venv\"];\n\nconst PROBE_TIMEOUT_MS = 5000;\n\n/** Default Python version for the QCentriq test environment (matches the execution container). */\nconst DEFAULT_PYTHON_VERSION = \"3.12\";\n\n/** Default Playwright version pin (matches issues-dev/Dockerfile.execution). */\nconst DEFAULT_PLAYWRIGHT_VERSION = \"1.56.0\";\n\n/**\n * Offline copy of the execution container's package list.\n *\n * The authoritative list is served by the backend at\n * /api/v1/mcp-client/runtime-requirements, which reads the same\n * execution-requirements.txt that Dockerfile.execution installs from. This copy\n * exists only so setup instructions still work without a reachable backend, and\n * a test asserts the two stay identical.\n *\n * playwright is absent on purpose: its version is pinned per execution image.\n */\nexport const FALLBACK_TEST_PACKAGES: readonly string[] = [\n \"pytest\",\n \"pytest-playwright\",\n \"allure-pytest\",\n \"httpx\",\n \"nest-asyncio\",\n \"pytest-playwright-visual-snapshot\",\n \"Pillow\",\n];\n\n/** Build the exact dependency set QCentriq Playwright test scripts need to run locally. */\nexport function testDependencies(playwrightVersion: string, packages?: readonly string[]): string {\n const base = packages && packages.length > 0 ? packages : FALLBACK_TEST_PACKAGES;\n return [...base, `playwright==${playwrightVersion}`].join(\" \");\n}\n\ninterface ProjectContext {\n workingDir: string;\n isWindows: boolean;\n envName: string;\n pythonVersion: string;\n playwrightVersion: string;\n /** Package list reported by the backend; falls back to FALLBACK_TEST_PACKAGES. */\n packages?: readonly string[];\n projectFiles: string[];\n}\n\n/**\n * Run `<cmd> --version` style probes without letting a hung binary stall the tool.\n * Commands are hardcoded constants, so the Windows `shell` hop (needed for .cmd/.bat\n * shims like poetry and conda) carries no injection risk.\n */\nfunction probeCommand(cmd: string, args: string[]): Promise<string | null> {\n return new Promise((resolve) => {\n let output = \"\";\n let settled = false;\n\n const finish = (value: string | null) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve(value);\n };\n\n let child;\n try {\n child = spawn(cmd, args, {\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n shell: process.platform === \"win32\",\n });\n } catch {\n resolve(null);\n return;\n }\n\n const timer = setTimeout(() => {\n try {\n child.kill(\"SIGKILL\");\n } catch {\n // Process already exited\n }\n finish(null);\n }, PROBE_TIMEOUT_MS);\n\n // Some tools (older conda, python) report their version on stderr\n child.stdout?.on(\"data\", (chunk) => (output += chunk.toString()));\n child.stderr?.on(\"data\", (chunk) => (output += chunk.toString()));\n child.on(\"error\", () => finish(null));\n child.on(\"close\", (code) => finish(code === 0 ? output.trim().split(\"\\n\")[0].trim() || \"unknown\" : null));\n });\n}\n\n/**\n * Locate a usable Python interpreter that can also create virtualenvs.\n * On Debian-family systems `venv` is packaged separately, so importing it is part of the probe.\n */\nexport const PYTHON_BIN = process.platform === \"win32\" ? \"python\" : \"python3\";\n\nasync function probePython(): Promise<{ bin: string; version: string } | null> {\n for (const bin of [PYTHON_BIN, \"python\"]) {\n const version = await probeCommand(bin, [\"-c\", \"import venv, sys; print(sys.version.split()[0])\"]);\n if (version) {\n return { bin, version };\n }\n }\n return null;\n}\n\nasync function fileExists(filePath: string): Promise<boolean> {\n try {\n await fs.access(filePath);\n return true;\n } catch {\n return false;\n }\n}\n\nasync function detectProjectFiles(workingDir: string): Promise<string[]> {\n const candidates = [\n \"pyproject.toml\",\n \"uv.lock\",\n \"poetry.lock\",\n \"requirements.txt\",\n \"environment.yml\",\n \"environment.yaml\",\n ];\n const found: string[] = [];\n for (const candidate of candidates) {\n if (await fileExists(path.join(workingDir, candidate))) {\n found.push(candidate);\n }\n }\n return found;\n}\n\n/** Detect which Python package managers are installed on the developer's machine. */\nexport async function detectPackageManagers(): Promise<PackageManagerStatus[]> {\n const [uv, poetry, conda, python] = await Promise.all([\n probeCommand(\"uv\", [\"--version\"]),\n probeCommand(\"poetry\", [\"--version\"]),\n probeCommand(\"conda\", [\"--version\"]),\n probePython(),\n ]);\n\n return [\n { name: \"uv\", available: Boolean(uv), version: uv ?? undefined, probe_command: \"uv --version\" },\n { name: \"poetry\", available: Boolean(poetry), version: poetry ?? undefined, probe_command: \"poetry --version\" },\n { name: \"conda\", available: Boolean(conda), version: conda ?? undefined, probe_command: \"conda --version\" },\n {\n name: \"venv\",\n available: Boolean(python),\n version: python ? `${python.bin} ${python.version}` : undefined,\n probe_command: `${PYTHON_BIN} -m venv`,\n },\n ];\n}\n\nfunction activateCommand(ctx: ProjectContext): string {\n return ctx.isWindows ? \".venv\\\\Scripts\\\\activate\" : \"source .venv/bin/activate\";\n}\n\nfunction buildUvSteps(ctx: ProjectContext): SetupStep[] {\n const deps = testDependencies(ctx.playwrightVersion, ctx.packages);\n\n if (ctx.projectFiles.includes(\"uv.lock\")) {\n return [\n { description: \"Install the project's locked dependencies into a uv-managed virtualenv.\", command: \"uv sync\" },\n { description: \"Add the QCentriq test dependencies if they are not already in pyproject.toml.\", command: `uv add --dev ${deps}` },\n { description: \"Download the Playwright browser binaries.\", command: \"uv run playwright install chromium\" },\n ];\n }\n\n const steps: SetupStep[] = [\n { description: \"Create a virtual environment in .venv.\", command: `uv venv .venv --python ${ctx.pythonVersion}` },\n { description: \"Activate the virtual environment.\", command: activateCommand(ctx) },\n ];\n\n if (ctx.projectFiles.includes(\"requirements.txt\")) {\n steps.push({ description: \"Install the project's existing dependencies.\", command: \"uv pip install -r requirements.txt\" });\n }\n\n steps.push(\n { description: \"Install the QCentriq test dependencies (pytest, Playwright, Allure, and fixtures).\", command: `uv pip install ${deps}` },\n { description: \"Download the Playwright browser binaries.\", command: \"playwright install chromium\" }\n );\n\n return steps;\n}\n\n/** Install uv first, then the regular uv steps, for a machine with no package manager. */\nfunction buildUvBootstrapSteps(ctx: ProjectContext): SetupStep[] {\n return [\n {\n description: \"Install uv, the recommended package manager. It also downloads Python, so nothing else needs to be installed first.\",\n command: ctx.isWindows ? UV_INSTALL_COMMANDS.windows : UV_INSTALL_COMMANDS.unix,\n },\n { description: \"Open a new terminal so uv is on PATH, then confirm it is installed.\", command: \"uv --version\" },\n ...buildUvSteps(ctx),\n ];\n}\n\nfunction buildPoetrySteps(ctx: ProjectContext): SetupStep[] {\n const deps = testDependencies(ctx.playwrightVersion, ctx.packages);\n const steps: SetupStep[] = [\n {\n description: \"Keep the virtualenv inside the project so qcentriq_run_local_test can find it.\",\n command: \"poetry config virtualenvs.in-project true\",\n },\n ];\n\n if (!ctx.projectFiles.includes(\"pyproject.toml\")) {\n steps.push({\n description: \"Initialize a pyproject.toml for this test project.\",\n command: `poetry init --no-interaction --python \">=${ctx.pythonVersion}\"`,\n });\n }\n\n steps.push(\n { description: \"Add the QCentriq test dependencies (pytest, Playwright, Allure, and fixtures) as dev dependencies.\", command: `poetry add --group dev ${deps}` },\n { description: \"Install the environment.\", command: \"poetry install\" },\n { description: \"Download the Playwright browser binaries.\", command: \"poetry run playwright install chromium\" },\n { description: \"Activate the environment for your shell session.\", command: activateCommand(ctx) }\n );\n\n return steps;\n}\n\nfunction buildCondaSteps(ctx: ProjectContext): SetupStep[] {\n const deps = testDependencies(ctx.playwrightVersion, ctx.packages);\n const envFile = ctx.projectFiles.find((f) => f === \"environment.yml\" || f === \"environment.yaml\");\n\n const steps: SetupStep[] = envFile\n ? [{ description: \"Create the conda environment from the project's environment file.\", command: `conda env create -f ${envFile}` }]\n : [\n {\n description: \"Create a dedicated conda environment for QCentriq tests.\",\n command: `conda create -n ${ctx.envName} python=${ctx.pythonVersion} -y`,\n },\n ];\n\n steps.push(\n { description: \"Activate the conda environment.\", command: `conda activate ${ctx.envName}` },\n { description: \"Install the QCentriq test dependencies (pytest, Playwright, Allure, and fixtures).\", command: `pip install ${deps}` },\n { description: \"Download the Playwright browser binaries.\", command: \"playwright install chromium\" }\n );\n\n return steps;\n}\n\nfunction buildVenvSteps(ctx: ProjectContext): SetupStep[] {\n const deps = testDependencies(ctx.playwrightVersion, ctx.packages);\n const steps: SetupStep[] = [\n { description: \"Create a virtual environment in .venv.\", command: `${PYTHON_BIN} -m venv .venv` },\n { description: \"Activate the virtual environment.\", command: activateCommand(ctx) },\n { description: \"Upgrade pip inside the environment.\", command: \"python -m pip install --upgrade pip\" },\n ];\n\n if (ctx.projectFiles.includes(\"requirements.txt\")) {\n steps.push({ description: \"Install the project's existing dependencies.\", command: \"pip install -r requirements.txt\" });\n }\n\n steps.push(\n { description: \"Install the QCentriq test dependencies (pytest, Playwright, Allure, and fixtures).\", command: `pip install ${deps}` },\n { description: \"Download the Playwright browser binaries.\", command: \"playwright install chromium\" }\n );\n\n return steps;\n}\n\nconst STEP_BUILDERS: Record<PackageManagerName, (ctx: ProjectContext) => SetupStep[]> = {\n uv: buildUvSteps,\n poetry: buildPoetrySteps,\n conda: buildCondaSteps,\n venv: buildVenvSteps,\n};\n\nconst VERIFY_COMMANDS: Record<PackageManagerName, string> = {\n uv: \"pytest --version\",\n poetry: \"poetry run pytest --version\",\n conda: \"pytest --version\",\n venv: \"pytest --version\",\n};\n\n/**\n * Astral's official uv installers. Used when no package manager is on PATH at all:\n * uv needs no pre-existing Python (`uv venv --python` downloads one), so it is the\n * only option that bootstraps from nothing.\n */\nconst UV_INSTALL_COMMANDS = {\n unix: \"curl -LsSf https://astral.sh/uv/install.sh | sh\",\n windows: 'powershell -ExecutionPolicy ByPass -c \"irm https://astral.sh/uv/install.ps1 | iex\"',\n};\n\nconst INSTALL_HINTS: Record<PackageManagerName, string> = {\n uv: \"uv: https://docs.astral.sh/uv/getting-started/installation/\",\n poetry: \"poetry: https://python-poetry.org/docs/#installation\",\n conda: \"conda (miniconda): https://docs.conda.io/projects/miniconda/en/latest/\",\n venv: \"Python with the venv module: https://www.python.org/downloads/\",\n};\n\n/**\n * What to tell the user when no package manager is installed, or null when one is.\n * Tests cannot run locally without one, so uv, which bootstraps from nothing,\n * has to be installed before anything else.\n */\nexport function installUvNotice(managers: PackageManagerStatus[]): string | null {\n if (managers.some((m) => m.available)) return null;\n const command = process.platform === \"win32\" ? UV_INSTALL_COMMANDS.windows : UV_INSTALL_COMMANDS.unix;\n return (\n \"No Python package manager (uv, poetry, conda or python with venv) was found on this machine. \" +\n `Ask the user to install uv first, the recommended option: \\`${command}\\` (see https://docs.astral.sh/uv/getting-started/installation/). ` +\n \"Then call qcentriq_get_setup_instructions for the commands that create the test environment, and restart the MCP client from that environment.\"\n );\n}\n\nfunction detectActiveEnvironment(): string | null {\n if (process.env.VIRTUAL_ENV) {\n return `virtualenv: ${process.env.VIRTUAL_ENV}`;\n }\n if (process.env.CONDA_DEFAULT_ENV) {\n return `conda: ${process.env.CONDA_DEFAULT_ENV}`;\n }\n return null;\n}\n\n/**\n * Detect the developer's available Python tooling and return the commands they should run\n * to create an environment capable of executing QCentriq Playwright tests locally.\n * This only inspects the machine and returns instructions; it never creates the environment.\n */\nexport async function buildEnvironmentSetupPlan(params: EnvironmentSetupParams = {}): Promise<EnvironmentSetupPlan> {\n const workingDir = params.workingDir ? path.resolve(params.workingDir) : process.cwd();\n\n const [packageManagers, projectFiles] = await Promise.all([detectPackageManagers(), detectProjectFiles(workingDir)]);\n\n const availability = new Map(packageManagers.map((m) => [m.name, m.available]));\n const preferred = params.preferredManager;\n const notes: string[] = [];\n\n let installed: PackageManagerName | undefined;\n if (preferred && availability.get(preferred)) {\n installed = preferred;\n } else {\n if (preferred) {\n notes.push(`Requested package manager \"${preferred}\" was not found on PATH; falling back to the best available option.`);\n }\n installed = MANAGER_PRIORITY.find((name) => availability.get(name));\n }\n // With nothing installed, uv is still the recommendation: the steps install it first.\n const recommended: PackageManagerName = installed ?? \"uv\";\n\n const ctx: ProjectContext = {\n workingDir,\n isWindows: process.platform === \"win32\",\n envName: params.envName || \"qcentriq-tests\",\n pythonVersion: params.pythonVersion || DEFAULT_PYTHON_VERSION,\n playwrightVersion: params.playwrightVersion || DEFAULT_PLAYWRIGHT_VERSION,\n packages: params.packages,\n projectFiles,\n };\n\n const activeEnvironment = detectActiveEnvironment();\n if (activeEnvironment) {\n notes.push(`An environment is already active (${activeEnvironment}). Reuse it instead of creating a new one if it already has pytest and playwright installed.`);\n }\n\n const steps = installed ? STEP_BUILDERS[installed](ctx) : buildUvBootstrapSteps(ctx);\n const verifyCommand = VERIFY_COMMANDS[recommended];\n\n if (installed) {\n if (recommended !== \"uv\" && availability.get(\"uv\")) {\n notes.push(\"uv is also available on this machine and is recommended over other package managers for faster, more reliable installs. Pass preferred_manager to override this choice.\");\n }\n\n const alternatives = MANAGER_PRIORITY.filter((name) => name !== recommended && availability.get(name));\n if (alternatives.length > 0) {\n notes.push(`Also available on this machine: ${alternatives.join(\", \")}. Re-run this tool with preferred_manager to get instructions for one of them.`);\n }\n } else {\n notes.push(\"No supported Python package manager was found on PATH. The steps below install uv, the recommended option. To use a different tool instead, install one of the following and run this tool again:\");\n for (const name of MANAGER_PRIORITY.filter((name) => name !== \"uv\")) {\n notes.push(` - ${INSTALL_HINTS[name]}`);\n }\n }\n\n notes.push(\n \"Run these commands in a terminal from the working directory below — this tool returns instructions only and does not create the environment for you.\",\n \"qcentriq_run_local_test resolves pytest from the VIRTUAL_ENV the MCP server was launched with, then falls back to pytest on PATH. After creating a new environment, restart your MCP client (Claude Desktop, Cursor, ...) from an activated shell so local runs pick it up.\"\n );\n\n logger.debug(`Environment setup plan: recommended=${recommended}, project files=[${projectFiles.join(\", \")}]`);\n\n return {\n working_dir: workingDir,\n package_managers: packageManagers,\n recommended_manager: recommended,\n active_environment: activeEnvironment,\n detected_project_files: projectFiles,\n steps,\n verify_command: verifyCommand,\n notes,\n };\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { runLocalPytest, LocalTestRunResult } from \"../local/runner.js\";\nimport { PassingRunLedger, coversWholeFile, reportsPassedTests } from \"../local/passing-runs.js\";\nimport { detectPackageManagers, installUvNotice } from \"../local/environment-setup.js\";\n\nexport function registerLocalRunTool(server: McpServer, passingRuns: PassingRunLedger): void {\n server.registerTool(\n \"qcentriq_run_local_test\",\n {\n description:\n \"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.\",\n inputSchema: z.object({\n file_path: z.string().describe(\"Path to the local test file to run (e.g. 'tests/test_login.py').\"),\n test_name: z.string().optional().describe(\"Optional specific test function name or expression to run (passed to pytest -k).\"),\n headless: z.boolean().default(true).describe(\"Whether to run the browser in headless mode (default True). Set False to watch the browser execution live.\"),\n browser: z.enum([\"chromium\", \"firefox\", \"webkit\"]).default(\"chromium\").describe(\"Browser engine to execute against (default 'chromium').\"),\n base_url: z.url().optional().describe(\"Target application base URL (e.g. from qcentriq_get_environment). Injected as BASE_URL env var.\"),\n group_id: z.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.\"),\n env_vars: z.record(z.string(), z.string()).optional().describe(\"Environment variables to inject into the local test process.\"),\n extra_args: z.array(z.string()).optional().describe(\"Additional CLI arguments to pass to pytest (e.g. ['-s', '--alluredir=allure-results']).\"),\n timeout_seconds: z.number().int().min(5).max(300).default(60).describe(\"Timeout in seconds for test execution (default 60).\"),\n working_dir: z.string().optional().describe(\"Working directory to run pytest in (defaults to current project directory).\"),\n }),\n },\n async (args) => {\n try {\n const scriptPath = path.resolve(args.working_dir ?? process.cwd(), args.file_path.split(\"::\")[0]);\n // Read before running, so what gets recorded is what pytest was given.\n const content = await fs.readFile(scriptPath, \"utf-8\").catch(() => null);\n const startedAt = Date.now();\n\n const result = await runLocalPytest({\n filePath: args.file_path,\n testName: args.test_name,\n headless: args.headless,\n browser: args.browser,\n baseUrl: args.base_url,\n groupId: args.group_id,\n envVars: args.env_vars,\n extraArgs: args.extra_args,\n timeoutSeconds: args.timeout_seconds,\n workingDir: args.working_dir,\n });\n\n const statusText = result.passed ? \"PASSED\" : \"FAILED\";\n const summary = [\n `Local Test Run Result: ${statusText} (exit code ${result.exitCode})`,\n `Duration: ${(result.durationMs / 1000).toFixed(2)}s`,\n `Command: ${result.command}`,\n \"\",\n \"--- STDOUT ---\",\n result.stdout || \"(no stdout)\",\n \"\",\n \"--- STDERR ---\",\n result.stderr || \"(no stderr)\",\n ];\n\n const next = await nextStep(result, args, content !== null);\n if (next.uploadable && content !== null) {\n passingRuns.record(content, { filePath: scriptPath, dir: path.dirname(scriptPath), startedAt });\n }\n if (next.text) summary.push(\"\", next.text);\n\n return {\n content: [\n {\n type: \"text\",\n text: summary.join(\"\\n\"),\n },\n ],\n isError: !result.passed,\n };\n } catch (err: any) {\n return {\n isError: true,\n content: [\n {\n type: \"text\",\n text: `Error executing local test: ${err.message}`,\n },\n ],\n };\n }\n }\n );\n}\n\n/** Whether this run qualifies the script for upload, and what to tell the agent about it. */\nasync function nextStep(\n result: LocalTestRunResult,\n args: { file_path: string; test_name?: string; extra_args?: string[] },\n scriptReadable: boolean\n): Promise<{ uploadable: boolean; text?: string }> {\n if (result.pytestMissing) {\n const notice = installUvNotice(await detectPackageManagers());\n return {\n uploadable: false,\n text: notice ?? \"pytest is not installed in the Python environment the MCP server runs with. Call qcentriq_get_setup_instructions for the commands that set one up.\",\n };\n }\n if (!result.passed) return { uploadable: false };\n if (!coversWholeFile(args.file_path, args.test_name, args.extra_args)) {\n return { uploadable: false, text: \"Only part of the script ran. Run the whole file, without test_name or test filters, before uploading it with qcentriq_save_group_script.\" };\n }\n if (!scriptReadable) {\n return { uploadable: false, text: \"file_path is not a readable script file, so this pass cannot qualify an upload. Run the single script file you intend to upload.\" };\n }\n if (!reportsPassedTests(result.stdout)) {\n return { uploadable: false, text: \"No test actually passed (all skipped or none collected), so this script cannot be uploaded yet.\" };\n }\n return { uploadable: true, text: \"This exact script passed locally and can now be uploaded with qcentriq_save_group_script.\" };\n}\n","import { spawn, ChildProcess } from \"node:child_process\";\nimport * as path from \"node:path\";\nimport { logger } from \"../utils/logger.js\";\nimport { PYTHON_BIN } from \"./environment-setup.js\";\n\nexport interface LocalTestRunParams {\n filePath: string;\n testName?: string;\n headless?: boolean;\n browser?: \"chromium\" | \"firefox\" | \"webkit\";\n baseUrl?: string;\n groupId?: string;\n envVars?: Record<string, string>;\n extraArgs?: string[];\n timeoutSeconds?: number;\n workingDir?: string;\n}\n\n/**\n * Build the environment pytest runs under.\n *\n * Each variable here has a reader on the Python side: BASE_URL and BROWSER are\n * consumed by the test script, while HEADLESS and QCAQ_TEST_GROUP_ID are read by\n * the QCentriq conftest. Leaving a variable unset is meaningful -- the conftest\n * falls back to the execution container's defaults.\n */\nexport function buildTestEnv(params: LocalTestRunParams): NodeJS.ProcessEnv {\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n ...(params.envVars || {}),\n };\n\n if (params.baseUrl) {\n env.BASE_URL = params.baseUrl;\n }\n if (params.browser) {\n env.BROWSER = params.browser;\n }\n if (params.headless !== undefined) {\n env.HEADLESS = params.headless ? \"true\" : \"false\";\n }\n if (params.groupId) {\n env.QCAQ_TEST_GROUP_ID = params.groupId;\n }\n\n return env;\n}\n\nexport interface LocalTestRunResult {\n passed: boolean;\n exitCode: number;\n stdout: string;\n stderr: string;\n durationMs: number;\n command: string;\n /** pytest could not be started: no Python interpreter, or pytest not installed in it. */\n pytestMissing: boolean;\n}\n\n/**\n * The pytest to launch: the active virtualenv's, else whatever is on PATH.\n */\nexport function resolvePytestCommand(): string {\n const venv = process.env.VIRTUAL_ENV;\n if (!venv) return \"pytest\";\n return process.platform === \"win32\" ? path.join(venv, \"Scripts\", \"pytest.exe\") : path.join(venv, \"bin\", \"pytest\");\n}\n\nfunction killProcessTree(child: ChildProcess): void {\n if (child.pid && process.platform !== \"win32\") {\n try {\n process.kill(-child.pid, \"SIGKILL\");\n return;\n } catch {\n // Process group kill may fail if group leader already died, fall back to killing child directly\n }\n }\n try {\n child.kill(\"SIGKILL\");\n } catch {\n // Process already terminated\n }\n}\n\ntype Attempt =\n | { launched: true; exitCode: number; stdout: string; stderr: string; timedOut: boolean }\n | { launched: false; error: NodeJS.ErrnoException };\n\n/** Run one command to completion or timeout, collecting its output. */\nfunction attempt(cmd: string, args: string[], cwd: string, env: NodeJS.ProcessEnv, timeoutMs: number): Promise<Attempt> {\n return new Promise((resolve) => {\n let stdout = \"\";\n let stderr = \"\";\n let settled = false;\n const settle = (result: Attempt) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n resolve(result);\n };\n\n // Detached on POSIX so the child leads a process group, which a timeout kills as a whole\n const child = spawn(cmd, args, {\n cwd,\n env,\n detached: process.platform !== \"win32\",\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n\n const timer = setTimeout(() => {\n killProcessTree(child);\n settle({ launched: true, exitCode: -1, stdout, stderr, timedOut: true });\n }, timeoutMs);\n\n child.stdout?.on(\"data\", (chunk) => (stdout += chunk.toString()));\n child.stderr?.on(\"data\", (chunk) => (stderr += chunk.toString()));\n child.on(\"error\", (error) => settle({ launched: false, error }));\n child.on(\"close\", (code) => settle({ launched: true, exitCode: code ?? -1, stdout, stderr, timedOut: false }));\n });\n}\n\n/**\n * Execute pytest locally in the user's environment.\n */\nexport async function runLocalPytest(params: LocalTestRunParams): Promise<LocalTestRunResult> {\n const startTime = Date.now();\n const cwd = params.workingDir ? path.resolve(params.workingDir) : process.cwd();\n const timeoutSeconds = params.timeoutSeconds || 60;\n\n const args = [params.filePath];\n if (params.testName) {\n args.push(\"-k\", params.testName);\n }\n if (params.extraArgs) {\n args.push(...params.extraArgs);\n }\n // Always use verbose flag if not present\n if (!args.includes(\"-v\") && !args.includes(\"-vv\")) {\n args.push(\"-v\");\n }\n\n const env = buildTestEnv(params);\n const failure = (stderr: string, command: string, pytestMissing: boolean): LocalTestRunResult => ({\n passed: false,\n exitCode: -1,\n stdout: \"\",\n stderr,\n durationMs: Date.now() - startTime,\n command,\n pytestMissing,\n });\n\n let cmd = resolvePytestCommand();\n let cmdArgs = args;\n logger.info(`Running local test command: ${cmd} ${cmdArgs.join(\" \")} in ${cwd}`);\n let outcome = await attempt(cmd, cmdArgs, cwd, env, timeoutSeconds * 1000);\n\n if (!outcome.launched) {\n if (outcome.error.code !== \"ENOENT\") {\n return failure(`Failed to spawn process: ${outcome.error.message}. Ensure pytest is installed in your Python environment.`, `${cmd} ${cmdArgs.join(\" \")}`, false);\n }\n logger.warn(`pytest binary not found directly, falling back to ${PYTHON_BIN} -m pytest...`);\n const primary = `${cmd} ${cmdArgs.join(\" \")}`;\n cmd = PYTHON_BIN;\n cmdArgs = [\"-m\", \"pytest\", ...args];\n outcome = await attempt(cmd, cmdArgs, cwd, env, timeoutSeconds * 1000);\n if (!outcome.launched) {\n return failure(`Failed to execute pytest or ${PYTHON_BIN} -m pytest: ${outcome.error.message}. Ensure pytest is installed in your Python environment.`, primary, true);\n }\n }\n\n return {\n passed: !outcome.timedOut && outcome.exitCode === 0,\n exitCode: outcome.exitCode,\n stdout: outcome.stdout,\n stderr: outcome.timedOut ? `${outcome.stderr}\\n[TIMEOUT] Test execution timed out after ${timeoutSeconds} seconds.` : outcome.stderr,\n durationMs: Date.now() - startTime,\n command: `${cmd} ${cmdArgs.join(\" \")}`,\n pytestMissing: /No module named pytest/.test(outcome.stderr),\n };\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\nimport { buildEnvironmentSetupPlan } from \"../local/environment-setup.js\";\nimport { logger } from \"../utils/logger.js\";\n\n/** Minimal shape of the backend client, so tests can supply a stub. */\ninterface RuntimeRequirementsSource {\n request(path: string, params?: Record<string, any>): Promise<any>;\n}\n\ninterface RuntimeRequirements {\n packages?: string[];\n playwright_version?: string;\n}\n\n/**\n * Ask the backend which packages the execution container installs.\n *\n * Setup instructions are still useful offline, so a failure here is downgraded\n * to the bundled fallback list rather than failing the tool.\n */\nasync function fetchRuntimeRequirements(\n client: RuntimeRequirementsSource | undefined\n): Promise<RuntimeRequirements> {\n if (!client) return {};\n try {\n const res = await client.request(\"/runtime-requirements\");\n return {\n packages: Array.isArray(res?.packages) ? res.packages : undefined,\n playwright_version: typeof res?.playwright_version === \"string\" ? res.playwright_version : undefined,\n };\n } catch (err: any) {\n logger.warn(`Could not fetch runtime requirements from the backend, using the bundled list: ${err.message}`);\n return {};\n }\n}\n\nexport function registerSetupInstructionsTool(server: McpServer, client?: RuntimeRequirementsSource): void {\n server.registerTool(\n \"qcentriq_get_setup_instructions\",\n {\n description:\n \"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 — it does not create the environment.\",\n inputSchema: z.object({\n preferred_manager: z\n .enum([\"uv\", \"poetry\", \"conda\", \"venv\"])\n .optional()\n .describe(\"Force instructions for a specific package manager. Falls back to the best available one if it is not installed.\"),\n working_dir: z.string().optional().describe(\"Directory to inspect for pyproject.toml / lockfiles / requirements.txt (defaults to the current project directory).\"),\n env_name: z.string().default(\"qcentriq-tests\").describe(\"Name for the created environment (used by conda, default 'qcentriq-tests').\"),\n python_version: z.string().default(\"3.12\").describe(\"Python version to request when creating the environment (default '3.12', matching the QCentriq execution container).\"),\n playwright_version: z.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.\"),\n }),\n annotations: {\n readOnlyHint: true, // Only probes local package managers and project files; never mutates local or remote state.\n destructiveHint: false,\n idempotentHint: false, // Machine state (installed tooling) can change between calls.\n openWorldHint: false, // Fixed set of local package managers, not open-ended.\n },\n },\n async (args) => {\n try {\n const runtime = await fetchRuntimeRequirements(client);\n\n const plan = await buildEnvironmentSetupPlan({\n preferredManager: args.preferred_manager,\n workingDir: args.working_dir,\n envName: args.env_name,\n pythonVersion: args.python_version,\n // An explicitly requested pin wins; otherwise use whatever the\n // project's active execution image is built against.\n playwrightVersion: args.playwright_version ?? runtime.playwright_version,\n packages: runtime.packages,\n });\n\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(plan, null, 2),\n },\n ],\n };\n } catch (err: any) {\n return {\n isError: true,\n content: [\n {\n type: \"text\",\n text: `Error in qcentriq_get_setup_instructions: ${err.message}`,\n },\n ],\n };\n }\n }\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/server\";\nimport { QCentriqApiClient } from \"../client/api.js\";\nimport { QCentriqConfig } from \"../types.js\";\nimport { registerListTestsTool } from \"./list-tests.js\";\nimport { registerGetTestTool } from \"./get-test.js\";\nimport { registerGetTestGroupsTool } from \"./get-groups.js\";\nimport { registerDownloadScriptTool } from \"./download-script.js\";\nimport { registerEnvironmentTool } from \"./environment.js\";\nimport { registerRunLogsTool } from \"./run-logs.js\";\nimport { registerAuthoringGuideTool } from \"./authoring-guide.js\";\nimport { registerCreatePlanTool } from \"./create-plan.js\";\nimport { registerSaveGroupScriptTool } from \"./save-group-script.js\";\nimport { registerLocalRunTool } from \"./local-run.js\";\nimport { registerSaveScriptTool } from \"./save-script.js\";\nimport { registerSetupInstructionsTool } from \"./setup-instructions.js\";\nimport { PassingRunLedger } from \"../local/passing-runs.js\";\nimport { logger } from \"../utils/logger.js\";\n\nexport function registerAllTools(server: McpServer, client: QCentriqApiClient, config: QCentriqConfig): void {\n logger.debug(\"Registering QCentriq MCP tools...\");\n\n // Shared by the local runner, which records scripts that pass, and the\n // script upload, which refuses anything that has not.\n const passingRuns = new PassingRunLedger();\n\n // Remote discovery and diagnostics tools (proxying to backend /api/v1/mcp-client)\n registerListTestsTool(server, client, config);\n registerGetTestTool(server, client, config);\n registerGetTestGroupsTool(server, client, config);\n registerDownloadScriptTool(server, client, config);\n registerEnvironmentTool(server, client, config);\n registerRunLogsTool(server, client, config);\n registerAuthoringGuideTool(server, client);\n\n // Authoring tools. The backend rejects these unless the API key carries\n // 'test:write', which the coarse 'mcp' scope does not grant.\n registerCreatePlanTool(server, client, config);\n registerSaveGroupScriptTool(server, client, config, passingRuns);\n\n // Client-focused local execution tools (run strictly in developer environment)\n registerSaveScriptTool(server);\n registerLocalRunTool(server, passingRuns);\n registerSetupInstructionsTool(server, client);\n\n logger.info(\"Registered QCentriq MCP tools.\");\n}\n\n","import { createRequire } from \"node:module\";\n\n/**\n * The package version, read from package.json at runtime.\n *\n * Both src/ and the bundled dist/ sit one level below the package root, so the\n * same relative path resolves in development and in the published package.\n */\nexport const PACKAGE_VERSION: string = createRequire(import.meta.url)(\"../package.json\").version;\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,MAAM,aAAa,WAAW,MAAM,CAAC;AAE/D,UAAM,UAAU,YAAY;AAC1B,aAAO,KAAK,sCAAsC;AAClD,YAAM,OAAO,MAAM;AACnB,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,YAAQ,GAAG,UAAU,OAAO;AAC5B,YAAQ,GAAG,WAAW,OAAO;AAE7B,WAAO,KAAK,0CAA0C;AAAA,EACxD,SAAS,KAAU;AACjB,WAAO,MAAM,mDAAmD,IAAI,OAAO;AAC3E,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,KAAK;","names":["path","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","fs","path","fs","path","resolve","name","z","z","fs","path","spawn","path","resolve","spawn","z","z","z"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qcentriq/mcp",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Official Model Context Protocol (MCP) server for QCentriq automated test discovery, diagnostics, and execution.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",