Compare commits

...
3 Commits
Author SHA1 Message Date
ars9 5ea1e38f25 feat(mcp): add credential CRUD tools, bump to 1.13.0
- add list/get/create/update/delete_credential MCP tools so credentials
  can be created and attached to scenarios entirely via MCP
- update_credential only changes the fields passed, keeping data intact
- add changelog entries for 1.13.0 and the missing 1.12.0 release
2026-09-30 14:26:15 +03:00
ars9andClaude Sonnet 5 d99bb75fc2 chore: sync package-lock.json version to 1.12.0
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-16 15:53:21 +03:00
ars9andClaude Sonnet 5 d79415cbb3 feat(scenario): dump page screenshot and HTML to run files on step failure
Captures a full-page screenshot and the current page HTML whenever a
scenario or snippet step fails, and uploads both as run artifacts so
failures can be diagnosed from the run's file list.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-16 15:52:32 +03:00
6 changed files with 367 additions and 3 deletions

No files matched your search

+16
View File
@@ -2,6 +2,22 @@
All notable changes to this project will be documented in this file.
## 1.13.0 - 2026-09-30
Changes since 1.12.0:
### Added
- Added credential CRUD tools to the MCP server: `list_credentials`, `get_credential`, `create_credential`, `update_credential`, and `delete_credential`. Combined with the existing `add_scenario_credential` tool, credentials can now be created and attached to scenarios entirely via MCP.
## 1.12.0 - 2026-09-16
Changes since 1.11.0:
### Added
- When a scenario or snippet step fails, a full-page screenshot and the current page HTML are captured and uploaded as run artifacts, so failures can be diagnosed from the run's file list.
## 1.11.0 - 2026-09-15
Changes since 1.10.1:
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "liqa",
"version": "1.10.1",
"version": "1.13.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "liqa",
"version": "1.10.1",
"version": "1.13.0",
"workspaces": [
"server",
"client"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "liqa",
"version": "1.11.0",
"version": "1.13.0",
"private": true,
"workspaces": [
"server",
+160
View File
@@ -275,6 +275,166 @@ export class McpService {
},
);
// ── Credentials ───────────────────────────────────────────────────────────
server.registerTool(
"list_credentials",
{
description: "List all credentials (paginated)",
inputSchema: {
page: z
.number()
.int()
.min(1)
.optional()
.describe("Page number (default 1)"),
limit: z
.number()
.int()
.min(1)
.optional()
.describe("Items per page (default 20)"),
orderBy: z
.enum(["id", "name", "lastUsedAt", "createdAt", "updatedAt"])
.optional()
.describe("Field to order by (default id)"),
orderDir: z
.enum(["ASC", "DESC"])
.optional()
.describe("Sort direction (default ASC)"),
},
},
async ({ page, limit, orderBy, orderDir }) => {
const result = await this.credentialService.findAll({
page,
limit,
orderBy,
orderDir,
});
return {
content: [{ type: "text" as const, text: JSON.stringify(result) }],
};
},
);
server.registerTool(
"get_credential",
{
description: "Get a credential by ID",
inputSchema: {
id: z.uuid().describe("Credential ID"),
},
},
async ({ id }) => {
try {
const credential = await this.credentialService.findOne(id);
return {
content: [
{ type: "text" as const, text: JSON.stringify(credential) },
],
};
} catch (err) {
return {
isError: true,
content: [{ type: "text" as const, text: (err as Error).message }],
};
}
},
);
server.registerTool(
"create_credential",
{
description:
"Create a new credential. Assign it to a scenario with add_scenario_credential to use it via context.getCredential(alias).",
inputSchema: {
name: z.string().min(1).describe("Human-readable credential name"),
data: z
.string()
.optional()
.describe(
'JSON-encoded credential payload, e.g. {"token":"abc123"}',
),
},
},
async ({ name, data }) => {
try {
const credential = await this.credentialService.create({
name,
data,
});
return {
content: [
{ type: "text" as const, text: JSON.stringify(credential) },
],
};
} catch (err) {
return {
isError: true,
content: [{ type: "text" as const, text: (err as Error).message }],
};
}
},
);
server.registerTool(
"update_credential",
{
description: "Update an existing credential (name and/or data)",
inputSchema: {
id: z.uuid().describe("Credential ID to update"),
name: z.string().min(1).optional().describe("New name"),
data: z
.string()
.optional()
.describe("New JSON-encoded credential payload"),
},
},
async ({ id, name, data }) => {
try {
const credential = await this.credentialService.update(id, {
...(name !== undefined && { name }),
...(data !== undefined && { data }),
});
return {
content: [
{ type: "text" as const, text: JSON.stringify(credential) },
],
};
} catch (err) {
return {
isError: true,
content: [{ type: "text" as const, text: (err as Error).message }],
};
}
},
);
server.registerTool(
"delete_credential",
{
description: "Delete a credential by ID",
inputSchema: {
id: z.uuid().describe("Credential ID to delete"),
},
},
async ({ id }) => {
try {
await this.credentialService.remove(id);
return {
content: [
{ type: "text" as const, text: `Credential ${id} deleted` },
],
};
} catch (err) {
return {
isError: true,
content: [{ type: "text" as const, text: (err as Error).message }],
};
}
},
);
// ── Browser ───────────────────────────────────────────────────────────────
server.registerTool(
@@ -515,6 +515,8 @@ export class ScenarioSchedulerService implements OnModuleInit {
`Step ${(stepRun.scenarioStep as ScenarioStepEntity | undefined)?.order ?? "?"} failed: ${description}`,
);
await this.dumpPageOnFailure(stepRun);
// Cancel all remaining waiting/pending step runs in this run
await this.runStepRepo
.createQueryBuilder()
@@ -534,4 +536,51 @@ export class ScenarioSchedulerService implements OnModuleInit {
await this.runRepo.update(stepRun.runId, { status: "fail" });
this.logger.log(`Run #${stepRun.runId} → fail`);
}
// ── Page dump on failure ────────────────────────────────────────────────────
private async dumpPageOnFailure(
stepRun: ScenarioRunStepEntity,
): Promise<void> {
const handle = this.runBrowsers.get(stepRun.runId);
if (!handle) return; // no browser was ever opened for this run (e.g. setup error)
const step = stepRun.scenarioStep as ScenarioStepEntity | undefined;
const namePrefix = `step-${step?.order ?? stepRun.id}-failure`;
try {
const screenshot = await handle.page.screenshot({ fullPage: true });
await this.fileStorageService.createAndSaveRunArtifact(
stepRun.runId,
screenshot,
`${namePrefix}.png`,
"image/png",
);
} catch (err) {
this.logger.warn(
`StepRun #${stepRun.id}: failed to capture failure screenshot — ${(err as Error).message}`,
);
}
try {
const html = await handle.page.content();
await this.fileStorageService.createAndSaveRunArtifact(
stepRun.runId,
Buffer.from(html, "utf-8"),
`${namePrefix}.html`,
"text/html",
);
} catch (err) {
this.logger.warn(
`StepRun #${stepRun.id}: failed to capture failure page HTML — ${(err as Error).message}`,
);
}
this.persistLog(
stepRun.runId,
stepRun.id,
"log",
`Step ${step?.order ?? "?"} failed: page dump uploaded to run files`,
);
}
}
+139
View File
@@ -843,4 +843,143 @@ describe("McpController", () => {
expect(result.isError).toBe(true);
});
});
// ── Credential CRUD tools ─────────────────────────────────────────────────
async function createCredential(name: string, data?: string) {
const { rpc } = await mcpCall("create_credential", { name, data });
return JSON.parse(
(rpc.result as { content: { text: string }[] }).content[0].text,
) as { id: string; name: string; data: string | null };
}
describe("list_credentials", () => {
it("returns a paginated result with a data array", async () => {
await createCredential("mcp-list-cred");
const { status, rpc } = await mcpCall("list_credentials", {
limit: 100,
});
expect(status).toBe(200);
const result = rpc.result as { content: { text: string }[] };
const body = JSON.parse(result.content[0].text) as {
data: { name: string }[];
total: number;
};
expect(Array.isArray(body.data)).toBe(true);
expect(typeof body.total).toBe("number");
expect(body.data.some((c) => c.name === "mcp-list-cred")).toBe(true);
});
});
describe("create_credential", () => {
it("creates a credential and returns it with name and data", async () => {
const created = await createCredential(
"mcp-test-cred",
'{"token":"abc123"}',
);
expect(typeof created.id).toBe("string");
expect(created.name).toBe("mcp-test-cred");
expect(created.data).toBe('{"token":"abc123"}');
});
it("stores null data when data is omitted", async () => {
const created = await createCredential("mcp-test-cred-nodata");
expect(created.data).toBeNull();
});
});
describe("get_credential", () => {
it("returns the created credential by id", async () => {
const created = await createCredential("mcp-get-cred", '{"a":1}');
const { status, rpc } = await mcpCall("get_credential", {
id: created.id,
});
expect(status).toBe(200);
const result = rpc.result as { content: { text: string }[] };
const fetched = JSON.parse(result.content[0].text) as {
id: string;
name: string;
data: string;
};
expect(fetched.id).toBe(created.id);
expect(fetched.name).toBe("mcp-get-cred");
expect(fetched.data).toBe('{"a":1}');
});
it("returns an MCP error for a non-existent credential id", async () => {
const { status, rpc } = await mcpCall("get_credential", {
id: "00000000-0000-0000-0000-000000000000",
});
expect(status).toBe(200);
const result = rpc.result as { isError: boolean };
expect(result.isError).toBe(true);
});
});
describe("update_credential", () => {
it("updates name and data of an existing credential", async () => {
const created = await createCredential("mcp-upd-cred-orig", '{"v":1}');
const { status, rpc } = await mcpCall("update_credential", {
id: created.id,
name: "mcp-upd-cred-new",
data: '{"v":2}',
});
expect(status).toBe(200);
const result = rpc.result as { content: { text: string }[] };
const updated = JSON.parse(result.content[0].text) as {
name: string;
data: string;
};
expect(updated.name).toBe("mcp-upd-cred-new");
expect(updated.data).toBe('{"v":2}');
});
it("leaves data untouched when only name is updated", async () => {
const created = await createCredential("mcp-upd-cred-partial", '{"k":1}');
const { rpc } = await mcpCall("update_credential", {
id: created.id,
name: "mcp-upd-cred-partial-new",
});
const updated = JSON.parse(
(rpc.result as { content: { text: string }[] }).content[0].text,
) as { name: string; data: string };
expect(updated.name).toBe("mcp-upd-cred-partial-new");
expect(updated.data).toBe('{"k":1}');
});
it("returns an MCP error for a non-existent credential id", async () => {
const { status, rpc } = await mcpCall("update_credential", {
id: "00000000-0000-0000-0000-000000000000",
name: "Ghost",
});
expect(status).toBe(200);
const result = rpc.result as { isError: boolean };
expect(result.isError).toBe(true);
});
});
describe("delete_credential", () => {
it("deletes an existing credential and confirms deletion", async () => {
const created = await createCredential("mcp-del-cred");
const { status, rpc } = await mcpCall("delete_credential", {
id: created.id,
});
expect(status).toBe(200);
const result = rpc.result as { content: { text: string }[] };
expect(result.content[0].text).toContain(created.id);
const getResult = (await mcpCall("get_credential", { id: created.id }))
.rpc.result as { isError: boolean };
expect(getResult.isError).toBe(true);
});
it("returns an MCP error for a non-existent credential id", async () => {
const { status, rpc } = await mcpCall("delete_credential", {
id: "00000000-0000-0000-0000-000000000000",
});
expect(status).toBe(200);
const result = rpc.result as { isError: boolean };
expect(result.isError).toBe(true);
});
});
});