@browserstack/mcp-server 1.0.12 → 1.0.13
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
CHANGED
|
@@ -16,6 +16,7 @@ const live_1 = __importDefault(require("./tools/live"));
|
|
|
16
16
|
const accessibility_1 = __importDefault(require("./tools/accessibility"));
|
|
17
17
|
const automate_1 = __importDefault(require("./tools/automate"));
|
|
18
18
|
const testmanagement_1 = __importDefault(require("./tools/testmanagement"));
|
|
19
|
+
const instrumentation_1 = require("./lib/instrumentation");
|
|
19
20
|
function registerTools(server) {
|
|
20
21
|
(0, bstack_sdk_1.default)(server);
|
|
21
22
|
(0, applive_1.default)(server);
|
|
@@ -37,6 +38,7 @@ async function main() {
|
|
|
37
38
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
38
39
|
await server.connect(transport);
|
|
39
40
|
logger_1.default.info("MCP server started successfully");
|
|
41
|
+
(0, instrumentation_1.trackMCP)("started", server.server.getClientVersion());
|
|
40
42
|
}
|
|
41
43
|
main().catch(console.error);
|
|
42
44
|
// Ensure logs are flushed before exit
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AddTestResultSchema = void 0;
|
|
7
|
+
exports.addTestResult = addTestResult;
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const config_1 = __importDefault(require("../../config"));
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const error_1 = require("../../lib/error");
|
|
12
|
+
/**
|
|
13
|
+
* Schema for adding a test result to a test run.
|
|
14
|
+
*/
|
|
15
|
+
exports.AddTestResultSchema = zod_1.z.object({
|
|
16
|
+
project_identifier: zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.describe("Identifier of the project (e.g., PR-12345)"),
|
|
19
|
+
test_run_id: zod_1.z.string().describe("Identifier of the test run (e.g., TR-678)"),
|
|
20
|
+
test_result: zod_1.z.object({
|
|
21
|
+
status: zod_1.z
|
|
22
|
+
.string()
|
|
23
|
+
.describe("Status of the test result, e.g., 'passed', 'failed'."),
|
|
24
|
+
description: zod_1.z
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe("Optional description of the test result."),
|
|
28
|
+
}),
|
|
29
|
+
test_case_id: zod_1.z
|
|
30
|
+
.string()
|
|
31
|
+
.describe("Identifier of the test case, e.g., 'TC-13'."),
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Adds a test result to a specific test run via BrowserStack Test Management API.
|
|
35
|
+
*/
|
|
36
|
+
async function addTestResult(rawArgs) {
|
|
37
|
+
try {
|
|
38
|
+
const args = exports.AddTestResultSchema.parse(rawArgs);
|
|
39
|
+
const url = `https://test-management.browserstack.com/api/v2/projects/${encodeURIComponent(args.project_identifier)}/test-runs/${encodeURIComponent(args.test_run_id)}/results`;
|
|
40
|
+
const body = {
|
|
41
|
+
test_result: args.test_result,
|
|
42
|
+
test_case_id: args.test_case_id,
|
|
43
|
+
};
|
|
44
|
+
const response = await axios_1.default.post(url, body, {
|
|
45
|
+
auth: {
|
|
46
|
+
username: config_1.default.browserstackUsername,
|
|
47
|
+
password: config_1.default.browserstackAccessKey,
|
|
48
|
+
},
|
|
49
|
+
headers: { "Content-Type": "application/json" },
|
|
50
|
+
});
|
|
51
|
+
const data = response.data;
|
|
52
|
+
if (!data.success) {
|
|
53
|
+
throw new Error(`API returned unsuccessful response: ${JSON.stringify(data)}`);
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
content: [
|
|
57
|
+
{
|
|
58
|
+
type: "text",
|
|
59
|
+
text: `Successfully added test result with ID=${data["test-result"].id}`,
|
|
60
|
+
},
|
|
61
|
+
{ type: "text", text: JSON.stringify(data["test-result"], null, 2) },
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
return (0, error_1.formatAxiosError)(err, "Failed to add test result to test run");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -9,6 +9,7 @@ exports.listTestCasesTool = listTestCasesTool;
|
|
|
9
9
|
exports.createTestRunTool = createTestRunTool;
|
|
10
10
|
exports.listTestRunsTool = listTestRunsTool;
|
|
11
11
|
exports.updateTestRunTool = updateTestRunTool;
|
|
12
|
+
exports.addTestResultTool = addTestResultTool;
|
|
12
13
|
exports.default = addTestManagementTools;
|
|
13
14
|
const instrumentation_1 = require("../lib/instrumentation");
|
|
14
15
|
const logger_1 = __importDefault(require("../logger"));
|
|
@@ -19,7 +20,7 @@ const list_testcases_1 = require("./testmanagement-utils/list-testcases");
|
|
|
19
20
|
const create_testrun_1 = require("./testmanagement-utils/create-testrun");
|
|
20
21
|
const list_testruns_1 = require("./testmanagement-utils/list-testruns");
|
|
21
22
|
const update_testrun_1 = require("./testmanagement-utils/update-testrun");
|
|
22
|
-
|
|
23
|
+
const add_test_result_1 = require("./testmanagement-utils/add-test-result");
|
|
23
24
|
/**
|
|
24
25
|
* Wrapper to call createProjectOrFolder util.
|
|
25
26
|
*/
|
|
@@ -73,9 +74,11 @@ async function createTestCaseTool(args) {
|
|
|
73
74
|
*/
|
|
74
75
|
async function listTestCasesTool(args) {
|
|
75
76
|
try {
|
|
77
|
+
(0, instrumentation_1.trackMCP)("listTestCases", serverInstance.server.getClientVersion());
|
|
76
78
|
return await (0, list_testcases_1.listTestCases)(args);
|
|
77
79
|
}
|
|
78
80
|
catch (err) {
|
|
81
|
+
(0, instrumentation_1.trackMCP)("listTestCases", serverInstance.server.getClientVersion(), err);
|
|
79
82
|
return {
|
|
80
83
|
content: [
|
|
81
84
|
{
|
|
@@ -93,9 +96,11 @@ async function listTestCasesTool(args) {
|
|
|
93
96
|
*/
|
|
94
97
|
async function createTestRunTool(args) {
|
|
95
98
|
try {
|
|
99
|
+
(0, instrumentation_1.trackMCP)("createTestRun", serverInstance.server.getClientVersion());
|
|
96
100
|
return await (0, create_testrun_1.createTestRun)(args);
|
|
97
101
|
}
|
|
98
102
|
catch (err) {
|
|
103
|
+
(0, instrumentation_1.trackMCP)("createTestRun", serverInstance.server.getClientVersion(), err);
|
|
99
104
|
return {
|
|
100
105
|
content: [
|
|
101
106
|
{
|
|
@@ -113,9 +118,11 @@ async function createTestRunTool(args) {
|
|
|
113
118
|
*/
|
|
114
119
|
async function listTestRunsTool(args) {
|
|
115
120
|
try {
|
|
121
|
+
(0, instrumentation_1.trackMCP)("listTestRuns", serverInstance.server.getClientVersion());
|
|
116
122
|
return await (0, list_testruns_1.listTestRuns)(args);
|
|
117
123
|
}
|
|
118
124
|
catch (err) {
|
|
125
|
+
(0, instrumentation_1.trackMCP)("listTestRuns", serverInstance.server.getClientVersion(), err);
|
|
119
126
|
return {
|
|
120
127
|
content: [
|
|
121
128
|
{
|
|
@@ -135,9 +142,11 @@ async function listTestRunsTool(args) {
|
|
|
135
142
|
*/
|
|
136
143
|
async function updateTestRunTool(args) {
|
|
137
144
|
try {
|
|
145
|
+
(0, instrumentation_1.trackMCP)("updateTestRun", serverInstance.server.getClientVersion());
|
|
138
146
|
return await (0, update_testrun_1.updateTestRun)(args);
|
|
139
147
|
}
|
|
140
148
|
catch (err) {
|
|
149
|
+
(0, instrumentation_1.trackMCP)("updateTestRun", serverInstance.server.getClientVersion(), err);
|
|
141
150
|
return {
|
|
142
151
|
content: [
|
|
143
152
|
{
|
|
@@ -150,6 +159,28 @@ async function updateTestRunTool(args) {
|
|
|
150
159
|
};
|
|
151
160
|
}
|
|
152
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Adds a test result to a specific test run via BrowserStack Test Management API.
|
|
164
|
+
*/
|
|
165
|
+
async function addTestResultTool(args) {
|
|
166
|
+
try {
|
|
167
|
+
(0, instrumentation_1.trackMCP)("addTestResult", serverInstance.server.getClientVersion());
|
|
168
|
+
return await (0, add_test_result_1.addTestResult)(args);
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
(0, instrumentation_1.trackMCP)("addTestResult", serverInstance.server.getClientVersion(), err);
|
|
172
|
+
return {
|
|
173
|
+
content: [
|
|
174
|
+
{
|
|
175
|
+
type: "text",
|
|
176
|
+
text: `Failed to add test result: ${err instanceof Error ? err.message : "Unknown error"}. Please open an issue on GitHub if the problem persists`,
|
|
177
|
+
isError: true,
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
isError: true,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
153
184
|
/**
|
|
154
185
|
* Registers both project/folder and test-case tools.
|
|
155
186
|
*/
|
|
@@ -161,4 +192,5 @@ function addTestManagementTools(server) {
|
|
|
161
192
|
server.tool("createTestRun", "Create a test run in BrowserStack Test Management.", create_testrun_1.CreateTestRunSchema.shape, createTestRunTool);
|
|
162
193
|
server.tool("listTestRuns", "List test runs in a project with optional filters (date ranges, assignee, state, etc.)", list_testruns_1.ListTestRunsSchema.shape, listTestRunsTool);
|
|
163
194
|
server.tool("updateTestRun", "Update a test run in BrowserStack Test Management.", update_testrun_1.UpdateTestRunSchema.shape, updateTestRunTool);
|
|
195
|
+
server.tool("addTestResult", "Add a test result to a specific test run via BrowserStack Test Management API.", add_test_result_1.AddTestResultSchema.shape, addTestResultTool);
|
|
164
196
|
}
|