@validate.qa/mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,983 @@
1
+ #!/usr/bin/env node
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __esm = (fn, res) => function __init() {
5
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ };
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+
12
+ // src/init.ts
13
+ var init_exports = {};
14
+ __export(init_exports, {
15
+ runInit: () => runInit
16
+ });
17
+ import { existsSync, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
18
+ import { resolve as resolve2, join } from "path";
19
+ function parseInitArgs(argv) {
20
+ const args = {};
21
+ for (let i = 0; i < argv.length; i++) {
22
+ const arg = argv[i];
23
+ if (arg.startsWith("--") && i + 1 < argv.length) {
24
+ args[arg.slice(2)] = argv[++i];
25
+ }
26
+ }
27
+ const apiUrl = args["api-url"] ?? process.env.VALIDATEQA_API_URL ?? "https://shared-server.up.railway.app";
28
+ const token = args["token"] ?? process.env.VALIDATEQA_TOKEN;
29
+ const projectId = args["project-id"] ?? process.env.VALIDATEQA_PROJECT_ID;
30
+ if (!token) {
31
+ console.error("\u274C Missing --token. Copy the full command from your Validate.QA dashboard.");
32
+ process.exit(1);
33
+ }
34
+ if (!projectId) {
35
+ console.error("\u274C Missing --project-id. Copy the full command from your Validate.QA dashboard.");
36
+ process.exit(1);
37
+ }
38
+ return { apiUrl: apiUrl.replace(/\/$/, ""), token, projectId };
39
+ }
40
+ function buildMcpEntry(config2) {
41
+ return {
42
+ command: "npx",
43
+ args: [
44
+ "-y",
45
+ "@validate.qa/mcp@latest",
46
+ "--api-url",
47
+ config2.apiUrl,
48
+ "--token",
49
+ config2.token,
50
+ "--project-id",
51
+ config2.projectId
52
+ ]
53
+ };
54
+ }
55
+ function writeConfigForIDE(cwd, target, entry) {
56
+ const dir = resolve2(cwd, target.configDir);
57
+ const filePath = resolve2(dir, target.configFile);
58
+ if (target.configDir !== "." && !existsSync(dir)) {
59
+ return "skipped";
60
+ }
61
+ let existing = {};
62
+ if (existsSync(filePath)) {
63
+ try {
64
+ existing = JSON.parse(readFileSync2(filePath, "utf-8"));
65
+ } catch {
66
+ }
67
+ }
68
+ const servers = existing[target.serversKey] ?? {};
69
+ const hadEntry = "validate.qa" in servers;
70
+ servers["validate.qa"] = entry;
71
+ existing[target.serversKey] = servers;
72
+ if (!existsSync(dir)) {
73
+ mkdirSync(dir, { recursive: true });
74
+ }
75
+ writeFileSync(filePath, JSON.stringify(existing, null, 2) + "\n", "utf-8");
76
+ return hadEntry ? "updated" : "created";
77
+ }
78
+ function runInit() {
79
+ const config2 = parseInitArgs(process.argv.slice(3));
80
+ const entry = buildMcpEntry(config2);
81
+ const cwd = process.cwd();
82
+ console.log("");
83
+ console.log(" Validate.QA \u2014 MCP Setup");
84
+ console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
85
+ console.log("");
86
+ let anyWritten = false;
87
+ for (const target of IDE_TARGETS) {
88
+ const result = writeConfigForIDE(cwd, target, entry);
89
+ if (result === "skipped") {
90
+ continue;
91
+ }
92
+ const file = join(target.configDir, target.configFile);
93
+ if (result === "created") {
94
+ console.log(` \u2713 ${target.name} \u2014 created ${file}`);
95
+ } else {
96
+ console.log(` \u2713 ${target.name} \u2014 updated ${file}`);
97
+ }
98
+ anyWritten = true;
99
+ }
100
+ if (!anyWritten) {
101
+ const target = IDE_TARGETS[0];
102
+ writeConfigForIDE(cwd, target, entry);
103
+ console.log(` \u2713 Created ${target.configFile} (works with Claude Code)`);
104
+ console.log("");
105
+ console.log(" Tip: Create a .cursor/ or .windsurf/ directory and re-run to set up those IDEs too.");
106
+ }
107
+ console.log("");
108
+ console.log(" Next: restart your IDE or reload MCP servers.");
109
+ console.log(' Then ask your AI: "list my tests" to verify it works.');
110
+ console.log("");
111
+ }
112
+ var IDE_TARGETS;
113
+ var init_init = __esm({
114
+ "src/init.ts"() {
115
+ "use strict";
116
+ IDE_TARGETS = [
117
+ { name: "Claude Code", configDir: ".", configFile: ".mcp.json", serversKey: "mcpServers" },
118
+ { name: "Cursor", configDir: ".cursor", configFile: "mcp.json", serversKey: "mcpServers" },
119
+ { name: "Windsurf", configDir: ".windsurf", configFile: "mcp.json", serversKey: "mcpServers" },
120
+ { name: "VS Code", configDir: ".vscode", configFile: "mcp.json", serversKey: "servers" }
121
+ ];
122
+ }
123
+ });
124
+
125
+ // src/index.ts
126
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
127
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
128
+
129
+ // src/config.ts
130
+ import { readFileSync } from "fs";
131
+ import { resolve } from "path";
132
+ function parseArgs(argv) {
133
+ const args = {};
134
+ for (let i = 0; i < argv.length; i++) {
135
+ const arg = argv[i];
136
+ if (arg.startsWith("--") && i + 1 < argv.length) {
137
+ const key = arg.slice(2);
138
+ args[key] = argv[++i];
139
+ }
140
+ }
141
+ return args;
142
+ }
143
+ function loadDotFile() {
144
+ try {
145
+ const content = readFileSync(resolve(process.cwd(), ".validateqa.json"), "utf-8");
146
+ const json = JSON.parse(content);
147
+ return {
148
+ apiUrl: typeof json.apiUrl === "string" ? json.apiUrl : void 0,
149
+ projectId: typeof json.projectId === "string" ? json.projectId : void 0
150
+ };
151
+ } catch {
152
+ return {};
153
+ }
154
+ }
155
+ function resolveConfig() {
156
+ const cliArgs = parseArgs(process.argv.slice(2));
157
+ const dotFile = loadDotFile();
158
+ const apiUrl = cliArgs["api-url"] ?? process.env.VALIDATEQA_API_URL ?? dotFile.apiUrl;
159
+ const token = cliArgs["token"] ?? process.env.VALIDATEQA_TOKEN;
160
+ const projectId = cliArgs["project-id"] ?? process.env.VALIDATEQA_PROJECT_ID ?? dotFile.projectId;
161
+ if (!apiUrl) {
162
+ console.error("Missing required config: api-url (--api-url, VALIDATEQA_API_URL, or .validateqa.json)");
163
+ process.exit(1);
164
+ }
165
+ if (!token) {
166
+ console.error("Missing required config: token (--token or VALIDATEQA_TOKEN)");
167
+ process.exit(1);
168
+ }
169
+ if (!projectId) {
170
+ console.error("Missing required config: project-id (--project-id, VALIDATEQA_PROJECT_ID, or .validateqa.json)");
171
+ process.exit(1);
172
+ }
173
+ return { apiUrl: apiUrl.replace(/\/$/, ""), token, projectId };
174
+ }
175
+
176
+ // src/api-client.ts
177
+ var ValidateQAClient = class {
178
+ constructor(baseUrl, token, projectId) {
179
+ this.baseUrl = baseUrl;
180
+ this.token = token;
181
+ this.projectId = projectId;
182
+ }
183
+ async executeTool(tool2, args = {}) {
184
+ let res;
185
+ try {
186
+ res = await fetch(`${this.baseUrl}/api/mcp/execute`, {
187
+ method: "POST",
188
+ headers: {
189
+ "Authorization": `Bearer ${this.token}`,
190
+ "X-Project-Id": this.projectId,
191
+ "Content-Type": "application/json"
192
+ },
193
+ body: JSON.stringify({ tool: tool2, args }),
194
+ signal: AbortSignal.timeout(12e4)
195
+ });
196
+ } catch (err) {
197
+ const cause = err instanceof Error && err.cause instanceof Error ? err.cause.message : "";
198
+ const msg = err instanceof Error ? err.message : String(err);
199
+ throw new Error(`Connection failed: ${msg}${cause ? ` (${cause})` : ""}`);
200
+ }
201
+ if (!res.ok) {
202
+ const body = await res.json().catch(() => ({ error: res.statusText }));
203
+ throw new Error(body.error || `API error ${res.status}`);
204
+ }
205
+ return res.json();
206
+ }
207
+ async healthCheck() {
208
+ try {
209
+ const res = await fetch(`${this.baseUrl}/health`, {
210
+ signal: AbortSignal.timeout(5e3)
211
+ });
212
+ return res.ok;
213
+ } catch {
214
+ return false;
215
+ }
216
+ }
217
+ };
218
+
219
+ // src/tools/index.ts
220
+ import { z } from "zod";
221
+ function tool(server2, client2, name, description, schema, annotations) {
222
+ const handler = async (args) => {
223
+ try {
224
+ const result = await client2.executeTool(name, args);
225
+ return {
226
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
227
+ };
228
+ } catch (err) {
229
+ return {
230
+ content: [{ type: "text", text: `Error: ${err instanceof Error ? err.message : String(err)}` }],
231
+ isError: true
232
+ };
233
+ }
234
+ };
235
+ if (annotations) {
236
+ server2.tool(name, description, schema, annotations, handler);
237
+ } else {
238
+ server2.tool(name, description, schema, handler);
239
+ }
240
+ }
241
+ function registerAllTools(server2, client2) {
242
+ tool(
243
+ server2,
244
+ client2,
245
+ "list_tests",
246
+ "List tests in the current project. Returns test name, status, suite, tags, confidence, and the last run result. Paginated \u2014 use limit/offset to page through all tests.",
247
+ {
248
+ status: z.enum(["DRAFT", "ACTIVE", "DISABLED", "QUARANTINED"]).optional().describe("Filter by test lifecycle status"),
249
+ suite: z.string().optional().describe("Filter by suite name"),
250
+ search: z.string().optional().describe("Search test names (case-insensitive substring match)"),
251
+ tag: z.string().optional().describe("Filter by tag (e.g. @regression, @smoke, @auth)"),
252
+ limit: z.number().optional().describe("Max results to return (default: 50, max: 200)"),
253
+ offset: z.number().optional().describe("Number of results to skip for pagination (default: 0)")
254
+ },
255
+ { readOnlyHint: true }
256
+ );
257
+ tool(
258
+ server2,
259
+ client2,
260
+ "get_test",
261
+ "Get details of a specific test: name, status, tags, steps, session, and the 5 most recent run results. Code is truncated to 200 lines \u2014 use get_test_code for the full Playwright code.",
262
+ { testId: z.string().describe("The test case ID") },
263
+ { readOnlyHint: true }
264
+ );
265
+ tool(
266
+ server2,
267
+ client2,
268
+ "run_test",
269
+ "Queue a test for execution. Creates a PENDING test run that will be picked up by an online runner. Returns the run ID.",
270
+ { testId: z.string().describe("The test case ID to run") }
271
+ );
272
+ tool(
273
+ server2,
274
+ client2,
275
+ "delete_test",
276
+ "Permanently delete a test case and all its run history. Cannot be undone.",
277
+ { testId: z.string().describe("The test case ID to delete") },
278
+ { destructiveHint: true }
279
+ );
280
+ tool(
281
+ server2,
282
+ client2,
283
+ "heal_test",
284
+ "Queue an AI healing run for a failing test. The AI agent replays the test in a real browser, analyzes the failure, and either fixes the Playwright code OR detects an application bug (quarantines the test with @bug-found if the app itself is broken, not the test).",
285
+ { testId: z.string().describe("The failing test case ID") }
286
+ );
287
+ tool(
288
+ server2,
289
+ client2,
290
+ "edit_test_code",
291
+ "Update the Playwright code, name, or tags of an existing test case. Read project://test-conventions for patterns and pitfalls. Code is validated \u2014 fix any warnings returned.",
292
+ {
293
+ testId: z.string().describe("The test case ID to edit"),
294
+ playwrightCode: z.string().optional().describe("New Playwright test code (full file replacement)"),
295
+ name: z.string().optional().describe("New test name"),
296
+ tags: z.array(z.string()).optional().describe('New tags array (e.g. ["@regression", "@smoke"])')
297
+ }
298
+ );
299
+ tool(
300
+ server2,
301
+ client2,
302
+ "update_test_status",
303
+ "Change the lifecycle status of one or more tests (e.g. promote DRAFT\u2192ACTIVE, disable a flaky test).",
304
+ {
305
+ testIds: z.array(z.string()).describe("Test IDs to update"),
306
+ status: z.enum(["DRAFT", "ACTIVE", "DISABLED", "QUARANTINED"]).describe("New status to set")
307
+ }
308
+ );
309
+ tool(
310
+ server2,
311
+ client2,
312
+ "get_test_run",
313
+ "Get the status and result of a specific test run, including error details if it failed. Can look up by runId or get the latest run for a testId.",
314
+ {
315
+ runId: z.string().optional().describe("The test run ID"),
316
+ testId: z.string().optional().describe("Get the most recent run for this test case ID")
317
+ },
318
+ { readOnlyHint: true }
319
+ );
320
+ server2.tool(
321
+ "get_test_screenshots",
322
+ "Get screenshots from a specific test run as images the AI can actually see. Use this to visually inspect what happened during a failed or passing run.",
323
+ {
324
+ runId: z.string().describe("The test run ID to fetch screenshots from"),
325
+ limit: z.number().optional().describe("Max screenshots to return (default: 5, max: 10)")
326
+ },
327
+ { readOnlyHint: true },
328
+ async (args) => {
329
+ try {
330
+ const result = await client2.executeTool("get_test_screenshots", args);
331
+ if (!result.screenshots || result.screenshots.length === 0) {
332
+ return {
333
+ content: [{
334
+ type: "text",
335
+ text: `No screenshots available for run ${result.runId} (status: ${result.status})`
336
+ }]
337
+ };
338
+ }
339
+ const content = [
340
+ {
341
+ type: "text",
342
+ text: `Run ${result.runId} \u2014 status: ${result.status} \u2014 showing ${result.returned} of ${result.total} screenshot(s)`
343
+ }
344
+ ];
345
+ for (const shot of result.screenshots) {
346
+ content.push({ type: "image", data: shot.data, mimeType: shot.mimeType });
347
+ }
348
+ return { content };
349
+ } catch (err) {
350
+ return {
351
+ content: [{ type: "text", text: `Error: ${err instanceof Error ? err.message : String(err)}` }],
352
+ isError: true
353
+ };
354
+ }
355
+ }
356
+ );
357
+ tool(
358
+ server2,
359
+ client2,
360
+ "cancel_test_run",
361
+ "Cancel a pending or running test run. Can cancel by run ID or cancel the latest running batch.",
362
+ {
363
+ runId: z.string().optional().describe("The specific test run ID to cancel"),
364
+ cancelBatch: z.boolean().optional().describe("If true, cancel the latest batch run instead")
365
+ }
366
+ );
367
+ tool(
368
+ server2,
369
+ client2,
370
+ "batch_run_tests",
371
+ "Run multiple tests from the database individually. Filter by test IDs or suite name; omit both to run all ACTIVE tests. Each test executes in its own browser.",
372
+ {
373
+ testIds: z.array(z.string()).optional().describe("Specific test IDs to run"),
374
+ suite: z.string().optional().describe("Run all active tests in this suite")
375
+ }
376
+ );
377
+ tool(
378
+ server2,
379
+ client2,
380
+ "list_features",
381
+ "List all features with test counts and failure counts (last 24h). Use failingTests > 0 to identify which features need attention, then call get_test_failures({ suite: featureName }) to drill into the full error details for that feature.",
382
+ {},
383
+ { readOnlyHint: true }
384
+ );
385
+ tool(
386
+ server2,
387
+ client2,
388
+ "list_api_endpoints",
389
+ "List captured API endpoints for the current project. Optionally scope to a specific feature name.",
390
+ {
391
+ featureName: z.string().optional().describe("Optional feature name to scope the endpoint list")
392
+ },
393
+ { readOnlyHint: true }
394
+ );
395
+ tool(
396
+ server2,
397
+ client2,
398
+ "get_runner_health",
399
+ "Check whether the project's configured runners are online, including available device capabilities.",
400
+ {},
401
+ { readOnlyHint: true }
402
+ );
403
+ tool(
404
+ server2,
405
+ client2,
406
+ "get_project_overview",
407
+ "Get a workspace-level QA overview: test counts, pass rates, runner readiness, features, coverage gaps, variables, schedules, and notifications.",
408
+ {},
409
+ { readOnlyHint: true }
410
+ );
411
+ tool(
412
+ server2,
413
+ client2,
414
+ "get_reports_summary",
415
+ "Get a high-level report: total tests (active, never-run), 7-day pass rate, today's run count, and the 10 most recent test run results.",
416
+ {},
417
+ { readOnlyHint: true }
418
+ );
419
+ tool(
420
+ server2,
421
+ client2,
422
+ "list_schedules",
423
+ "List all scheduled test runs in the project.",
424
+ {},
425
+ { readOnlyHint: true }
426
+ );
427
+ tool(
428
+ server2,
429
+ client2,
430
+ "create_schedule",
431
+ "Create a new recurring test schedule. Runs all matching tests from the database on the configured interval.",
432
+ {
433
+ name: z.string().describe('Name for the schedule (e.g. "Nightly smoke tests")'),
434
+ mode: z.enum(["batch"]).describe("Run mode: batch (runs project tests from the database)"),
435
+ intervalMinutes: z.union([z.literal(60), z.literal(360), z.literal(720), z.literal(1440), z.literal(2880), z.literal(10080)]).describe("Interval in minutes: 60 (hourly), 360 (6h), 720 (12h), 1440 (daily), 2880 (2 days), 10080 (weekly)"),
436
+ tags: z.array(z.string()).optional().describe('Tags to filter which tests run (e.g. ["@smoke"]). Omit to run all ACTIVE tests.'),
437
+ autoHeal: z.boolean().optional().describe("Automatically heal failing tests after each run"),
438
+ enabled: z.boolean().optional().describe("Whether the schedule is active (default: true)"),
439
+ runImmediately: z.boolean().optional().describe("Whether to trigger the first run immediately (default: true)")
440
+ }
441
+ );
442
+ tool(
443
+ server2,
444
+ client2,
445
+ "update_schedule",
446
+ "Update an existing test schedule.",
447
+ {
448
+ scheduleId: z.string().describe("The schedule ID to update"),
449
+ name: z.string().optional().describe("New name for the schedule"),
450
+ intervalMinutes: z.union([z.literal(60), z.literal(360), z.literal(720), z.literal(1440), z.literal(2880), z.literal(10080)]).optional().describe("New interval in minutes"),
451
+ suite: z.string().optional().describe("New suite name to filter tests"),
452
+ tags: z.array(z.string()).optional().describe("New tag filter"),
453
+ autoHeal: z.boolean().optional().describe("Toggle auto-heal"),
454
+ enabled: z.boolean().optional().describe("Enable or disable the schedule")
455
+ }
456
+ );
457
+ tool(
458
+ server2,
459
+ client2,
460
+ "delete_schedule",
461
+ "Delete (remove) a test schedule permanently.",
462
+ { scheduleId: z.string().describe("The schedule ID to delete") },
463
+ { destructiveHint: true }
464
+ );
465
+ tool(
466
+ server2,
467
+ client2,
468
+ "run_schedule_now",
469
+ "Trigger a scheduled run immediately instead of waiting for the next scheduled time.",
470
+ { scheduleId: z.string().describe("The schedule ID to trigger") }
471
+ );
472
+ tool(
473
+ server2,
474
+ client2,
475
+ "get_variables",
476
+ "Get all test variables (environment variables) for the current project. Secrets are redacted.",
477
+ {},
478
+ { readOnlyHint: true }
479
+ );
480
+ tool(
481
+ server2,
482
+ client2,
483
+ "set_variable",
484
+ "Set or update a test variable (environment variable) for the project. Used to configure base URLs, credentials, etc.",
485
+ {
486
+ key: z.string().describe("Variable name (e.g. BASE_URL, TEST_USER_EMAIL, API_KEY)"),
487
+ value: z.string().describe("Variable value. Set value to empty string to remove a variable."),
488
+ secret: z.boolean().optional().describe("Whether this variable is a secret (will be redacted in UI)")
489
+ }
490
+ );
491
+ tool(
492
+ server2,
493
+ client2,
494
+ "create_test",
495
+ "Create a new test case with Playwright code. Read project://test-conventions for templates and pitfalls BEFORE writing code. The test starts as DRAFT \u2014 auto-runs and auto-promotes to ACTIVE on pass. IMPORTANT: (1) Set suite to the EXACT feature name. (2) After creating all tests for a feature, you MUST call add_api_endpoints.",
496
+ {
497
+ name: z.string().describe('Test name (e.g. "Login \u2014 Happy Path")'),
498
+ playwrightCode: z.string().describe("Full Playwright test code"),
499
+ suite: z.string().optional().describe('MUST match an existing feature name exactly to link the test to that feature (e.g. "Authentication", not "Auth Tests")'),
500
+ tags: z.array(z.string()).optional().describe('Tags (e.g. ["@smoke", "@auth"])')
501
+ }
502
+ );
503
+ tool(
504
+ server2,
505
+ client2,
506
+ "get_feature",
507
+ "Get detailed info about a feature including its pages, test plans, existing tests with lastRunStatus, and AI insights.",
508
+ { featureName: z.string().describe("The feature name (case-insensitive match)") },
509
+ { readOnlyHint: true }
510
+ );
511
+ tool(
512
+ server2,
513
+ client2,
514
+ "create_feature",
515
+ "Create a new feature with page routes. Read the developer's route files to provide accurate page URLs. Pages are used for coverage tracking and site map.",
516
+ {
517
+ name: z.string().describe('Feature name (e.g. "Checkout Flow")'),
518
+ description: z.string().optional().describe("What the feature does and what to test"),
519
+ pages: z.array(z.string()).describe('Page routes this feature covers (e.g. ["/checkout", "/checkout/payment"]). Required for test generation.'),
520
+ criticality: z.enum(["critical", "high", "medium", "low"]).optional().describe("Feature criticality level (default: medium)")
521
+ }
522
+ );
523
+ tool(
524
+ server2,
525
+ client2,
526
+ "get_test_code",
527
+ "Get the full (untruncated) Playwright test code for a test case. Use this when you need to read, analyze, or prepare edits for the complete test code.",
528
+ { testId: z.string().describe("The test case ID") },
529
+ { readOnlyHint: true }
530
+ );
531
+ tool(
532
+ server2,
533
+ client2,
534
+ "set_runner_preference",
535
+ "Switch between cloud and local runner for test execution.",
536
+ { preference: z.enum(["cloud", "local"]).describe("Runner type: cloud (shared infrastructure) or local (runs on your machine)") }
537
+ );
538
+ tool(
539
+ server2,
540
+ client2,
541
+ "toggle_auto_heal",
542
+ "Enable or disable automatic AI healing when tests fail in batch or suite runs.",
543
+ { enabled: z.boolean().describe("true to enable auto-heal, false to disable") }
544
+ );
545
+ tool(
546
+ server2,
547
+ client2,
548
+ "list_test_data",
549
+ "List all test data sets in the project. Each set contains key-value pairs injected into AI prompts and test runs.",
550
+ {},
551
+ { readOnlyHint: true }
552
+ );
553
+ tool(
554
+ server2,
555
+ client2,
556
+ "create_test_data",
557
+ "Create a new test data set with key-value pairs. Max 200 entries per set.",
558
+ {
559
+ name: z.string().describe("Name of the test data set (max 100 chars)"),
560
+ description: z.string().optional().describe("Optional description (max 1000 chars)"),
561
+ data: z.record(z.string()).describe('Key-value pairs (e.g. {"email": "test@example.com", "password": "secret"})')
562
+ }
563
+ );
564
+ tool(
565
+ server2,
566
+ client2,
567
+ "delete_test_data",
568
+ "Delete a test data set by ID.",
569
+ { dataSetId: z.string().describe("The test data set ID to delete") },
570
+ { destructiveHint: true }
571
+ );
572
+ tool(
573
+ server2,
574
+ client2,
575
+ "update_feature",
576
+ "Update a feature's name, description, pages, or criticality.",
577
+ {
578
+ featureId: z.string().describe("The feature ID to update"),
579
+ name: z.string().optional().describe("New feature name"),
580
+ description: z.string().optional().describe("New description"),
581
+ pages: z.array(z.string()).optional().describe("Updated page routes"),
582
+ criticality: z.enum(["critical", "high", "medium", "low"]).optional().describe("Feature criticality level")
583
+ }
584
+ );
585
+ tool(
586
+ server2,
587
+ client2,
588
+ "archive_feature",
589
+ "Archive a feature (soft delete). Archived features are hidden from the dashboard but can be restored.",
590
+ { featureId: z.string().describe("The feature ID to archive") },
591
+ { destructiveHint: true }
592
+ );
593
+ tool(
594
+ server2,
595
+ client2,
596
+ "get_site_map_coverage",
597
+ "Get site map coverage statistics: total pages, pages with tests, elements covered, coverage percentage, and per-page breakdown.",
598
+ {},
599
+ { readOnlyHint: true }
600
+ );
601
+ tool(
602
+ server2,
603
+ client2,
604
+ "list_bugs",
605
+ "Get all detected bugs: app bugs (quarantined tests with @bug-found), security findings, and flaky tests.",
606
+ {},
607
+ { readOnlyHint: true }
608
+ );
609
+ tool(
610
+ server2,
611
+ client2,
612
+ "flag_as_bug",
613
+ "Mark a failing test as a confirmed application bug \u2014 quarantines it with @bug-found and records the bug description. Use when the failure is caused by broken app behaviour, NOT a test script issue. Do NOT use for selector changes or timeout failures \u2014 use heal_test or edit_test_code for those.",
614
+ {
615
+ testId: z.string().describe("The failing test case ID"),
616
+ description: z.string().describe('What is broken in the application (e.g. "POST /api/checkout returns 500 when payment method is valid")')
617
+ }
618
+ );
619
+ tool(
620
+ server2,
621
+ client2,
622
+ "run_security_audit",
623
+ 'Run an AI security audit on captured API traffic. Requires prior browser-based test execution (discovery or capture) \u2014 analyzes real network traffic, not just registered endpoints. If no traffic exists, the developer can trigger "Security Audit" from the Dashboard which launches a live browser to capture it.',
624
+ {}
625
+ );
626
+ tool(
627
+ server2,
628
+ client2,
629
+ "list_security_findings",
630
+ "List security audit findings with optional filters. Returns severity, category, status, and affected endpoints.",
631
+ {
632
+ severity: z.enum(["critical", "high", "medium", "low", "info"]).optional().describe("Filter by severity"),
633
+ status: z.enum(["open", "acknowledged", "resolved", "false-positive"]).optional().describe("Filter by status")
634
+ },
635
+ { readOnlyHint: true }
636
+ );
637
+ tool(
638
+ server2,
639
+ client2,
640
+ "set_app_brief",
641
+ "Set or update the project's application brief \u2014 a description of the app used by AI for better test generation.",
642
+ { appBrief: z.string().describe("Application description. Set empty to clear.") }
643
+ );
644
+ tool(
645
+ server2,
646
+ client2,
647
+ "get_coverage_summary",
648
+ "Get feature-level test coverage: planned vs existing vs passing tests, plus API endpoint coverage. Shows uncoveredEndpoints per feature \u2014 use this to find which API endpoints still need tests.",
649
+ {},
650
+ { readOnlyHint: true }
651
+ );
652
+ tool(
653
+ server2,
654
+ client2,
655
+ "run_draft_tests",
656
+ "Run all DRAFT tests to verify them. Tests that pass auto-promote to ACTIVE. Optionally scope to a feature.",
657
+ {
658
+ featureName: z.string().optional().describe("Only run drafts for this feature (optional)")
659
+ }
660
+ );
661
+ tool(
662
+ server2,
663
+ client2,
664
+ "setup_project",
665
+ 'One-shot project setup from codebase knowledge. Sets app brief, base URL, test credentials, and creates features with pages \u2014 all in one call. Use this when a developer says "set up test coverage for my app."',
666
+ {
667
+ appBrief: z.string().optional().describe("Description of the application (what it does, key features, tech stack)"),
668
+ baseUrl: z.string().describe('Application base URL (e.g. "https://myapp.com" or "http://localhost:3000")'),
669
+ testCredentials: z.object({
670
+ email: z.string().optional().describe("Test user email"),
671
+ password: z.string().optional().describe("Test user password")
672
+ }).optional().describe("Login credentials for test execution"),
673
+ features: z.array(z.object({
674
+ name: z.string().describe("Feature name"),
675
+ description: z.string().optional().describe("What the feature does"),
676
+ pages: z.array(z.string()).describe('Page routes (e.g. ["/login", "/register"])'),
677
+ criticality: z.enum(["critical", "high", "medium", "low"]).optional().describe("Feature criticality")
678
+ })).describe("Features to create with their page routes")
679
+ }
680
+ );
681
+ tool(
682
+ server2,
683
+ client2,
684
+ "add_api_endpoints",
685
+ "Register API endpoints for a feature from codebase knowledge. Read the developer's route handlers to extract methods, paths, request/response shapes. Populates the API intelligence dashboard.",
686
+ {
687
+ featureName: z.string().describe("Feature name to link these endpoints to"),
688
+ endpoints: z.array(z.object({
689
+ method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).describe("HTTP method"),
690
+ path: z.string().describe('API path (e.g. "/api/auth/login")'),
691
+ requestShape: z.record(z.string()).optional().describe('Request body fields with types (e.g. { "email": "string" })'),
692
+ responseShapes: z.record(z.record(z.string())).optional().describe('Response shapes by status code (e.g. { "200": { "token": "string" } })'),
693
+ requiresAuth: z.boolean().optional().describe("Whether endpoint requires authentication")
694
+ })).describe("API endpoints to register")
695
+ }
696
+ );
697
+ tool(
698
+ server2,
699
+ client2,
700
+ "get_test_failures",
701
+ "Get recent test failures with full error messages, Playwright code, step-level failures, and heal context. Use this to understand why tests are failing.",
702
+ {
703
+ limit: z.number().optional().describe("Max failures to return (default: 50, max: 100)"),
704
+ suite: z.string().optional().describe("Filter by feature/suite name"),
705
+ mode: z.enum(["run", "heal", "all"]).optional().describe("run = regular failures, heal = heal attempt failures, all = both (default)"),
706
+ sinceHours: z.number().optional().describe("Only failures from the last N hours (default: 24)")
707
+ },
708
+ { readOnlyHint: true }
709
+ );
710
+ }
711
+
712
+ // src/index.ts
713
+ if (process.argv[2] === "init") {
714
+ const { runInit: runInit2 } = await Promise.resolve().then(() => (init_init(), init_exports));
715
+ runInit2();
716
+ process.exit(0);
717
+ }
718
+ var config = resolveConfig();
719
+ var client = new ValidateQAClient(config.apiUrl, config.token, config.projectId);
720
+ var server = new McpServer(
721
+ { name: "validate.qa", version: "1.0.0" },
722
+ { instructions: `Validate.QA \u2014 AI-powered QA platform: generates, runs, and heals Playwright E2E tests.
723
+
724
+ ## Capabilities
725
+ - Setup projects via setup_project (read source code first)
726
+ - Write tests via create_test (read routes, components, API handlers first)
727
+ - Manage tests: list, view, edit, run, delete (DRAFT/ACTIVE/DISABLED/QUARANTINED)
728
+ - Heal failing tests: AI replays in browser, fixes code or flags app bugs
729
+ - Schedule recurring runs (hourly-weekly) with auto-heal
730
+
731
+ ## Workflows
732
+ 1. New project: READ source, setup_project (features, baseUrl, testCredentials, appBrief). Per feature: READ code, create_test, add_api_endpoints.
733
+ 2. Check health: list_features (failingTests > 0), get_test_failures per feature, edit_test_code or heal_test.
734
+ 3. Add coverage: READ code, create_feature, create_test x N (suite = feature name), add_api_endpoints.
735
+ 4. Nightly automation: create_schedule (daily, autoHeal: true).
736
+ 5. After code change: batch_run_tests, then list_features + get_test_failures.
737
+
738
+ ## Automatic lifecycle
739
+ Do NOT call run_test after create_test (auto-queued) or heal_test after failures (auto-heals).
740
+ Do NOT check run status in a loop \u2014 call get_test_failures after a reasonable wait to see what failed.
741
+ Lifecycle: create > auto-run > pass=ACTIVE, fail=auto-heal > heal fail=@needs-review.
742
+ DO call add_api_endpoints per feature (not automatic).
743
+ DO call run_security_audit after UI tests to analyze captured API traffic. If it errors about missing data, tell the developer to click "Security Audit" in the Dashboard to run a live browser capture first. Use list_security_findings to review results.
744
+
745
+ ## Rate limits
746
+ 50 calls/60s. Reads parallel OK, writes sequential. On 429, wait 30-60s.
747
+
748
+ ## Triaging failures
749
+ - App broken: flag_as_bug(testId, description). Selector/timing: heal_test. Bad test logic: edit_test_code.
750
+ - Unsure: heal_test first \u2014 it detects app bugs automatically.
751
+
752
+ ## Using the codebase
753
+ You have full source code access. Always READ before writing: routes for URLs, components for selectors, API handlers for endpoints.
754
+
755
+ ## Before writing any test \u2014 preflight check
756
+
757
+ Read project://test-conventions first. Check the variables section:
758
+ - BASE_URL must be set (the runner needs it). If missing, call setup_project or set_variable.
759
+ - TEST_USER_EMAIL and TEST_USER_PASSWORD must be set if tests require login. If missing, ask the developer for credentials and call set_variable.
760
+ - If starting fresh (no features, no variables), use workflow #1 (setup_project) before anything else.
761
+
762
+ ## Critical rules \u2014 see project://test-conventions for full details and code templates
763
+ - URLs: relative only, never hardcoded domains \u2014 runner sets baseURL
764
+ - Credentials: process.env.TEST_USER_EMAIL! (non-null assertion) \u2014 never ?? or || fallbacks
765
+ - Registration: testuser-\${Date.now()}@example.com
766
+ - Suite name must match feature name exactly (case-sensitive)
767
+ - @auth must NOT combine with @smoke/@regression/@needs-auth/@critical
768
+ - Each test = own browser process; @needs-auth tests MUST login inline
769
+ - API tests: test.describe.serial() with __QA_HTTP__ log after every request
770
+ - UI tests: console.log() milestones after key actions
771
+ - create_test/edit_test_code validate code \u2014 fix warnings before moving on
772
+
773
+ ## Setting up coverage
774
+ 1. SCAN: Read router, nav, pages, API handlers \u2014 map ALL routes and features.
775
+ 2. SETUP: setup_project with features, pages, baseUrl, testCredentials, appBrief.
776
+ 3. WRITE: One feature at a time. For EACH test, read the SPECIFIC source code first (see codeReadingRequirements in test-conventions). For login blocks: read the login component. For UI tests: read the page component. For API tests: read the route handler. Templates are structure guides \u2014 selectors MUST come from the real code. Use create_test for BOTH UI and API tests. Then call add_api_endpoints.
777
+ 4. VERIFY: get_coverage_summary + list_features for failures + get_test_failures.
778
+
779
+ Test real user flows (forms, validation, errors). "Page loads" tests are worthless.` }
780
+ );
781
+ registerAllTools(server, client);
782
+ server.resource(
783
+ "Project Overview",
784
+ "project://overview",
785
+ { description: "Live project state: test counts, pass rates, runner status, features, coverage gaps, and configuration. Read this first to understand the current project." },
786
+ async () => {
787
+ try {
788
+ const [overview, coverage, stats] = await Promise.all([
789
+ client.executeTool("get_project_overview"),
790
+ client.executeTool("get_coverage_summary").catch(() => null),
791
+ client.executeTool("get_regression_stats").catch(() => null)
792
+ ]);
793
+ const snapshot = {
794
+ overview,
795
+ coverage,
796
+ regressionStats: stats,
797
+ retrievedAt: (/* @__PURE__ */ new Date()).toISOString()
798
+ };
799
+ return { contents: [{ uri: "project://overview", mimeType: "application/json", text: JSON.stringify(snapshot, null, 2) }] };
800
+ } catch (err) {
801
+ return { contents: [{ uri: "project://overview", mimeType: "text/plain", text: `Failed to load project overview: ${err instanceof Error ? err.message : String(err)}` }] };
802
+ }
803
+ }
804
+ );
805
+ server.resource(
806
+ "Test Conventions",
807
+ "project://test-conventions",
808
+ { description: "Project-specific test conventions: environment variables, credential patterns, tag meanings, and registration email rules. Read this before writing or editing any test." },
809
+ async () => {
810
+ try {
811
+ const vars = await client.executeTool("get_variables");
812
+ const varNames = Object.keys(vars.variables || {});
813
+ const hasAuth = varNames.includes("TEST_USER_EMAIL") && varNames.includes("TEST_USER_PASSWORD");
814
+ const conventions = {
815
+ codeReadingRequirements: {
816
+ CRITICAL: "Templates below are STRUCTURE GUIDES \u2014 every selector, route, and endpoint MUST come from reading the actual source code. Never copy a template verbatim.",
817
+ forLogin: "BEFORE writing any @needs-auth login block: READ the login/auth page component. Find: (1) the login route (/login, /auth/login, /signin?), (2) the flow type (single-step or multi-step with Continue/Next button?), (3) exact input selectors (labels, placeholders, input types \u2014 is it getByLabel, getByPlaceholder, or input[type=password]?), (4) exact submit button text, (5) post-login redirect URL. Every app is different \u2014 single-step, multi-step, OAuth buttons, magic links.",
818
+ forUITests: "BEFORE writing a UI test for a page: READ the page component. Find: headings (text + level), form fields (labels, placeholders, types), buttons (text, role), navigation elements, validation error messages, success/error states. Use the exact text from the component \u2014 do not guess.",
819
+ forAPITests: "BEFORE writing an API test: READ the route handler. Find: the endpoint path, HTTP method, request body schema (what fields, what types), response body shape (is it flat or wrapped in { data: {...} }?), auth requirements (Bearer token? Cookie? API key?), error response shapes.",
820
+ forAPIMapping: "BEFORE calling add_api_endpoints: READ ALL route handlers for the feature. Register every endpoint with accurate method, path, requestShape, responseShapes, requiresAuth."
821
+ },
822
+ credentials: {
823
+ rule: "Never hardcode credentials in test code",
824
+ loginFields: hasAuth ? "Use process.env.TEST_USER_EMAIL! and process.env.TEST_USER_PASSWORD!" : "No credentials configured \u2014 set TEST_USER_EMAIL and TEST_USER_PASSWORD via set_variable",
825
+ registrationFields: 'MUST use unique email per run: `testuser-${Date.now()}@example.com` \u2014 reusing emails causes "already registered" failures',
826
+ registrationPassword: "Use 'TestPass123!' for new account passwords (meets typical strength rules)"
827
+ },
828
+ variables: {
829
+ configured: varNames,
830
+ baseUrl: vars.variables?.BASE_URL?.value || "Not set"
831
+ },
832
+ tags: {
833
+ "@auth": "Tests the login/auth flow itself. MUST NOT combine with @smoke, @regression, @needs-auth, @critical. CAN include @discovered.",
834
+ "@needs-auth": "Tests for authenticated pages \u2014 MUST include inline login block. CAN combine with @smoke, @regression, @critical.",
835
+ "@smoke": "Quick sanity checks \u2014 run on every deploy",
836
+ "@regression": "Full regression suite tests",
837
+ "@critical": "Business-critical paths (informational label \u2014 no special suite filtering)",
838
+ "@api": "API-level tests. Runs in its own project, excluded from suite/smoke/regression runs",
839
+ "@discovered": "Auto-added to tests generated by AI discovery",
840
+ "@generated": "Auto-added by AI discovery and API test generation",
841
+ "@manual": "Default tag for tests created via create_test when no tags specified",
842
+ "@flaky": "Auto-added after repeated failures. Excluded from suite/smoke/regression runs",
843
+ "@bug-found": "Added when healer detects an app bug. Test is auto-quarantined",
844
+ "@needs-review": "Added when DRAFT test fails healing. Requires human attention",
845
+ "@heal-skip": "Added by healer when test is permanently unfixable. Prevents future auto-heal"
846
+ },
847
+ executionModel: {
848
+ isolation: "Each test runs as its own separate Playwright process in a fresh browser. No shared state, no storageState, no global setup.",
849
+ authRequired: "Every @needs-auth test MUST include its own login block. Do NOT suggest storageState or performLogin() \u2014 those only work in the regression suite.",
850
+ concurrency: "Tests run in parallel \u2014 runner claims up to 10 per poll, launched 3s apart (~30s per batch). Multiple batches can overlap. Use test.setTimeout(120_000) if the target app is slow under concurrent login load."
851
+ },
852
+ lifecycle: {
853
+ DRAFT: "New or unverified test \u2014 not included in scheduled runs",
854
+ ACTIVE: "Verified and running \u2014 included in batch/suite executions",
855
+ DISABLED: "Manually paused \u2014 excluded from all runs",
856
+ QUARANTINED: "Auto-quarantined after repeated failures"
857
+ },
858
+ logging: {
859
+ CRITICAL: "EVERY request.get/post/put/patch/delete call MUST be followed by a __QA_HTTP__ log line. This is how the platform surfaces request/response data in the Network panel. Missing this = invisible API calls.",
860
+ apiPattern: "const body = await res.json();\nconsole.log('__QA_HTTP__:' + JSON.stringify({ method: 'POST', url: '/api/path', status: res.status(), requestBody: { field: value, password: '[REDACTED]' }, responseBody: body }));",
861
+ rules: [
862
+ "Call res.json() ONCE, store in body variable \u2014 reuse for log and assertions (calling twice throws)",
863
+ "Log AFTER the request, BEFORE assertions",
864
+ 'Redact sensitive fields: password: "[REDACTED]", token: "[REDACTED]"',
865
+ "Use the literal URL string (same as the request call), not a variable",
866
+ "UI tests using page fixture do NOT need __QA_HTTP__ \u2014 only request fixture tests"
867
+ ],
868
+ uiMilestones: "UI tests (page fixture): add plain console.log() at key milestones \u2014 e.g. console.log('Navigated to login page') after page.goto(). These appear in the Console Output panel.",
869
+ uiLoggingRules: [
870
+ "Log AFTER the action, not before \u2014 confirms the action succeeded",
871
+ 'Include dynamic values where useful: console.log("Current URL:", page.url())',
872
+ "Keep messages short and human-readable \u2014 they show verbatim in the UI",
873
+ "Do NOT log sensitive values (passwords, tokens)"
874
+ ],
875
+ apiTestStructure: "Use test.describe.serial() for API tests sharing auth. Independent validation tests (401, 404 checks) go in a SEPARATE non-serial describe block \u2014 do not mix them with the auth-dependent serial flow."
876
+ },
877
+ bestPractices: [
878
+ "Every @needs-auth test must start with a login block (goto login, fill creds, click submit, waitForURL)",
879
+ "Use { timeout: 30000 } on waitForURL after login \u2014 target apps can be slow under concurrent test load",
880
+ "Keep login blocks minimal \u2014 no assertions on the login page (that is what @auth tests are for)",
881
+ "After login, page.goto() directly to the page being tested \u2014 do not navigate via UI clicks",
882
+ "Use role-based selectors (getByRole, getByLabel) over CSS selectors",
883
+ "Registration tests must generate unique email with Date.now()",
884
+ "Group tests into suites matching feature names exactly (case-sensitive)",
885
+ "Do NOT suggest storageState or performLogin() for create_test \u2014 those only work in the regression suite",
886
+ "EVERY API test (request fixture) MUST include __QA_HTTP__ log after each request call \u2014 see logging section above",
887
+ 'Avoid waitForLoadState("networkidle") \u2014 apps with SSE, WebSocket, or analytics connections may never reach idle, causing 60s timeouts. Wait for specific elements instead.',
888
+ 'For headings, use exact: true or level: 1 \u2014 getByRole("heading", { name: "X" }) matches ALL h1-h6 containing "X", causing strict mode violations'
889
+ ],
890
+ pitfalls: {
891
+ CRITICAL: "These are the top causes of test failures. Read before writing ANY test.",
892
+ strictModeViolations: `Playwright throws when a locator resolves to 2+ elements. Common causes: getByLabel('Password') matches input AND 'Show password' toggle; getByRole('button', { name: 'Continue' }) matches 'Continue' AND 'Continue with GitHub'. Prevention: use input[type="password"] for password fields, use { exact: true } for ambiguous button text, scope to a parent container (page.locator('form#login').getByLabel('Email')).`,
893
+ networkIdle: "NEVER use waitForLoadState('networkidle') \u2014 waits for 500ms of zero network activity, which is fragile and causes 30s+ timeouts in apps with polling, analytics, or WebSockets. Use waitForURL() or wait for a specific element instead.",
894
+ headingStrictMode: "getByRole('heading', { name: 'Dashboard' }) can match multiple headings (h1 + h2 + breadcrumb). Add { level: 1 } or { exact: true } to disambiguate. Same for getByLabel('Password') matching input AND 'Show password' toggle.",
895
+ postLoginRedirect: "NEVER assert exact URL after login (e.g. expect(page).toHaveURL('/dashboard')) \u2014 apps redirect to different routes per user/role. Use: await page.waitForURL(url => !url.pathname.startsWith('/login'), { timeout: 30000 })",
896
+ resJsonOnce: "res.json() consumes the response body stream \u2014 calling it twice throws. Store result: const body = await res.json(); then reuse body for logging and assertions.",
897
+ hiddenInputs: "Many UI frameworks use visually hidden <input> with custom overlays. page.check() fails because the overlay intercepts clicks. Click the <label> or visible wrapper: page.getByText('Remember me').click()",
898
+ apiResponseShapes: "API endpoints often wrap data in a property ({ user: {...} }, { data: [...] }). Read the route handler's res.json() call to see the actual shape. If the handler does res.json({ ticket }), then body is { ticket: { id, ... } } \u2014 NOT { id, ... }.",
899
+ invalidIds: "Not all routes validate ID format before querying the database. If a route passes the raw ID to an ORM query and gets null back, it returns 404 'not found' \u2014 not 400 'bad request'. If unsure, expect either: expect([400, 404]).toContain(res.status())",
900
+ hardcodedUrls: "NEVER hardcode full URLs in test code. For UI tests: always use relative paths \u2014 page.goto('/login'). The runner sets baseURL from the project's BASE_URL variable. For API tests: use relative paths if the API is on the same domain as the frontend (request.post('/api/auth/login')). If the API is on a SEPARATE domain, use process.env.BASE_API_URL! as a test variable (set via set_variable) and construct URLs: request.post(process.env.BASE_API_URL! + '/auth/login'). NEVER hardcode 'https://example.com/...' in test code \u2014 use env vars or relative paths.",
901
+ credentialFallbacks: "NEVER use process.env.TEST_USER_EMAIL ?? 'fallback' or || 'fallback'. Use ! (non-null assertion). Missing variable = test should fail immediately, not silently use hardcoded value."
902
+ },
903
+ templates: {
904
+ needsAuth: `test('Feature Name \u2014 Test Name', {
905
+ tag: ['@needs-auth', '@smoke'],
906
+ }, async ({ page }) => {
907
+ // Login block \u2014 ADAPTED from reading the app's login page component
908
+ // YOU MUST READ the login page component BEFORE writing this block
909
+ await page.goto('/login'); // read the router for actual login route
910
+ await page.getByRole('textbox', { name: /email/i }).fill(process.env.TEST_USER_EMAIL!);
911
+ await page.locator('input[type="password"]').waitFor({ state: 'visible', timeout: 10000 });
912
+ await page.locator('input[type="password"]').fill(process.env.TEST_USER_PASSWORD!);
913
+ await page.getByRole('button', { name: /sign in|log in|submit/i }).click();
914
+ await page.waitForURL(url => !url.pathname.startsWith('/login'), { timeout: 30000 });
915
+ console.log('Logged in, current URL:', page.url());
916
+
917
+ // Actual test
918
+ await page.goto('/feature-path');
919
+ console.log('On feature page');
920
+ await expect(page.getByRole('heading', { name: /feature name/i })).toBeVisible();
921
+ });`,
922
+ authTest: "test('Login \u2014 Happy Path', {\n tag: ['@auth'],\n}, async ({ page }) => {\n await page.goto('/auth/login');\n // test the login form itself \u2014 selectors from reading the actual component\n});",
923
+ apiSerial: "test.describe.serial('Feature Name', () => {\n let token: string;\n test('authenticate', async ({ request }) => {\n const res = await request.post('/api/auth/login', {\n data: { email: process.env.TEST_USER_EMAIL!, password: process.env.TEST_USER_PASSWORD! }\n });\n const body = await res.json();\n console.log('__QA_HTTP__:' + JSON.stringify({\n method: 'POST', url: '/api/auth/login', status: res.status(),\n requestBody: { email: process.env.TEST_USER_EMAIL!, password: '[REDACTED]' },\n responseBody: body,\n }));\n expect(res.status()).toBe(200);\n token = body.access_token; // \u2190 adapt to your API (e.g. body.token, body.jwt)\n });\n test('get profile', async ({ request }) => {\n const res = await request.get('/api/users/profile', {\n headers: { Authorization: `Bearer ${token}` }\n });\n const body = await res.json();\n console.log('__QA_HTTP__:' + JSON.stringify({\n method: 'GET', url: '/api/users/profile', status: res.status(),\n responseBody: body,\n }));\n expect(res.status()).toBe(200);\n });\n});",
924
+ apiEndpointMapping: `// After reading an Express route handler like:
925
+ // router.post('/api/auth/login', async (req, res) => { ... })
926
+ // Call add_api_endpoints with:
927
+ {
928
+ featureName: "Authentication",
929
+ endpoints: [{
930
+ method: "POST",
931
+ path: "/api/auth/login",
932
+ requiresAuth: false,
933
+ requestShape: { "email": "string", "password": "string" },
934
+ responseShapes: { "200": { "token": "string", "user": "object" }, "401": { "error": "string" } }
935
+ }]
936
+ }`,
937
+ uiWithMilestones: `test('Feature \u2014 Happy Path', async ({ page }) => {
938
+ await page.goto('/login');
939
+ console.log('Navigated to login page');
940
+
941
+ await page.getByRole('textbox', { name: /email/i }).fill(process.env.TEST_USER_EMAIL!);
942
+ await page.locator('input[type="password"]').fill(process.env.TEST_USER_PASSWORD!);
943
+ await page.getByRole('button', { name: /sign in/i }).click();
944
+ console.log('Credentials submitted');
945
+
946
+ await page.waitForURL(url => !url.pathname.startsWith('/login'), { timeout: 15000 });
947
+ console.log('Logged in, current URL:', page.url());
948
+
949
+ await page.goto('/feature-path');
950
+ console.log('On feature page');
951
+ });`
952
+ },
953
+ testQuality: [
954
+ 'Test actual user flows, not just "page loads" \u2014 a test that only checks goto + heading visible is nearly worthless',
955
+ "Test form submission: fill fields, submit, verify success/redirect",
956
+ "Test validation: leave required fields empty, enter invalid data, verify error messages",
957
+ "Test error states: wrong password, expired session, invalid IDs",
958
+ "Test the happy path end-to-end: login \u2192 navigate \u2192 perform action \u2192 verify result",
959
+ "Each test should assert something meaningful about the application behavior"
960
+ ],
961
+ securityAudit: {
962
+ workflow: "After creating UI tests for a feature, call run_security_audit to analyze captured API traffic for auth issues, data exposure, and vulnerabilities.",
963
+ prerequisite: 'Requires prior browser-based test execution (the auto-verification run from create_test counts). If run_security_audit errors about missing data, tell the developer to click "Security Audit" in the Tests dropdown on the Dashboard \u2014 this launches a live browser to capture real network traffic (HAR) and runs analysis automatically.',
964
+ reviewing: "Use list_security_findings to review results. Filter by severity (critical/high/medium/low/info) or status (open/acknowledged/resolved/false-positive). Critical and high findings should be flagged to the developer immediately."
965
+ },
966
+ keyConcepts: {
967
+ features: 'Group related pages and tests (e.g., "Authentication" covers /auth/login, /auth/register). MUST include page routes.',
968
+ pages: 'Route URLs on a feature \u2014 used for coverage tracking and site map (e.g., ["/login", "/register"])',
969
+ suites: "Group tests for batch execution \u2014 suite name MUST match feature name exactly (case-sensitive)",
970
+ runner: "Executes tests \u2014 can be local (developer machine) or cloud",
971
+ testData: "Key-value variables injected into tests (e.g., credentials, URLs)"
972
+ },
973
+ retrievedAt: (/* @__PURE__ */ new Date()).toISOString()
974
+ };
975
+ return { contents: [{ uri: "project://test-conventions", mimeType: "application/json", text: JSON.stringify(conventions, null, 2) }] };
976
+ } catch (err) {
977
+ return { contents: [{ uri: "project://test-conventions", mimeType: "text/plain", text: `Failed to load conventions: ${err instanceof Error ? err.message : String(err)}` }] };
978
+ }
979
+ }
980
+ );
981
+ var transport = new StdioServerTransport();
982
+ await server.connect(transport);
983
+ //# sourceMappingURL=index.js.map