@askqa/mcp 1.1.1 → 1.2.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/.claude-plugin/plugin.json +1 -1
- package/README.md +1 -0
- package/package.json +1 -1
- package/server.js +246 -6
package/README.md
CHANGED
|
@@ -41,6 +41,7 @@ Get your API key from [askqa.ai](https://askqa.ai) after signing in.
|
|
|
41
41
|
| `delete_test` | Delete a test (with confirmation) |
|
|
42
42
|
| `run_test` | Run a test and wait for results |
|
|
43
43
|
| `get_test_results` | Get recent test run results with step details |
|
|
44
|
+
| `heal_test` | Diagnose a layout-change regression and help fix selectors |
|
|
44
45
|
| `get_test_screenshots` | Get screenshots from a test run |
|
|
45
46
|
| `list_templates` | List available test templates |
|
|
46
47
|
| `screenshot_url` | Screenshot a URL and extract page structure |
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -170,8 +170,19 @@ const server = new McpServer(
|
|
|
170
170
|
'When the user asks whether something is working (e.g. "is checkout working?", "is the site up?"),',
|
|
171
171
|
"your FIRST step should be to call list_tests to find a matching test by name or URL,",
|
|
172
172
|
"then call get_test_results for that test to check the latest run status and step details.",
|
|
173
|
-
"If the latest run passed, confirm it
|
|
173
|
+
"If the latest run passed, confirm it's working. If it failed, report what failed.",
|
|
174
174
|
"Only call run_test if the user explicitly asks to run a new test — checking status should use existing results.",
|
|
175
|
+
"",
|
|
176
|
+
"When the user asks to monitor a site, use list_templates to see available templates.",
|
|
177
|
+
"There are two kinds of templates:",
|
|
178
|
+
"",
|
|
179
|
+
"1. Universal templates (e.g. 'quick-checks') — work on any website with no configuration.",
|
|
180
|
+
" Just call create_test with template_id and you're done.",
|
|
181
|
+
"",
|
|
182
|
+
"2. Site-specific templates (e.g. 'shopify-cart') — need to discover CSS selectors for the target site.",
|
|
183
|
+
" Call detect_template first to probe the site and generate standalone Playwright code,",
|
|
184
|
+
" then call create_test with that generated code (not the template_id).",
|
|
185
|
+
" Templates that support detection have supportsDetection: true in list_templates output.",
|
|
175
186
|
].join("\n"),
|
|
176
187
|
}
|
|
177
188
|
);
|
|
@@ -179,13 +190,94 @@ const server = new McpServer(
|
|
|
179
190
|
server.registerTool(
|
|
180
191
|
"list_templates",
|
|
181
192
|
{
|
|
182
|
-
description: "List available test templates.
|
|
193
|
+
description: "List available test templates with usage hints. Some templates work directly with create_test (universal), others need detect_template first to discover site-specific selectors (site-specific).",
|
|
183
194
|
readOnlyHint: true,
|
|
184
195
|
},
|
|
185
196
|
async () => {
|
|
186
197
|
try {
|
|
187
198
|
const data = await apiGet("/api/tests/templates");
|
|
188
|
-
|
|
199
|
+
const lines = [];
|
|
200
|
+
for (const t of data.templates) {
|
|
201
|
+
lines.push(`${t.id}`);
|
|
202
|
+
lines.push(` Name: ${t.name}`);
|
|
203
|
+
lines.push(` Description: ${t.description}`);
|
|
204
|
+
lines.push(` Steps: ${t.steps.join(", ")}`);
|
|
205
|
+
if (t.supportsCodeGeneration) {
|
|
206
|
+
lines.push(` supportsDetection: true`);
|
|
207
|
+
lines.push(` Usage: call detect_template → get generated code → create_test with code`);
|
|
208
|
+
} else {
|
|
209
|
+
lines.push(` Usage: call create_test with template_id="${t.id}" directly`);
|
|
210
|
+
}
|
|
211
|
+
lines.push("");
|
|
212
|
+
}
|
|
213
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
214
|
+
} catch (err) {
|
|
215
|
+
return { content: [{ type: "text", text: `Error: ${err.message}` }], isError: true };
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
server.registerTool(
|
|
221
|
+
"detect_template",
|
|
222
|
+
{
|
|
223
|
+
description: "Run template detection against a URL to discover selectors and generate custom test code. This is the fastest way to create a custom test — detection runs the template flow against the site, discovers which CSS selectors work, and generates standalone Playwright test code with those selectors baked in. Use the generated code with create_test to save it.",
|
|
224
|
+
readOnlyHint: true,
|
|
225
|
+
inputSchema: {
|
|
226
|
+
template_id: z.string().describe("Template ID from list_templates (e.g. 'shopify-cart')"),
|
|
227
|
+
url: z.string().describe("The target URL to detect against (e.g. 'https://my-store.myshopify.com')"),
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
async ({ template_id, url }) => {
|
|
231
|
+
try {
|
|
232
|
+
const result = await apiPost(`/api/tests/templates/${template_id}/detect`, { url });
|
|
233
|
+
const content = [];
|
|
234
|
+
const lines = [];
|
|
235
|
+
|
|
236
|
+
const statusLabel = result.status === "passed" ? "PASSED" : "FAILED";
|
|
237
|
+
lines.push(`Detection: ${statusLabel}`);
|
|
238
|
+
lines.push("");
|
|
239
|
+
|
|
240
|
+
if (result.steps) {
|
|
241
|
+
lines.push("Steps:");
|
|
242
|
+
for (const step of result.steps) {
|
|
243
|
+
const icon = step.status === "passed" ? "+" : "x";
|
|
244
|
+
lines.push(` ${icon} ${step.name} — ${step.status}`);
|
|
245
|
+
if (step.error) lines.push(` Error: ${step.error}`);
|
|
246
|
+
}
|
|
247
|
+
lines.push("");
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (result.selectors) {
|
|
251
|
+
lines.push("Discovered selectors:");
|
|
252
|
+
for (const [key, value] of Object.entries(result.selectors)) {
|
|
253
|
+
lines.push(` ${key}: ${value}`);
|
|
254
|
+
}
|
|
255
|
+
lines.push("");
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (result.code) {
|
|
259
|
+
lines.push("Generated test code (use with create_test):");
|
|
260
|
+
lines.push("```");
|
|
261
|
+
lines.push(result.code);
|
|
262
|
+
lines.push("```");
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
content.push({ type: "text", text: lines.join("\n") });
|
|
266
|
+
|
|
267
|
+
// Fetch screenshots for each step
|
|
268
|
+
if (result.steps) {
|
|
269
|
+
for (const step of result.steps) {
|
|
270
|
+
if (!step.screenshot) continue;
|
|
271
|
+
const screenshotUrl = `${API_URL}/api/screenshots/${result.executionId}/${step.screenshot}`;
|
|
272
|
+
const base64 = await fetchScreenshot(screenshotUrl);
|
|
273
|
+
if (base64) {
|
|
274
|
+
content.push({ type: "text", text: `Screenshot: ${step.name}` });
|
|
275
|
+
content.push({ type: "image", data: base64, mimeType: "image/png" });
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return { content };
|
|
189
281
|
} catch (err) {
|
|
190
282
|
return { content: [{ type: "text", text: `Error: ${err.message}` }], isError: true };
|
|
191
283
|
}
|
|
@@ -195,7 +287,7 @@ server.registerTool(
|
|
|
195
287
|
server.registerTool(
|
|
196
288
|
"create_test",
|
|
197
289
|
{
|
|
198
|
-
description: "Create a saved test. Use template_id for
|
|
290
|
+
description: "Create a saved test. Use template_id for universal templates (e.g. 'quick-checks') that work on any site. Use code for custom tests or for site-specific templates after running detect_template. Provide template_id or code, not both.",
|
|
199
291
|
destructiveHint: true,
|
|
200
292
|
inputSchema: {
|
|
201
293
|
name: z.string().describe("A name for this test (e.g. 'Homepage health check')"),
|
|
@@ -403,12 +495,14 @@ server.registerTool(
|
|
|
403
495
|
code: z.string().optional().describe("Updated custom Playwright test code"),
|
|
404
496
|
template_id: z.string().optional().describe("Updated template ID"),
|
|
405
497
|
params: z.record(z.string()).optional().describe("Updated template parameters"),
|
|
406
|
-
secrets: z.record(z.string()).nullable().optional().describe("Updated secrets (pass null to clear)"),
|
|
498
|
+
secrets: z.record(z.string()).nullable().optional().describe("Updated secrets (pass null to clear). Encrypted at rest, never returned in API responses — must be provided again when updating a test that uses secrets."),
|
|
407
499
|
headers: z.record(z.string()).nullable().optional().describe("Updated HTTP headers (pass null to clear)"),
|
|
408
500
|
enable_test_mode: z.boolean().optional().describe("Send X-AskQA-Secret header to the target site, enabling test mode on sites that support it (default: true)"),
|
|
501
|
+
healing_disabled: z.boolean().optional().describe("Set true to stop AskQA from suggesting fixes for this test (e.g. a failing test that's acceptable as-is, or one you'd rather fix yourself). Auto-clears once the test passes again. Set false to re-enable."),
|
|
502
|
+
healing_note: z.string().nullable().optional().describe("Optional note explaining why healing was disabled (pass null to clear)."),
|
|
409
503
|
},
|
|
410
504
|
},
|
|
411
|
-
async ({ test_id, name, url, code, template_id, params, secrets, headers, enable_test_mode }) => {
|
|
505
|
+
async ({ test_id, name, url, code, template_id, params, secrets, headers, enable_test_mode, healing_disabled, healing_note }) => {
|
|
412
506
|
try {
|
|
413
507
|
const body = {};
|
|
414
508
|
if (name !== undefined) body.name = name;
|
|
@@ -419,6 +513,8 @@ server.registerTool(
|
|
|
419
513
|
if (secrets !== undefined) body.secrets = secrets;
|
|
420
514
|
if (headers !== undefined) body.headers = headers;
|
|
421
515
|
if (enable_test_mode !== undefined) body.enable_test_mode = enable_test_mode;
|
|
516
|
+
if (healing_disabled !== undefined) body.healing_disabled = healing_disabled;
|
|
517
|
+
if (healing_note !== undefined) body.healing_note = healing_note;
|
|
422
518
|
const test = await apiPatch(`/api/tests/${test_id}`, body);
|
|
423
519
|
return { content: [{ type: "text", text: JSON.stringify(test, null, 2) }] };
|
|
424
520
|
} catch (err) {
|
|
@@ -670,6 +766,150 @@ server.registerTool(
|
|
|
670
766
|
}
|
|
671
767
|
);
|
|
672
768
|
|
|
769
|
+
const REASON_EXPLANATIONS = {
|
|
770
|
+
"healing-disabled": "Healing is turned off for this test. Re-enable with update_test healing_disabled=false, or pass force=true to heal anyway.",
|
|
771
|
+
"not-custom-code": "This is a template-based test with no custom selectors to heal. Layout-change healing only applies to custom-code tests.",
|
|
772
|
+
"currently-passing": "The test's most recent run passed — there's nothing to heal.",
|
|
773
|
+
"not-enough-failures": "The test hasn't failed enough consecutive times yet to confirm a regression (a single/transient failure isn't healed). Wait for the confirmation threshold.",
|
|
774
|
+
"never-passed": "This test has no prior passing run, so a failure isn't a regression — it likely needs to be authored/fixed from scratch rather than healed.",
|
|
775
|
+
"transient-recovered": "On a fresh re-run the test passed, so the earlier failure was transient — no layout fix needed.",
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
function renderPageStructure(pageInfo) {
|
|
779
|
+
if (!pageInfo) return "";
|
|
780
|
+
const lines = ["", "Current page structure (selectors that exist NOW — map old selectors to these):"];
|
|
781
|
+
if (pageInfo.buttons?.length) {
|
|
782
|
+
lines.push(" Buttons:");
|
|
783
|
+
for (const b of pageInfo.buttons) lines.push(` "${b.text}" → ${b.selector}`);
|
|
784
|
+
}
|
|
785
|
+
if (pageInfo.inputs?.length) {
|
|
786
|
+
lines.push(" Inputs:");
|
|
787
|
+
for (const inp of pageInfo.inputs) {
|
|
788
|
+
const desc = inp.placeholder || inp.name || inp.type || inp.tag;
|
|
789
|
+
lines.push(` [${desc}] → ${inp.selector}`);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
if (pageInfo.links?.length) {
|
|
793
|
+
lines.push(" Links:");
|
|
794
|
+
for (const l of pageInfo.links) lines.push(` "${l.text}" → ${l.selector}`);
|
|
795
|
+
}
|
|
796
|
+
return lines.join("\n");
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
server.registerTool(
|
|
800
|
+
"heal_test",
|
|
801
|
+
{
|
|
802
|
+
description: "Diagnose and help heal a test that recently started failing because the website's layout changed (e.g. an input id or button selector changed). Accepts a test_id or name. Checks run history to confirm a real regression (was passing, now consistently failing) and that the failure is selector/layout-related — NOT a site outage, network error, or genuine feature breakage. When healable, it re-runs the test live, captures the CURRENT page structure + screenshots, and returns a brief for you to write new selectors. IMPORTANT: only fix the selectors — never change the test's logic, step order, assertions, or navigation, and never skip steps. After proposing new code, verify it with validate_test, and only then apply with update_test. If the failing test is actually acceptable, or the user wants to fix it themselves, call update_test healing_disabled=true to stop future suggestions.",
|
|
803
|
+
readOnlyHint: true,
|
|
804
|
+
inputSchema: {
|
|
805
|
+
test_id: z.coerce.number().optional().describe("The test ID to heal (from list_tests). Provide this or name."),
|
|
806
|
+
name: z.string().optional().describe("Test name (case-insensitive substring match) if you don't have the ID."),
|
|
807
|
+
reproduce: z.boolean().optional().describe("Re-run the test live to confirm the failure and capture current layout (default: true)."),
|
|
808
|
+
force: z.boolean().optional().describe("Heal even if healing_disabled is set on the test (default: false)."),
|
|
809
|
+
},
|
|
810
|
+
},
|
|
811
|
+
async ({ test_id, name, reproduce, force }) => {
|
|
812
|
+
try {
|
|
813
|
+
// Resolve test by id or name.
|
|
814
|
+
let resolvedId = test_id;
|
|
815
|
+
if (!resolvedId) {
|
|
816
|
+
if (!name) {
|
|
817
|
+
return { content: [{ type: "text", text: "Provide a test_id or name." }], isError: true };
|
|
818
|
+
}
|
|
819
|
+
const data = await apiGet("/api/tests/list");
|
|
820
|
+
const needle = name.toLowerCase();
|
|
821
|
+
const matches = data.tests.filter((t) => t.name && t.name.toLowerCase().includes(needle));
|
|
822
|
+
if (matches.length === 0) {
|
|
823
|
+
return { content: [{ type: "text", text: `No test found matching "${name}". Use list_tests to see available tests.` }], isError: true };
|
|
824
|
+
}
|
|
825
|
+
if (matches.length > 1) {
|
|
826
|
+
const list = matches.map((t) => ` #${t.id} — ${t.name} (${t.url})`).join("\n");
|
|
827
|
+
return { content: [{ type: "text", text: `Multiple tests match "${name}":\n${list}\n\nRe-run heal_test with a specific test_id.` }] };
|
|
828
|
+
}
|
|
829
|
+
resolvedId = matches[0].id;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
const result = await apiPost(`/api/tests/${resolvedId}/heal`, { mode: "diagnose", reproduce: reproduce !== false });
|
|
833
|
+
const { test, diagnosis, reproduction } = result;
|
|
834
|
+
const content = [];
|
|
835
|
+
const lines = [`Healing diagnosis for "${test.name}" (#${test.id})`, ` URL: ${test.url}`, ""];
|
|
836
|
+
|
|
837
|
+
// Healing disabled — respect unless forced.
|
|
838
|
+
if (diagnosis.reason === "healing-disabled" && !force) {
|
|
839
|
+
lines.push("⚠ " + REASON_EXPLANATIONS["healing-disabled"]);
|
|
840
|
+
if (diagnosis.healing_note) lines.push(` Note: ${diagnosis.healing_note}`);
|
|
841
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
// Not healable — explain and stop.
|
|
845
|
+
if (!diagnosis.healable && diagnosis.reason !== "healing-disabled") {
|
|
846
|
+
lines.push(`Not healable (${diagnosis.reason}).`);
|
|
847
|
+
if (REASON_EXPLANATIONS[diagnosis.reason]) lines.push(` ${REASON_EXPLANATIONS[diagnosis.reason]}`);
|
|
848
|
+
if (diagnosis.reason === "regression" && diagnosis.failure_class && diagnosis.failure_class !== "selector") {
|
|
849
|
+
lines.push(` The failure looks like a "${diagnosis.failure_class}" issue, not a layout/selector change, so healing won't help.`);
|
|
850
|
+
if (diagnosis.failing_step) lines.push(` Failing step: ${diagnosis.failing_step.name} — ${diagnosis.failing_step.error || ""}`);
|
|
851
|
+
}
|
|
852
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// Healable (or forced past a disabled flag). Build the brief.
|
|
856
|
+
const reg = diagnosis.regression;
|
|
857
|
+
if (reg) {
|
|
858
|
+
lines.push("✓ Confirmed regression (layout change suspected):");
|
|
859
|
+
lines.push(` Last passed: run #${reg.lastPassRunId} at ${reg.lastPassAt}`);
|
|
860
|
+
lines.push(` Started failing: run #${reg.firstFailRunId} at ${reg.firstFailAt}`);
|
|
861
|
+
lines.push(` Consecutive failures: ${reg.failureStreak}`);
|
|
862
|
+
}
|
|
863
|
+
if (diagnosis.failing_step) {
|
|
864
|
+
lines.push("", `Failing step: ${diagnosis.failing_step.name}`);
|
|
865
|
+
if (diagnosis.failing_step.error) lines.push(` Error: ${diagnosis.failing_step.error}`);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
if (reproduction && !reproduction.still_failing) {
|
|
869
|
+
lines.push("", "On a fresh re-run the test PASSED — the failure was transient. No fix needed right now.");
|
|
870
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
// Current test code
|
|
874
|
+
const fullTest = await apiGet(`/api/tests/${test.id}`);
|
|
875
|
+
lines.push("", "Current test code:", "```javascript", fullTest.code || "(no code)", "```");
|
|
876
|
+
|
|
877
|
+
// Current page structure
|
|
878
|
+
if (reproduction?.page_info) lines.push(renderPageStructure(reproduction.page_info));
|
|
879
|
+
|
|
880
|
+
// Guardrails + instructions for the calling agent
|
|
881
|
+
lines.push(
|
|
882
|
+
"",
|
|
883
|
+
"── How to heal this test ──",
|
|
884
|
+
"1. Propose updated code that changes ONLY the broken selector(s) to match the current page structure above.",
|
|
885
|
+
" • Do NOT change the test's logic, step order, assertions, waits, or navigation.",
|
|
886
|
+
" • Do NOT skip/remove steps or add workarounds (no JS .click(), no waitForTimeout).",
|
|
887
|
+
"2. Verify your new code with validate_test (code + url). Iterate until it passes.",
|
|
888
|
+
"3. Only after it passes, apply it with update_test (confirm with the user first).",
|
|
889
|
+
"",
|
|
890
|
+
"If this failing test is actually acceptable, or the user wants to fix it themselves, call",
|
|
891
|
+
"update_test healing_disabled=true (optionally with healing_note) to stop future suggestions.",
|
|
892
|
+
);
|
|
893
|
+
|
|
894
|
+
content.push({ type: "text", text: lines.join("\n") });
|
|
895
|
+
|
|
896
|
+
// Reproduction screenshots
|
|
897
|
+
if (reproduction?.screenshots) {
|
|
898
|
+
for (const [stepName, base64] of Object.entries(reproduction.screenshots)) {
|
|
899
|
+
if (base64) {
|
|
900
|
+
content.push({ type: "text", text: `Screenshot: ${stepName}` });
|
|
901
|
+
content.push({ type: "image", data: base64, mimeType: "image/png" });
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
return { content };
|
|
907
|
+
} catch (err) {
|
|
908
|
+
return { content: [{ type: "text", text: `Error: ${err.message}` }], isError: true };
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
);
|
|
912
|
+
|
|
673
913
|
// --- Notification channel tools ---
|
|
674
914
|
|
|
675
915
|
server.registerTool(
|