@smartbear/mcp 0.14.1 → 0.16.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/README.md +1 -1
- package/dist/bugsnag/client.js +47 -1340
- package/dist/bugsnag/input-schemas.js +18 -18
- package/dist/bugsnag/tool/error/get-error.js +98 -0
- package/dist/bugsnag/tool/error/list-project-errors.js +102 -0
- package/dist/bugsnag/tool/error/update-error.js +256 -0
- package/dist/bugsnag/tool/event/get-event-details-from-dashboard-url.js +55 -0
- package/dist/bugsnag/tool/event/get-event.js +38 -0
- package/dist/bugsnag/tool/performance/get-network-endpoint-groupings.js +46 -0
- package/dist/bugsnag/tool/performance/get-span-group.js +73 -0
- package/dist/bugsnag/tool/performance/get-trace.js +83 -0
- package/dist/bugsnag/tool/performance/list-span-groups.js +111 -0
- package/dist/bugsnag/tool/performance/list-spans.js +97 -0
- package/dist/bugsnag/tool/performance/list-trace-fields.js +41 -0
- package/dist/bugsnag/tool/performance/set-network-endpoint-groupings.js +90 -0
- package/dist/bugsnag/tool/project/get-current-project.js +31 -0
- package/dist/bugsnag/tool/project/list-project-event-filters.js +42 -0
- package/dist/bugsnag/tool/project/list-projects.js +43 -0
- package/dist/bugsnag/tool/release/get-build.js +50 -0
- package/dist/bugsnag/tool/release/get-release.js +68 -0
- package/dist/bugsnag/tool/release/list-releases.js +88 -0
- package/dist/common/prompts.js +9 -0
- package/dist/common/server.js +16 -0
- package/dist/common/transport-http.js +2 -0
- package/dist/package.json.js +1 -1
- package/dist/qmetry/client/api/client-api.js +2 -1
- package/dist/qmetry/client/automation.js +2 -1
- package/dist/qmetry/client/tools/testcase-tools.js +269 -1
- package/dist/qmetry/client/tools/testsuite-tools.js +1 -1
- package/dist/reflect/client.js +82 -255
- package/dist/reflect/config/constants.js +8 -0
- package/dist/reflect/prompt/sap-test.js +29 -0
- package/dist/reflect/tool/recording/add-prompt-step.js +60 -0
- package/dist/reflect/tool/recording/add-segment.js +56 -0
- package/dist/reflect/tool/recording/connect-to-session.js +89 -0
- package/dist/reflect/tool/recording/delete-previous-step.js +47 -0
- package/dist/reflect/tool/recording/get-screenshot.js +55 -0
- package/dist/reflect/tool/suites/cancel-suite-execution.js +50 -0
- package/dist/reflect/tool/suites/execute-suite.js +40 -0
- package/dist/reflect/tool/suites/get-suite-execution-status.js +50 -0
- package/dist/reflect/tool/suites/list-suite-executions.js +40 -0
- package/dist/reflect/tool/suites/list-suites.js +27 -0
- package/dist/reflect/tool/tests/get-test-status.js +42 -0
- package/dist/reflect/tool/tests/list-segments.js +68 -0
- package/dist/reflect/tool/tests/list-tests.js +27 -0
- package/dist/reflect/tool/tests/run-test.js +40 -0
- package/dist/reflect/websocket-manager.js +92 -0
- package/dist/zephyr/client.js +35 -1
- package/dist/zephyr/common/rest-api-schemas.js +463 -477
- package/dist/zephyr/tool/folder/create-folder.js +55 -0
- package/dist/zephyr/tool/issue-link/get-test-cases.js +33 -0
- package/dist/zephyr/tool/issue-link/get-test-cycles.js +32 -0
- package/dist/zephyr/tool/issue-link/get-test-executions.js +32 -0
- package/dist/zephyr/tool/test-case/create-issue-link.js +38 -0
- package/dist/zephyr/tool/test-case/create-test-script.js +57 -0
- package/dist/zephyr/tool/test-case/create-test-steps.js +91 -0
- package/dist/zephyr/tool/test-case/create-web-link.js +5 -2
- package/dist/zephyr/tool/test-case/get-links.js +32 -0
- package/dist/zephyr/tool/test-case/get-test-script.js +46 -0
- package/dist/zephyr/tool/test-case/get-test-steps.js +56 -0
- package/dist/zephyr/tool/test-cycle/create-issue-link.js +45 -0
- package/dist/zephyr/tool/test-cycle/create-web-link.js +56 -0
- package/dist/zephyr/tool/test-cycle/get-links.js +39 -0
- package/dist/zephyr/tool/test-execution/create-issue-link.js +45 -0
- package/dist/zephyr/tool/test-execution/get-test-execution-links.js +39 -0
- package/dist/zephyr/tool/test-execution/get-test-steps.js +75 -0
- package/dist/zephyr/tool/test-execution/update-test-execution.js +73 -0
- package/package.json +11 -9
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { Tool, ToolError } from "../../../common/tools.js";
|
|
4
|
+
class GetScreenshot extends Tool {
|
|
5
|
+
specification = {
|
|
6
|
+
title: "Get Screenshot",
|
|
7
|
+
summary: "Capture a screenshot from the current state of an active Reflect recording session",
|
|
8
|
+
readOnly: true,
|
|
9
|
+
idempotent: true,
|
|
10
|
+
parameters: [
|
|
11
|
+
{
|
|
12
|
+
name: "sessionId",
|
|
13
|
+
type: z.string(),
|
|
14
|
+
description: "The ID of the Reflect recording session",
|
|
15
|
+
required: true
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
};
|
|
19
|
+
handle = async (args) => {
|
|
20
|
+
const { sessionId } = args;
|
|
21
|
+
if (!sessionId) throw new ToolError("sessionId argument is required");
|
|
22
|
+
const wsManager = this.client.getConnectedSession(sessionId);
|
|
23
|
+
const id = randomUUID();
|
|
24
|
+
const responsePromise = wsManager.waitForResponse(id);
|
|
25
|
+
await wsManager.sendMcpMessage({
|
|
26
|
+
type: "mcp:get-screenshot",
|
|
27
|
+
id
|
|
28
|
+
});
|
|
29
|
+
const response = await responsePromise;
|
|
30
|
+
const { imageBase64, state } = response;
|
|
31
|
+
if (!imageBase64) {
|
|
32
|
+
throw new ToolError("No imageBase64 in screenshot response");
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
content: [
|
|
36
|
+
{
|
|
37
|
+
type: "image",
|
|
38
|
+
data: imageBase64,
|
|
39
|
+
mimeType: "image/png"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: "text",
|
|
43
|
+
text: JSON.stringify({
|
|
44
|
+
success: true,
|
|
45
|
+
message: "Screenshot captured",
|
|
46
|
+
state
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
GetScreenshot
|
|
55
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Tool, ToolError } from "../../../common/tools.js";
|
|
3
|
+
import { API_HOSTNAME } from "../../config/constants.js";
|
|
4
|
+
class CancelSuiteExecution extends Tool {
|
|
5
|
+
specification = {
|
|
6
|
+
title: "Cancel Suite Execution",
|
|
7
|
+
summary: "Cancel a reflect suite execution",
|
|
8
|
+
parameters: [
|
|
9
|
+
{
|
|
10
|
+
name: "suiteId",
|
|
11
|
+
type: z.string(),
|
|
12
|
+
description: "ID of the reflect suite to cancel execution for",
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "executionId",
|
|
17
|
+
type: z.string(),
|
|
18
|
+
description: "ID of the reflect suite execution to cancel",
|
|
19
|
+
required: true
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
};
|
|
23
|
+
handle = async (args) => {
|
|
24
|
+
const { suiteId, executionId } = args;
|
|
25
|
+
if (!suiteId || !executionId) {
|
|
26
|
+
throw new ToolError(
|
|
27
|
+
"Both suiteId and executionId arguments are required"
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
const response = await fetch(
|
|
31
|
+
`https://${API_HOSTNAME}/v1/suites/${suiteId}/executions/${executionId}/cancel`,
|
|
32
|
+
{
|
|
33
|
+
method: "PATCH",
|
|
34
|
+
headers: this.client.getHeaders()
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
throw new ToolError(
|
|
39
|
+
`Failed to cancel suite execution: ${response.status} ${response.statusText}`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
const data = await response.json();
|
|
43
|
+
return {
|
|
44
|
+
content: [{ type: "text", text: JSON.stringify(data) }]
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
CancelSuiteExecution
|
|
50
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Tool, ToolError } from "../../../common/tools.js";
|
|
3
|
+
import { API_HOSTNAME } from "../../config/constants.js";
|
|
4
|
+
class ExecuteSuite extends Tool {
|
|
5
|
+
specification = {
|
|
6
|
+
title: "Execute Suite",
|
|
7
|
+
summary: "Execute a reflect suite",
|
|
8
|
+
parameters: [
|
|
9
|
+
{
|
|
10
|
+
name: "suiteId",
|
|
11
|
+
type: z.string(),
|
|
12
|
+
description: "ID of the reflect suite to execute",
|
|
13
|
+
required: true
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
};
|
|
17
|
+
handle = async (args) => {
|
|
18
|
+
const { suiteId } = args;
|
|
19
|
+
if (!suiteId) throw new ToolError("suiteId argument is required");
|
|
20
|
+
const response = await fetch(
|
|
21
|
+
`https://${API_HOSTNAME}/v1/suites/${suiteId}/executions`,
|
|
22
|
+
{
|
|
23
|
+
method: "POST",
|
|
24
|
+
headers: this.client.getHeaders()
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
throw new ToolError(
|
|
29
|
+
`Failed to execute suite: ${response.status} ${response.statusText}`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
const data = await response.json();
|
|
33
|
+
return {
|
|
34
|
+
content: [{ type: "text", text: JSON.stringify(data) }]
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
ExecuteSuite
|
|
40
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Tool, ToolError } from "../../../common/tools.js";
|
|
3
|
+
import { API_HOSTNAME } from "../../config/constants.js";
|
|
4
|
+
class GetSuiteExecutionStatus extends Tool {
|
|
5
|
+
specification = {
|
|
6
|
+
title: "Get Suite Execution Status",
|
|
7
|
+
summary: "Get the status of a reflect suite execution",
|
|
8
|
+
parameters: [
|
|
9
|
+
{
|
|
10
|
+
name: "suiteId",
|
|
11
|
+
type: z.string(),
|
|
12
|
+
description: "ID of the reflect suite to get execution status for",
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "executionId",
|
|
17
|
+
type: z.string(),
|
|
18
|
+
description: "ID of the reflect suite execution to get status for",
|
|
19
|
+
required: true
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
};
|
|
23
|
+
handle = async (args) => {
|
|
24
|
+
const { suiteId, executionId } = args;
|
|
25
|
+
if (!suiteId || !executionId) {
|
|
26
|
+
throw new ToolError(
|
|
27
|
+
"Both suiteId and executionId arguments are required"
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
const response = await fetch(
|
|
31
|
+
`https://${API_HOSTNAME}/v1/suites/${suiteId}/executions/${executionId}`,
|
|
32
|
+
{
|
|
33
|
+
method: "GET",
|
|
34
|
+
headers: this.client.getHeaders()
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
throw new ToolError(
|
|
39
|
+
`Failed to get suite execution status: ${response.status} ${response.statusText}`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
const data = await response.json();
|
|
43
|
+
return {
|
|
44
|
+
content: [{ type: "text", text: JSON.stringify(data) }]
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
GetSuiteExecutionStatus
|
|
50
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Tool, ToolError } from "../../../common/tools.js";
|
|
3
|
+
import { API_HOSTNAME } from "../../config/constants.js";
|
|
4
|
+
class ListSuiteExecutions extends Tool {
|
|
5
|
+
specification = {
|
|
6
|
+
title: "List Suite Executions",
|
|
7
|
+
summary: "List all executions for a given suite",
|
|
8
|
+
parameters: [
|
|
9
|
+
{
|
|
10
|
+
name: "suiteId",
|
|
11
|
+
type: z.string(),
|
|
12
|
+
description: "ID of the reflect suite to list executions for",
|
|
13
|
+
required: true
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
};
|
|
17
|
+
handle = async (args) => {
|
|
18
|
+
const { suiteId } = args;
|
|
19
|
+
if (!suiteId) throw new ToolError("suiteId argument is required");
|
|
20
|
+
const response = await fetch(
|
|
21
|
+
`https://${API_HOSTNAME}/v1/suites/${suiteId}/executions`,
|
|
22
|
+
{
|
|
23
|
+
method: "GET",
|
|
24
|
+
headers: this.client.getHeaders()
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
throw new ToolError(
|
|
29
|
+
`Failed to list suite executions: ${response.status} ${response.statusText}`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
const data = await response.json();
|
|
33
|
+
return {
|
|
34
|
+
content: [{ type: "text", text: JSON.stringify(data) }]
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
ListSuiteExecutions
|
|
40
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Tool, ToolError } from "../../../common/tools.js";
|
|
2
|
+
import { API_HOSTNAME } from "../../config/constants.js";
|
|
3
|
+
class ListSuites extends Tool {
|
|
4
|
+
specification = {
|
|
5
|
+
title: "List Suites",
|
|
6
|
+
summary: "Retrieve a list of all reflect suites available",
|
|
7
|
+
parameters: []
|
|
8
|
+
};
|
|
9
|
+
handle = async (_args) => {
|
|
10
|
+
const response = await fetch(`https://${API_HOSTNAME}/v1/suites`, {
|
|
11
|
+
method: "GET",
|
|
12
|
+
headers: this.client.getHeaders()
|
|
13
|
+
});
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
throw new ToolError(
|
|
16
|
+
`Failed to list suites: ${response.status} ${response.statusText}`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
const data = await response.json();
|
|
20
|
+
return {
|
|
21
|
+
content: [{ type: "text", text: JSON.stringify(data) }]
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
ListSuites
|
|
27
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Tool, ToolError } from "../../../common/tools.js";
|
|
3
|
+
import { API_HOSTNAME } from "../../config/constants.js";
|
|
4
|
+
class GetTestStatus extends Tool {
|
|
5
|
+
specification = {
|
|
6
|
+
title: "Get Test Status",
|
|
7
|
+
summary: "Get the status of a reflect test execution",
|
|
8
|
+
parameters: [
|
|
9
|
+
{
|
|
10
|
+
name: "executionId",
|
|
11
|
+
type: z.string(),
|
|
12
|
+
description: "ID of the reflect test execution to get status for",
|
|
13
|
+
required: true
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
};
|
|
17
|
+
handle = async (args) => {
|
|
18
|
+
const { executionId } = args;
|
|
19
|
+
if (!executionId) {
|
|
20
|
+
throw new ToolError("executionId argument is required");
|
|
21
|
+
}
|
|
22
|
+
const response = await fetch(
|
|
23
|
+
`https://${API_HOSTNAME}/v1/executions/${executionId}`,
|
|
24
|
+
{
|
|
25
|
+
method: "GET",
|
|
26
|
+
headers: this.client.getHeaders()
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
throw new ToolError(
|
|
31
|
+
`Failed to get test status: ${response.status} ${response.statusText}`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
const data = await response.json();
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: "text", text: JSON.stringify(data) }]
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
GetTestStatus
|
|
42
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Tool, ToolError } from "../../../common/tools.js";
|
|
3
|
+
import { API_HOSTNAME, API_KEY_HEADER } from "../../config/constants.js";
|
|
4
|
+
class ListSegments extends Tool {
|
|
5
|
+
specification = {
|
|
6
|
+
title: "List Segments",
|
|
7
|
+
summary: "Retrieve available reusable test segments for the given platform type. Segments are reusable test steps with an optional set of parameters that can used across multiple tests.",
|
|
8
|
+
readOnly: true,
|
|
9
|
+
idempotent: true,
|
|
10
|
+
parameters: [
|
|
11
|
+
{
|
|
12
|
+
name: "platform",
|
|
13
|
+
type: z.enum(["api", "native-mobile", "web"]),
|
|
14
|
+
description: "The platform type to retrieve segments for",
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "offset",
|
|
19
|
+
type: z.number(),
|
|
20
|
+
description: "Offset for pagination",
|
|
21
|
+
required: false
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "limit",
|
|
25
|
+
type: z.number(),
|
|
26
|
+
description: "Maximum number of segments to return",
|
|
27
|
+
required: false
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
};
|
|
31
|
+
handle = async (args) => {
|
|
32
|
+
const {
|
|
33
|
+
platform,
|
|
34
|
+
offset = 0,
|
|
35
|
+
limit = 25
|
|
36
|
+
} = args;
|
|
37
|
+
const url = `https://${API_HOSTNAME}/v1/segments?type=${platform}&offset=${offset}&limit=${limit}`;
|
|
38
|
+
const response = await fetch(url, {
|
|
39
|
+
method: "GET",
|
|
40
|
+
headers: {
|
|
41
|
+
[API_KEY_HEADER]: this.client.getApiToken(),
|
|
42
|
+
"Content-Type": "application/json"
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
if (!response.ok) {
|
|
46
|
+
throw new ToolError(
|
|
47
|
+
`Failed to list segments: ${response.status} ${response.statusText}`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
const data = await response.json();
|
|
51
|
+
return {
|
|
52
|
+
content: [
|
|
53
|
+
{
|
|
54
|
+
type: "text",
|
|
55
|
+
text: JSON.stringify({
|
|
56
|
+
success: true,
|
|
57
|
+
segments: data.segments,
|
|
58
|
+
count: data.count,
|
|
59
|
+
message: `Found ${data.count} segment(s) for platform '${platform}'`
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
ListSegments
|
|
68
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Tool, ToolError } from "../../../common/tools.js";
|
|
2
|
+
import { API_HOSTNAME } from "../../config/constants.js";
|
|
3
|
+
class ListTests extends Tool {
|
|
4
|
+
specification = {
|
|
5
|
+
title: "List Tests",
|
|
6
|
+
summary: "List all reflect tests",
|
|
7
|
+
parameters: []
|
|
8
|
+
};
|
|
9
|
+
handle = async (_args) => {
|
|
10
|
+
const response = await fetch(`https://${API_HOSTNAME}/v1/tests`, {
|
|
11
|
+
method: "GET",
|
|
12
|
+
headers: this.client.getHeaders()
|
|
13
|
+
});
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
throw new ToolError(
|
|
16
|
+
`Failed to list tests: ${response.status} ${response.statusText}`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
const data = await response.json();
|
|
20
|
+
return {
|
|
21
|
+
content: [{ type: "text", text: JSON.stringify(data) }]
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
ListTests
|
|
27
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Tool, ToolError } from "../../../common/tools.js";
|
|
3
|
+
import { API_HOSTNAME } from "../../config/constants.js";
|
|
4
|
+
class RunTest extends Tool {
|
|
5
|
+
specification = {
|
|
6
|
+
title: "Run Test",
|
|
7
|
+
summary: "Run a reflect test",
|
|
8
|
+
parameters: [
|
|
9
|
+
{
|
|
10
|
+
name: "testId",
|
|
11
|
+
type: z.string(),
|
|
12
|
+
description: "ID of the reflect test to run",
|
|
13
|
+
required: true
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
};
|
|
17
|
+
handle = async (args) => {
|
|
18
|
+
const { testId } = args;
|
|
19
|
+
if (!testId) throw new ToolError("testId argument is required");
|
|
20
|
+
const response = await fetch(
|
|
21
|
+
`https://${API_HOSTNAME}/v1/tests/${testId}/executions`,
|
|
22
|
+
{
|
|
23
|
+
method: "POST",
|
|
24
|
+
headers: this.client.getHeaders()
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
throw new ToolError(
|
|
29
|
+
`Failed to run test: ${response.status} ${response.statusText}`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
const data = await response.json();
|
|
33
|
+
return {
|
|
34
|
+
content: [{ type: "text", text: JSON.stringify(data) }]
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
RunTest
|
|
40
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import WebSocket from "ws";
|
|
2
|
+
import { WEBSOCKET_HOSTNAME, API_KEY_HEADER } from "./config/constants.js";
|
|
3
|
+
class WebSocketManager {
|
|
4
|
+
sessionId;
|
|
5
|
+
apiKey;
|
|
6
|
+
mcpSocket = null;
|
|
7
|
+
pendingResponses = /* @__PURE__ */ new Map();
|
|
8
|
+
constructor(sessionId, apiKey) {
|
|
9
|
+
this.sessionId = sessionId;
|
|
10
|
+
this.apiKey = apiKey;
|
|
11
|
+
}
|
|
12
|
+
async connect() {
|
|
13
|
+
if (this.mcpSocket?.readyState === WebSocket.OPEN) {
|
|
14
|
+
throw new Error("WebSocket is already connected");
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
await this.connectMcpSocket();
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
`Failed to connect WebSocket: ${error.message}`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async connectMcpSocket() {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
const url = `wss://${WEBSOCKET_HOSTNAME}/websocket/v2/recordings/${this.sessionId}/topics/mcp?sid=${this.sessionId}`;
|
|
27
|
+
this.mcpSocket = new WebSocket(url, {
|
|
28
|
+
headers: {
|
|
29
|
+
[API_KEY_HEADER]: this.apiKey
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
this.mcpSocket.on("open", () => {
|
|
33
|
+
resolve();
|
|
34
|
+
});
|
|
35
|
+
this.mcpSocket.on("message", (data) => {
|
|
36
|
+
try {
|
|
37
|
+
const message = JSON.parse(data.toString());
|
|
38
|
+
const { id, type } = message;
|
|
39
|
+
if (id && this.pendingResponses.has(id)) {
|
|
40
|
+
const pending = this.pendingResponses.get(id);
|
|
41
|
+
this.pendingResponses.delete(id);
|
|
42
|
+
if (type?.endsWith(":success")) {
|
|
43
|
+
pending.resolve(message);
|
|
44
|
+
} else if (type?.endsWith(":failure")) {
|
|
45
|
+
pending.reject(message);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error("Failed to parse MCP message:", error);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
this.mcpSocket.on("error", (error) => {
|
|
53
|
+
reject(new Error(`MCP socket error: ${error.message}`));
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async sendMcpMessage(message) {
|
|
58
|
+
if (!this.mcpSocket || this.mcpSocket.readyState !== WebSocket.OPEN) {
|
|
59
|
+
throw new Error("WebSocket is not connected");
|
|
60
|
+
}
|
|
61
|
+
return new Promise((resolve, reject) => {
|
|
62
|
+
this.mcpSocket?.send(JSON.stringify(message), (error) => {
|
|
63
|
+
if (error) {
|
|
64
|
+
reject(new Error(`Failed to send MCP message: ${error.message}`));
|
|
65
|
+
} else {
|
|
66
|
+
resolve();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
waitForResponse(id) {
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
this.pendingResponses.set(id, { resolve, reject });
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async disconnect() {
|
|
77
|
+
if (this.mcpSocket) {
|
|
78
|
+
this.mcpSocket.removeAllListeners();
|
|
79
|
+
if (this.mcpSocket.readyState === WebSocket.OPEN || this.mcpSocket.readyState === WebSocket.CONNECTING) {
|
|
80
|
+
this.mcpSocket.close();
|
|
81
|
+
}
|
|
82
|
+
this.mcpSocket = null;
|
|
83
|
+
}
|
|
84
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
85
|
+
}
|
|
86
|
+
isConnected() {
|
|
87
|
+
return this.mcpSocket?.readyState === WebSocket.OPEN;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
WebSocketManager
|
|
92
|
+
};
|
package/dist/zephyr/client.js
CHANGED
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
import zod__default from "zod";
|
|
2
2
|
import { ApiClient } from "./common/api-client.js";
|
|
3
3
|
import { GetEnvironments } from "./tool/environment/get-environments.js";
|
|
4
|
+
import { CreateFolder } from "./tool/folder/create-folder.js";
|
|
5
|
+
import { GetTestCases as GetTestCases$1 } from "./tool/issue-link/get-test-cases.js";
|
|
6
|
+
import { GetTestCycles as GetTestCycles$1 } from "./tool/issue-link/get-test-cycles.js";
|
|
7
|
+
import { GetTestExecutions as GetTestExecutions$1 } from "./tool/issue-link/get-test-executions.js";
|
|
4
8
|
import { GetPriorities } from "./tool/priority/get-priorities.js";
|
|
5
9
|
import { GetProject } from "./tool/project/get-project.js";
|
|
6
10
|
import { GetProjects } from "./tool/project/get-projects.js";
|
|
7
11
|
import { GetStatuses } from "./tool/status/get-statuses.js";
|
|
12
|
+
import { CreateTestCaseIssueLink } from "./tool/test-case/create-issue-link.js";
|
|
8
13
|
import { CreateTestCase } from "./tool/test-case/create-test-case.js";
|
|
14
|
+
import { CreateTestScript } from "./tool/test-case/create-test-script.js";
|
|
15
|
+
import { CreateTestSteps } from "./tool/test-case/create-test-steps.js";
|
|
9
16
|
import { CreateTestCaseWebLink } from "./tool/test-case/create-web-link.js";
|
|
17
|
+
import { GetTestCaseLinks } from "./tool/test-case/get-links.js";
|
|
10
18
|
import { GetTestCase } from "./tool/test-case/get-test-case.js";
|
|
11
19
|
import { GetTestCases } from "./tool/test-case/get-test-cases.js";
|
|
20
|
+
import { GetTestScript } from "./tool/test-case/get-test-script.js";
|
|
21
|
+
import { GetTestCaseSteps } from "./tool/test-case/get-test-steps.js";
|
|
12
22
|
import { UpdateTestCase } from "./tool/test-case/update-test-case.js";
|
|
23
|
+
import { CreateTestCycleIssueLink } from "./tool/test-cycle/create-issue-link.js";
|
|
13
24
|
import { CreateTestCycle } from "./tool/test-cycle/create-test-cycle.js";
|
|
25
|
+
import { CreateTestCycleWebLink } from "./tool/test-cycle/create-web-link.js";
|
|
26
|
+
import { GetTestCycleLinks } from "./tool/test-cycle/get-links.js";
|
|
14
27
|
import { GetTestCycle } from "./tool/test-cycle/get-test-cycle.js";
|
|
15
28
|
import { GetTestCycles } from "./tool/test-cycle/get-test-cycles.js";
|
|
16
29
|
import { UpdateTestCycle } from "./tool/test-cycle/update-test-cycle.js";
|
|
30
|
+
import { CreateTestExecutionIssueLink } from "./tool/test-execution/create-issue-link.js";
|
|
17
31
|
import { CreateTestExecution } from "./tool/test-execution/create-test-execution.js";
|
|
18
32
|
import { GetTestExecution } from "./tool/test-execution/get-test-execution.js";
|
|
33
|
+
import { GetTestExecutionLinks } from "./tool/test-execution/get-test-execution-links.js";
|
|
19
34
|
import { GetTestExecutions } from "./tool/test-execution/get-test-executions.js";
|
|
35
|
+
import { GetTestExecutionSteps } from "./tool/test-execution/get-test-steps.js";
|
|
36
|
+
import { UpdateTestExecution } from "./tool/test-execution/update-test-execution.js";
|
|
20
37
|
const BASE_URL_DEFAULT = "https://api.zephyrscale.smartbear.com/v2";
|
|
21
38
|
const ConfigurationSchema = zod__default.object({
|
|
22
39
|
api_token: zod__default.string().describe("Zephyr Scale API token for authentication"),
|
|
@@ -47,11 +64,13 @@ class ZephyrClient {
|
|
|
47
64
|
new GetProject(this),
|
|
48
65
|
new GetTestCycles(this),
|
|
49
66
|
new GetTestCycle(this),
|
|
67
|
+
new GetTestCycleLinks(this),
|
|
50
68
|
new GetPriorities(this),
|
|
51
69
|
new GetStatuses(this),
|
|
52
70
|
new GetTestCases(this),
|
|
53
71
|
new GetEnvironments(this),
|
|
54
72
|
new GetTestCase(this),
|
|
73
|
+
new GetTestCaseLinks(this),
|
|
55
74
|
new GetTestExecution(this),
|
|
56
75
|
new GetTestExecutions(this),
|
|
57
76
|
new CreateTestCase(this),
|
|
@@ -59,7 +78,22 @@ class ZephyrClient {
|
|
|
59
78
|
new UpdateTestCase(this),
|
|
60
79
|
new UpdateTestCycle(this),
|
|
61
80
|
new CreateTestExecution(this),
|
|
62
|
-
new CreateTestCaseWebLink(this)
|
|
81
|
+
new CreateTestCaseWebLink(this),
|
|
82
|
+
new CreateTestSteps(this),
|
|
83
|
+
new CreateTestCaseIssueLink(this),
|
|
84
|
+
new CreateTestCycleIssueLink(this),
|
|
85
|
+
new CreateFolder(this),
|
|
86
|
+
new CreateTestScript(this),
|
|
87
|
+
new UpdateTestExecution(this),
|
|
88
|
+
new CreateTestExecutionIssueLink(this),
|
|
89
|
+
new GetTestCaseSteps(this),
|
|
90
|
+
new GetTestCases$1(this),
|
|
91
|
+
new GetTestCycles$1(this),
|
|
92
|
+
new GetTestScript(this),
|
|
93
|
+
new CreateTestCycleWebLink(this),
|
|
94
|
+
new GetTestExecutionSteps(this),
|
|
95
|
+
new GetTestExecutionLinks(this),
|
|
96
|
+
new GetTestExecutions$1(this)
|
|
63
97
|
];
|
|
64
98
|
for (const tool of tools) {
|
|
65
99
|
register(tool.specification, tool.handle);
|