@browserstack/mcp-server 1.2.3 → 1.2.4

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.
Files changed (157) hide show
  1. package/README.md +88 -2
  2. package/dist/lib/device-cache.js +20 -17
  3. package/dist/lib/inmemory-store.d.ts +1 -0
  4. package/dist/lib/inmemory-store.js +1 -0
  5. package/dist/lib/utils.d.ts +5 -0
  6. package/dist/lib/utils.js +27 -0
  7. package/dist/server-factory.js +6 -0
  8. package/dist/tools/add-percy-snapshots.d.ts +5 -0
  9. package/dist/tools/add-percy-snapshots.js +17 -0
  10. package/dist/tools/appautomate-utils/appium-sdk/config-generator.d.ts +1 -0
  11. package/dist/tools/appautomate-utils/appium-sdk/config-generator.js +50 -0
  12. package/dist/tools/appautomate-utils/appium-sdk/constants.d.ts +23 -0
  13. package/dist/tools/appautomate-utils/appium-sdk/constants.js +43 -0
  14. package/dist/tools/appautomate-utils/appium-sdk/formatter.d.ts +8 -0
  15. package/dist/tools/appautomate-utils/appium-sdk/formatter.js +59 -0
  16. package/dist/tools/appautomate-utils/appium-sdk/handler.d.ts +3 -0
  17. package/dist/tools/appautomate-utils/appium-sdk/handler.js +52 -0
  18. package/dist/tools/appautomate-utils/appium-sdk/index.d.ts +7 -0
  19. package/dist/tools/appautomate-utils/appium-sdk/index.js +8 -0
  20. package/dist/tools/appautomate-utils/appium-sdk/instructions.d.ts +3 -0
  21. package/dist/tools/appautomate-utils/appium-sdk/instructions.js +47 -0
  22. package/dist/tools/appautomate-utils/appium-sdk/languages/csharp.d.ts +2 -0
  23. package/dist/tools/appautomate-utils/appium-sdk/languages/csharp.js +78 -0
  24. package/dist/tools/appautomate-utils/appium-sdk/languages/java.d.ts +8 -0
  25. package/dist/tools/appautomate-utils/appium-sdk/languages/java.js +87 -0
  26. package/dist/tools/appautomate-utils/appium-sdk/languages/nodejs.d.ts +3 -0
  27. package/dist/tools/appautomate-utils/appium-sdk/languages/nodejs.js +194 -0
  28. package/dist/tools/appautomate-utils/appium-sdk/languages/python.d.ts +3 -0
  29. package/dist/tools/appautomate-utils/appium-sdk/languages/python.js +76 -0
  30. package/dist/tools/appautomate-utils/appium-sdk/languages/ruby.d.ts +2 -0
  31. package/dist/tools/appautomate-utils/appium-sdk/languages/ruby.js +85 -0
  32. package/dist/tools/appautomate-utils/appium-sdk/types.d.ts +57 -0
  33. package/dist/tools/appautomate-utils/appium-sdk/types.js +54 -0
  34. package/dist/tools/appautomate-utils/appium-sdk/utils.d.ts +17 -0
  35. package/dist/tools/appautomate-utils/appium-sdk/utils.js +64 -0
  36. package/dist/tools/appautomate-utils/{appautomate.d.ts → native-execution/appautomate.d.ts} +1 -1
  37. package/dist/tools/appautomate-utils/{appautomate.js → native-execution/appautomate.js} +2 -2
  38. package/dist/tools/appautomate-utils/native-execution/constants.d.ts +10 -0
  39. package/dist/tools/appautomate-utils/native-execution/constants.js +36 -0
  40. package/dist/tools/appautomate-utils/native-execution/types.d.ts +19 -0
  41. package/dist/tools/appautomate-utils/{types.js → native-execution/types.js} +5 -1
  42. package/dist/tools/appautomate.js +25 -40
  43. package/dist/tools/bstack-sdk.d.ts +2 -15
  44. package/dist/tools/bstack-sdk.js +10 -119
  45. package/dist/tools/build-insights.d.ts +7 -0
  46. package/dist/tools/build-insights.js +67 -0
  47. package/dist/tools/list-test-files.d.ts +2 -0
  48. package/dist/tools/list-test-files.js +36 -0
  49. package/dist/tools/percy-sdk.d.ts +4 -0
  50. package/dist/tools/percy-sdk.js +71 -0
  51. package/dist/tools/percy-snapshot-utils/constants.d.ts +16 -0
  52. package/dist/tools/percy-snapshot-utils/constants.js +500 -0
  53. package/dist/tools/percy-snapshot-utils/detect-test-files.d.ts +10 -0
  54. package/dist/tools/percy-snapshot-utils/detect-test-files.js +175 -0
  55. package/dist/tools/percy-snapshot-utils/types.d.ts +15 -0
  56. package/dist/tools/percy-snapshot-utils/utils.d.ts +4 -0
  57. package/dist/tools/percy-snapshot-utils/utils.js +30 -0
  58. package/dist/tools/rca-agent-utils/constants.d.ts +13 -0
  59. package/dist/tools/rca-agent-utils/constants.js +24 -0
  60. package/dist/tools/rca-agent-utils/format-rca.d.ts +1 -0
  61. package/dist/tools/rca-agent-utils/format-rca.js +37 -0
  62. package/dist/tools/rca-agent-utils/get-build-id.d.ts +1 -0
  63. package/dist/tools/rca-agent-utils/get-build-id.js +18 -0
  64. package/dist/tools/rca-agent-utils/get-failed-test-id.d.ts +2 -0
  65. package/dist/tools/rca-agent-utils/get-failed-test-id.js +69 -0
  66. package/dist/tools/rca-agent-utils/rca-data.d.ts +9 -0
  67. package/dist/tools/rca-agent-utils/rca-data.js +196 -0
  68. package/dist/tools/rca-agent-utils/types.d.ts +48 -0
  69. package/dist/tools/rca-agent-utils/types.js +20 -0
  70. package/dist/tools/rca-agent.d.ts +14 -0
  71. package/dist/tools/rca-agent.js +119 -0
  72. package/dist/tools/review-agent-utils/build-counts.d.ts +7 -0
  73. package/dist/tools/review-agent-utils/build-counts.js +44 -0
  74. package/dist/tools/review-agent-utils/percy-approve-reject.d.ts +6 -0
  75. package/dist/tools/review-agent-utils/percy-approve-reject.js +39 -0
  76. package/dist/tools/review-agent-utils/percy-diffs.d.ts +9 -0
  77. package/dist/tools/review-agent-utils/percy-diffs.js +35 -0
  78. package/dist/tools/review-agent-utils/percy-snapshots.d.ts +11 -0
  79. package/dist/tools/review-agent-utils/percy-snapshots.js +58 -0
  80. package/dist/tools/review-agent.d.ts +5 -0
  81. package/dist/tools/review-agent.js +56 -0
  82. package/dist/tools/run-percy-scan.d.ts +8 -0
  83. package/dist/tools/run-percy-scan.js +37 -0
  84. package/dist/tools/sdk-utils/{commands.d.ts → bstack/commands.d.ts} +1 -1
  85. package/dist/tools/sdk-utils/bstack/commands.js +88 -0
  86. package/dist/tools/sdk-utils/bstack/configUtils.d.ts +4 -0
  87. package/dist/tools/sdk-utils/bstack/configUtils.js +66 -0
  88. package/dist/tools/sdk-utils/bstack/constants.d.ts +58 -0
  89. package/dist/tools/sdk-utils/{constants.js → bstack/constants.js} +117 -78
  90. package/dist/tools/sdk-utils/{constants.d.ts → bstack/frameworks.d.ts} +1 -1
  91. package/dist/tools/sdk-utils/bstack/frameworks.js +57 -0
  92. package/dist/tools/sdk-utils/bstack/index.d.ts +4 -0
  93. package/dist/tools/sdk-utils/bstack/index.js +5 -0
  94. package/dist/tools/sdk-utils/bstack/sdkHandler.d.ts +4 -0
  95. package/dist/tools/sdk-utils/bstack/sdkHandler.js +74 -0
  96. package/dist/tools/sdk-utils/common/constants.d.ts +10 -0
  97. package/dist/tools/sdk-utils/common/constants.js +86 -0
  98. package/dist/tools/sdk-utils/common/formatUtils.d.ts +5 -0
  99. package/dist/tools/sdk-utils/common/formatUtils.js +27 -0
  100. package/dist/tools/sdk-utils/common/index.d.ts +3 -0
  101. package/dist/tools/sdk-utils/common/index.js +4 -0
  102. package/dist/tools/sdk-utils/common/instructionUtils.d.ts +8 -0
  103. package/dist/tools/sdk-utils/common/instructionUtils.js +20 -0
  104. package/dist/tools/sdk-utils/common/schema.d.ts +73 -0
  105. package/dist/tools/sdk-utils/common/schema.js +51 -0
  106. package/dist/tools/sdk-utils/common/types.d.ts +66 -0
  107. package/dist/tools/sdk-utils/{types.js → common/types.js} +15 -2
  108. package/dist/tools/sdk-utils/common/utils.d.ts +25 -0
  109. package/dist/tools/sdk-utils/common/utils.js +90 -0
  110. package/dist/tools/sdk-utils/handler.d.ts +4 -0
  111. package/dist/tools/sdk-utils/handler.js +119 -0
  112. package/dist/tools/sdk-utils/percy-automate/constants.d.ts +11 -0
  113. package/dist/tools/sdk-utils/percy-automate/constants.js +338 -0
  114. package/dist/tools/sdk-utils/percy-automate/frameworks.d.ts +8 -0
  115. package/dist/tools/sdk-utils/percy-automate/frameworks.js +50 -0
  116. package/dist/tools/sdk-utils/percy-automate/handler.d.ts +3 -0
  117. package/dist/tools/sdk-utils/percy-automate/handler.js +30 -0
  118. package/dist/tools/sdk-utils/percy-automate/index.d.ts +1 -0
  119. package/dist/tools/sdk-utils/percy-automate/index.js +2 -0
  120. package/dist/tools/sdk-utils/percy-automate/types.d.ts +13 -0
  121. package/dist/tools/sdk-utils/percy-automate/types.js +1 -0
  122. package/dist/tools/sdk-utils/percy-bstack/constants.d.ts +4 -0
  123. package/dist/tools/sdk-utils/{percy → percy-bstack}/constants.js +13 -39
  124. package/dist/tools/sdk-utils/percy-bstack/frameworks.d.ts +2 -0
  125. package/dist/tools/sdk-utils/percy-bstack/frameworks.js +27 -0
  126. package/dist/tools/sdk-utils/percy-bstack/handler.d.ts +4 -0
  127. package/dist/tools/sdk-utils/percy-bstack/handler.js +99 -0
  128. package/dist/tools/sdk-utils/percy-bstack/index.d.ts +4 -0
  129. package/dist/tools/sdk-utils/percy-bstack/index.js +4 -0
  130. package/dist/tools/sdk-utils/percy-bstack/instructions.d.ts +7 -0
  131. package/dist/tools/sdk-utils/{percy → percy-bstack}/instructions.js +5 -9
  132. package/dist/tools/sdk-utils/percy-bstack/types.d.ts +13 -0
  133. package/dist/tools/sdk-utils/percy-bstack/types.js +5 -0
  134. package/dist/tools/sdk-utils/percy-web/constants.d.ts +41 -0
  135. package/dist/tools/sdk-utils/percy-web/constants.js +883 -0
  136. package/dist/tools/sdk-utils/percy-web/fetchPercyToken.d.ts +4 -0
  137. package/dist/tools/sdk-utils/percy-web/fetchPercyToken.js +32 -0
  138. package/dist/tools/sdk-utils/percy-web/frameworks.d.ts +7 -0
  139. package/dist/tools/sdk-utils/percy-web/frameworks.js +103 -0
  140. package/dist/tools/sdk-utils/percy-web/handler.d.ts +4 -0
  141. package/dist/tools/sdk-utils/percy-web/handler.js +27 -0
  142. package/dist/tools/sdk-utils/percy-web/index.d.ts +4 -0
  143. package/dist/tools/sdk-utils/percy-web/index.js +4 -0
  144. package/dist/tools/sdk-utils/percy-web/types.d.ts +12 -0
  145. package/dist/tools/sdk-utils/percy-web/types.js +1 -0
  146. package/dist/tools/testmanagement-utils/create-testrun.d.ts +4 -4
  147. package/dist/tools/testmanagement-utils/update-testrun.d.ts +4 -4
  148. package/package.json +2 -1
  149. package/dist/tools/appautomate-utils/types.d.ts +0 -5
  150. package/dist/tools/sdk-utils/commands.js +0 -65
  151. package/dist/tools/sdk-utils/instructions.d.ts +0 -6
  152. package/dist/tools/sdk-utils/instructions.js +0 -99
  153. package/dist/tools/sdk-utils/percy/constants.d.ts +0 -3
  154. package/dist/tools/sdk-utils/percy/instructions.d.ts +0 -10
  155. package/dist/tools/sdk-utils/percy/types.d.ts +0 -5
  156. package/dist/tools/sdk-utils/types.d.ts +0 -40
  157. /package/dist/tools/{sdk-utils/percy → percy-snapshot-utils}/types.js +0 -0
@@ -0,0 +1,4 @@
1
+ import { PercyIntegrationTypeEnum } from "../common/types.js";
2
+ export declare function fetchPercyToken(projectName: string, authorization: string, options?: {
3
+ type?: PercyIntegrationTypeEnum;
4
+ }): Promise<string>;
@@ -0,0 +1,32 @@
1
+ let globalPercyToken = null;
2
+ let globalProjectName = null;
3
+ async function fetchTokenFromAPI(projectName, authorization, options = {}) {
4
+ const authHeader = `Basic ${Buffer.from(authorization).toString("base64")}`;
5
+ const baseUrl = "https://api.browserstack.com/api/app_percy/get_project_token";
6
+ const params = new URLSearchParams({ name: projectName });
7
+ if (options.type) {
8
+ params.append("type", options.type);
9
+ }
10
+ const url = `${baseUrl}?${params.toString()}`;
11
+ const response = await fetch(url, { headers: { Authorization: authHeader } });
12
+ if (!response.ok) {
13
+ throw new Error(`Failed to fetch Percy token (status: ${response.status})`);
14
+ }
15
+ const data = await response.json();
16
+ if (!data?.token || !data?.success) {
17
+ throw new Error("Project exists but is likely set up for Automate. Please use a different project name.");
18
+ }
19
+ return data.token;
20
+ }
21
+ export async function fetchPercyToken(projectName, authorization, options = {}) {
22
+ if (globalProjectName !== projectName) {
23
+ globalProjectName = projectName;
24
+ globalPercyToken = null;
25
+ }
26
+ if (globalPercyToken) {
27
+ return globalPercyToken;
28
+ }
29
+ const token = await fetchTokenFromAPI(projectName, authorization, options);
30
+ globalPercyToken = token;
31
+ return token;
32
+ }
@@ -0,0 +1,7 @@
1
+ import { ConfigMapping } from "./types.js";
2
+ export declare const SUPPORTED_CONFIGURATIONS: ConfigMapping;
3
+ /**
4
+ * Utility function to check if a given language and testing framework
5
+ * are supported by Percy Web.
6
+ */
7
+ export declare function isPercyWebFrameworkSupported(language: string, framework: string): boolean;
@@ -0,0 +1,103 @@
1
+ import * as constants from "./constants.js";
2
+ export const SUPPORTED_CONFIGURATIONS = {
3
+ python: {
4
+ selenium: {
5
+ instructions: constants.pythonInstructions,
6
+ snapshotInstruction: constants.pythonInstructionsSnapshot,
7
+ },
8
+ playwright: {
9
+ instructions: constants.pythonPlaywrightInstructions,
10
+ snapshotInstruction: constants.pythonPlaywrightInstructionsSnapshot,
11
+ },
12
+ },
13
+ nodejs: {
14
+ selenium: {
15
+ instructions: constants.nodejsInstructions,
16
+ snapshotInstruction: constants.nodejsInstructionsSnapshot,
17
+ },
18
+ playwright: {
19
+ instructions: constants.nodejsPlaywrightInstructions,
20
+ snapshotInstruction: constants.nodejsPlaywrightInstructionsSnapshot,
21
+ },
22
+ webdriverio: {
23
+ instructions: constants.nodejsWebdriverioInstructions,
24
+ snapshotInstruction: constants.nodejsWebdriverioInstructionsSnapshot,
25
+ },
26
+ ember: {
27
+ instructions: constants.nodejsEmberInstructions,
28
+ snapshotInstruction: constants.nodejsEmberInstructionsSnapshot,
29
+ },
30
+ cypress: {
31
+ instructions: constants.nodejsCypressInstructions,
32
+ snapshotInstruction: constants.nodejsCypressInstructionsSnapshot,
33
+ },
34
+ puppeteer: {
35
+ instructions: constants.nodejsPuppeteerInstructions,
36
+ snapshotInstruction: constants.nodejsPuppeteerInstructionsSnapshot,
37
+ },
38
+ nightmare: {
39
+ instructions: constants.nodejsNightmareInstructions,
40
+ snapshotInstruction: constants.nodejsNightmareInstructionsSnapshot,
41
+ },
42
+ nightwatch: {
43
+ instructions: constants.nodejsNightwatchInstructions,
44
+ snapshotInstruction: constants.nodejsNightwatchInstructionsSnapshot,
45
+ },
46
+ protractor: {
47
+ instructions: constants.nodejsProtractorInstructions,
48
+ snapshotInstruction: constants.nodejsProtractorInstructionsSnapshot,
49
+ },
50
+ testcafe: {
51
+ instructions: constants.nodejsTestcafeInstructions,
52
+ snapshotInstruction: constants.nodejsTestcafeInstructionsSnapshot,
53
+ },
54
+ gatsby: {
55
+ instructions: constants.nodejsGatsbyInstructions,
56
+ snapshotInstruction: constants.nodejsGatsbyInstructionsSnapshot,
57
+ },
58
+ storybook: {
59
+ instructions: constants.nodejsStorybookInstructions,
60
+ snapshotInstruction: constants.nodejsStorybookInstructionsSnapshot,
61
+ },
62
+ },
63
+ java: {
64
+ selenium: {
65
+ instructions: constants.javaInstructions,
66
+ snapshotInstruction: constants.javaInstructionsSnapshot,
67
+ },
68
+ playwright: {
69
+ instructions: constants.javaPlaywrightInstructions,
70
+ snapshotInstruction: constants.javaPlaywrightInstructionsSnapshot,
71
+ },
72
+ },
73
+ ruby: {
74
+ selenium: {
75
+ instructions: constants.rubyInstructions,
76
+ snapshotInstruction: constants.rubyInstructionsSnapshot,
77
+ },
78
+ capybara: {
79
+ instructions: constants.rubyCapybaraInstructions,
80
+ snapshotInstruction: constants.rubyCapybaraInstructionsSnapshot,
81
+ },
82
+ },
83
+ csharp: {
84
+ selenium: {
85
+ instructions: constants.csharpInstructions,
86
+ snapshotInstruction: constants.csharpInstructionsSnapshot,
87
+ },
88
+ playwright: {
89
+ instructions: constants.csharpPlaywrightInstructions,
90
+ snapshotInstruction: constants.csharpPlaywrightInstructionsSnapshot,
91
+ },
92
+ },
93
+ };
94
+ /**
95
+ * Utility function to check if a given language and testing framework
96
+ * are supported by Percy Web.
97
+ */
98
+ export function isPercyWebFrameworkSupported(language, framework) {
99
+ const languageConfig = SUPPORTED_CONFIGURATIONS[language];
100
+ if (!languageConfig)
101
+ return false;
102
+ return !!languageConfig[framework];
103
+ }
@@ -0,0 +1,4 @@
1
+ import { RunTestsInstructionResult } from "../common/types.js";
2
+ import { SetUpPercyInput } from "../common/schema.js";
3
+ export declare let percyWebSetupInstructions: string;
4
+ export declare function runPercyWeb(input: SetUpPercyInput, percyToken: string): RunTestsInstructionResult;
@@ -0,0 +1,27 @@
1
+ import { SUPPORTED_CONFIGURATIONS } from "./frameworks.js";
2
+ export let percyWebSetupInstructions = "";
3
+ export function runPercyWeb(input, percyToken) {
4
+ const steps = [];
5
+ // Assume configuration is supported due to guardrails at orchestration layer
6
+ const languageConfig = SUPPORTED_CONFIGURATIONS[input.detectedLanguage];
7
+ const frameworkConfig = languageConfig[input.detectedBrowserAutomationFramework];
8
+ // Generate instructions for the supported configuration
9
+ const instructions = frameworkConfig.instructions;
10
+ percyWebSetupInstructions = frameworkConfig.snapshotInstruction;
11
+ // Prepend a step to set the Percy token in the environment
12
+ steps.push({
13
+ type: "instruction",
14
+ title: "Set Percy Token in Environment",
15
+ content: `Here is percy token if required {${percyToken}}`,
16
+ });
17
+ steps.push({
18
+ type: "instruction",
19
+ title: `Percy Web Setup Instructions`,
20
+ content: instructions,
21
+ });
22
+ return {
23
+ steps,
24
+ requiresPercy: true,
25
+ missingDependencies: [],
26
+ };
27
+ }
@@ -0,0 +1,4 @@
1
+ export { runPercyWeb } from "./handler.js";
2
+ export { SUPPORTED_CONFIGURATIONS } from "./frameworks.js";
3
+ export * as constants from "./constants.js";
4
+ export type { ConfigMapping } from "./types.js";
@@ -0,0 +1,4 @@
1
+ // Percy Web utilities
2
+ export { runPercyWeb } from "./handler.js";
3
+ export { SUPPORTED_CONFIGURATIONS } from "./frameworks.js";
4
+ export * as constants from "./constants.js";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Type for Percy Web configuration mapping.
3
+ * Structure: language -> automationFramework -> { instructions: string }
4
+ */
5
+ export type ConfigMapping = {
6
+ [language: string]: {
7
+ [automationFramework: string]: {
8
+ instructions: string;
9
+ snapshotInstruction: string;
10
+ };
11
+ };
12
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -32,7 +32,7 @@ export declare const CreateTestRunSchema: z.ZodObject<{
32
32
  host: string;
33
33
  } | undefined;
34
34
  test_cases?: string[] | undefined;
35
- run_state?: "new_run" | "in_progress" | "under_review" | "rejected" | "done" | "closed" | undefined;
35
+ run_state?: "done" | "new_run" | "in_progress" | "under_review" | "rejected" | "closed" | undefined;
36
36
  folder_ids?: number[] | undefined;
37
37
  }, {
38
38
  name: string;
@@ -43,7 +43,7 @@ export declare const CreateTestRunSchema: z.ZodObject<{
43
43
  host: string;
44
44
  } | undefined;
45
45
  test_cases?: string[] | undefined;
46
- run_state?: "new_run" | "in_progress" | "under_review" | "rejected" | "done" | "closed" | undefined;
46
+ run_state?: "done" | "new_run" | "in_progress" | "under_review" | "rejected" | "closed" | undefined;
47
47
  folder_ids?: number[] | undefined;
48
48
  }>;
49
49
  }, "strip", z.ZodTypeAny, {
@@ -57,7 +57,7 @@ export declare const CreateTestRunSchema: z.ZodObject<{
57
57
  host: string;
58
58
  } | undefined;
59
59
  test_cases?: string[] | undefined;
60
- run_state?: "new_run" | "in_progress" | "under_review" | "rejected" | "done" | "closed" | undefined;
60
+ run_state?: "done" | "new_run" | "in_progress" | "under_review" | "rejected" | "closed" | undefined;
61
61
  folder_ids?: number[] | undefined;
62
62
  };
63
63
  }, {
@@ -71,7 +71,7 @@ export declare const CreateTestRunSchema: z.ZodObject<{
71
71
  host: string;
72
72
  } | undefined;
73
73
  test_cases?: string[] | undefined;
74
- run_state?: "new_run" | "in_progress" | "under_review" | "rejected" | "done" | "closed" | undefined;
74
+ run_state?: "done" | "new_run" | "in_progress" | "under_review" | "rejected" | "closed" | undefined;
75
75
  folder_ids?: number[] | undefined;
76
76
  };
77
77
  }>;
@@ -12,23 +12,23 @@ export declare const UpdateTestRunSchema: z.ZodObject<{
12
12
  run_state: z.ZodOptional<z.ZodEnum<["new_run", "in_progress", "under_review", "rejected", "done", "closed"]>>;
13
13
  }, "strip", z.ZodTypeAny, {
14
14
  name?: string | undefined;
15
- run_state?: "new_run" | "in_progress" | "under_review" | "rejected" | "done" | "closed" | undefined;
15
+ run_state?: "done" | "new_run" | "in_progress" | "under_review" | "rejected" | "closed" | undefined;
16
16
  }, {
17
17
  name?: string | undefined;
18
- run_state?: "new_run" | "in_progress" | "under_review" | "rejected" | "done" | "closed" | undefined;
18
+ run_state?: "done" | "new_run" | "in_progress" | "under_review" | "rejected" | "closed" | undefined;
19
19
  }>;
20
20
  }, "strip", z.ZodTypeAny, {
21
21
  project_identifier: string;
22
22
  test_run: {
23
23
  name?: string | undefined;
24
- run_state?: "new_run" | "in_progress" | "under_review" | "rejected" | "done" | "closed" | undefined;
24
+ run_state?: "done" | "new_run" | "in_progress" | "under_review" | "rejected" | "closed" | undefined;
25
25
  };
26
26
  test_run_id: string;
27
27
  }, {
28
28
  project_identifier: string;
29
29
  test_run: {
30
30
  name?: string | undefined;
31
- run_state?: "new_run" | "in_progress" | "under_review" | "rejected" | "done" | "closed" | undefined;
31
+ run_state?: "done" | "new_run" | "in_progress" | "under_review" | "rejected" | "closed" | undefined;
32
32
  };
33
33
  test_run_id: string;
34
34
  }>;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@browserstack/mcp-server",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "BrowserStack's Official MCP Server",
5
+ "mcpName": "io.github.browserstack/mcp-server",
5
6
  "main": "dist/index.js",
6
7
  "repository": {
7
8
  "type": "git",
@@ -1,5 +0,0 @@
1
- export declare enum AppTestPlatform {
2
- ESPRESSO = "espresso",
3
- APPIUM = "appium",
4
- XCUITEST = "xcuitest"
5
- }
@@ -1,65 +0,0 @@
1
- // Framework mapping for Java Maven archetype generation
2
- const JAVA_FRAMEWORK_MAP = {
3
- testng: "testng",
4
- junit5: "junit5",
5
- junit4: "junit4",
6
- cucumber: "cucumber-testng",
7
- serenity: "serenity",
8
- };
9
- // Common Gradle setup instructions (platform-independent)
10
- const GRADLE_SETUP_INSTRUCTIONS = `
11
- **For Gradle setup:**
12
- 1. Add browserstack-java-sdk to dependencies:
13
- compileOnly 'com.browserstack:browserstack-java-sdk:latest.release'
14
-
15
- 2. Add browserstackSDK path variable:
16
- def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }
17
-
18
- 3. Add javaagent to gradle tasks:
19
- jvmArgs "-javaagent:\${browserstackSDKArtifact.file}"
20
- `;
21
- export function getSDKPrefixCommand(language, framework, username, accessKey) {
22
- switch (language) {
23
- case "nodejs":
24
- return `---STEP---
25
- Install BrowserStack Node SDK using command:
26
- \`\`\`bash
27
- npm i -D browserstack-node-sdk@latest
28
- \`\`\`
29
- ---STEP---
30
- Run the following command to setup browserstack sdk:
31
- \`\`\`bash
32
- npx setup --username ${username} --key ${accessKey}
33
- \`\`\`
34
- ---STEP---
35
- Edit the browserstack.yml file that was created in the project root to add your desired platforms and browsers.`;
36
- case "java": {
37
- const mavenFramework = getJavaFrameworkForMaven(framework);
38
- const isWindows = process.platform === "win32";
39
- const mavenCommand = isWindows
40
- ? `mvn archetype:generate -B -DarchetypeGroupId="com.browserstack" -DarchetypeArtifactId="browserstack-sdk-archetype-integrate" -DarchetypeVersion="1.0" -DgroupId="com.browserstack" -DartifactId="browserstack-sdk-archetype-integrate" -Dversion="1.0" -DBROWSERSTACK_USERNAME="${process.env.BROWSERSTACK_USERNAME}" -DBROWSERSTACK_ACCESS_KEY="${process.env.BROWSERSTACK_ACCESS_KEY}" -DBROWSERSTACK_FRAMEWORK="${mavenFramework}"`
41
- : `mvn archetype:generate -B -DarchetypeGroupId=com.browserstack \\
42
- -DarchetypeArtifactId=browserstack-sdk-archetype-integrate -DarchetypeVersion=1.0 \\
43
- -DgroupId=com.browserstack -DartifactId=browserstack-sdk-archetype-integrate -Dversion=1.0 \\
44
- -DBROWSERSTACK_USERNAME="${username}" \\
45
- -DBROWSERSTACK_ACCESS_KEY="${accessKey}" \\
46
- -DBROWSERSTACK_FRAMEWORK="${mavenFramework}"`;
47
- const platformLabel = isWindows ? "Windows" : "macOS/Linux";
48
- return `---STEP---
49
- Install BrowserStack Java SDK
50
-
51
- **Maven command for ${framework} (${platformLabel}):**
52
- Run the command, it is required to generate the browserstack-sdk-archetype-integrate project:
53
- ${mavenCommand}
54
-
55
- Alternative setup for Gradle users:
56
- ${GRADLE_SETUP_INSTRUCTIONS}`;
57
- }
58
- // Add more languages as needed
59
- default:
60
- return "";
61
- }
62
- }
63
- export function getJavaFrameworkForMaven(framework) {
64
- return JAVA_FRAMEWORK_MAP[framework] || framework;
65
- }
@@ -1,6 +0,0 @@
1
- import { SDKSupportedLanguage } from "./types.js";
2
- import { SDKSupportedBrowserAutomationFramework } from "./types.js";
3
- import { SDKSupportedTestingFramework } from "./types.js";
4
- export declare const getInstructionsForProjectConfiguration: (detectedBrowserAutomationFramework: SDKSupportedBrowserAutomationFramework, detectedTestingFramework: SDKSupportedTestingFramework, detectedLanguage: SDKSupportedLanguage, username: string, accessKey: string) => string;
5
- export declare function generateBrowserStackYMLInstructions(desiredPlatforms: string[], enablePercy?: boolean): string;
6
- export declare function formatInstructionsWithNumbers(instructionText: string, separator?: string): string;
@@ -1,99 +0,0 @@
1
- import { SUPPORTED_CONFIGURATIONS } from "./constants.js";
2
- const errorMessageSuffix = "Please open an issue at our Github repo: https://github.com/browserstack/browserstack-mcp-server/issues to request support for your project configuration";
3
- export const getInstructionsForProjectConfiguration = (detectedBrowserAutomationFramework, detectedTestingFramework, detectedLanguage, username, accessKey) => {
4
- const configuration = SUPPORTED_CONFIGURATIONS[detectedLanguage];
5
- if (!configuration) {
6
- throw new Error(`BrowserStack MCP Server currently does not support ${detectedLanguage}, ${errorMessageSuffix}`);
7
- }
8
- if (!configuration[detectedBrowserAutomationFramework]) {
9
- throw new Error(`BrowserStack MCP Server currently does not support ${detectedBrowserAutomationFramework} for ${detectedLanguage}, ${errorMessageSuffix}`);
10
- }
11
- if (!configuration[detectedBrowserAutomationFramework][detectedTestingFramework]) {
12
- throw new Error(`BrowserStack MCP Server currently does not support ${detectedTestingFramework} for ${detectedBrowserAutomationFramework} on ${detectedLanguage}, ${errorMessageSuffix}`);
13
- }
14
- const instructionFunction = configuration[detectedBrowserAutomationFramework][detectedTestingFramework]
15
- .instructions;
16
- return instructionFunction(username, accessKey);
17
- };
18
- export function generateBrowserStackYMLInstructions(desiredPlatforms, enablePercy = false) {
19
- let ymlContent = `
20
- # ======================
21
- # BrowserStack Reporting
22
- # ======================
23
- # Project and build names help organize your test runs in BrowserStack dashboard and Percy.
24
- # TODO: Replace these sample values with your actual project details
25
- projectName: Sample Project
26
- buildName: Sample Build
27
-
28
- # =======================================
29
- # Platforms (Browsers / Devices to test)
30
- # =======================================
31
- # Platforms object contains all the browser / device combinations you want to test on.
32
- # Generate this on the basis of the following platforms requested by the user:
33
- # Requested platforms: ${desiredPlatforms}
34
- platforms:
35
- - os: Windows
36
- osVersion: 11
37
- browserName: chrome
38
- browserVersion: latest
39
-
40
- # =======================
41
- # Parallels per Platform
42
- # =======================
43
- # The number of parallel threads to be used for each platform set.
44
- # BrowserStack's SDK runner will select the best strategy based on the configured value
45
- #
46
- # Example 1 - If you have configured 3 platforms and set \`parallelsPerPlatform\` as 2, a total of 6 (2 * 3) parallel threads will be used on BrowserStack
47
- #
48
- # Example 2 - If you have configured 1 platform and set \`parallelsPerPlatform\` as 5, a total of 5 (1 * 5) parallel threads will be used on BrowserStack
49
- parallelsPerPlatform: 1
50
-
51
- # =================
52
- # Local Testing
53
- # =================
54
- # Set to true to test local
55
- browserstackLocal: true
56
-
57
- # ===================
58
- # Debugging features
59
- # ===================
60
- debug: true # Visual logs, text logs, etc.
61
- testObservability: true # For Test Observability`;
62
- if (enablePercy) {
63
- ymlContent += `
64
-
65
- # =====================
66
- # Percy Visual Testing
67
- # =====================
68
- # Set percy to true to enable visual testing.
69
- # Set percyCaptureMode to 'manual' to control when screenshots are taken.
70
- percy: true
71
- percyCaptureMode: manual`;
72
- }
73
- return `
74
- Create a browserstack.yml file in the project root. The file should be in the following format:
75
-
76
- \`\`\`yaml${ymlContent}
77
- \`\`\`
78
- \n`;
79
- }
80
- export function formatInstructionsWithNumbers(instructionText, separator = "---STEP---") {
81
- // Split the instructions by the separator
82
- const steps = instructionText
83
- .split(separator)
84
- .map((step) => step.trim())
85
- .filter((step) => step.length > 0);
86
- // If no separators found, treat the entire text as one step
87
- if (steps.length === 1 && !instructionText.includes(separator)) {
88
- return `**Step 1:**\n${instructionText.trim()}\n\n**✅ Verification:**\nPlease verify that you have completed all the steps above to ensure proper setup.`;
89
- }
90
- // Format each step with numbering
91
- const formattedSteps = steps
92
- .map((step, index) => {
93
- return `**Step ${index + 1}:**\n${step.trim()}`;
94
- })
95
- .join("\n\n");
96
- // Add verification statement at the end
97
- const verificationText = `\n\n**✅ Verification:**\nPlease verify that you have completed all ${steps.length} steps above to ensure proper setup. If you encounter any issues, double-check each step and ensure all commands executed successfully.`;
98
- return formattedSteps + verificationText;
99
- }
@@ -1,3 +0,0 @@
1
- import { PercyConfigMapping } from "./types.js";
2
- export declare const nodejsSeleniumInstructions = "\nImport the BrowserStack Percy SDK in your test script:\nAdd the Percy import to your test file.\n\n---STEP---\n\nAdd screenshot capture method at required points:\nUse the `percy.snapshot(driver, name)` method at points in your test script where you want to capture screenshots.\n\n```javascript\nconst { percy } = require('browserstack-node-sdk');\ndescribe(\"sample Test\", () => {\n // ... other imports and setup\n \n test(\"my test\", async () => {\n // ....\n await percy.snapshot(driver, \"My Snapshot\")\n // ....\n });\n})\n```\n";
3
- export declare const PERCY_INSTRUCTIONS: PercyConfigMapping;
@@ -1,10 +0,0 @@
1
- import { SDKSupportedBrowserAutomationFramework, SDKSupportedLanguage, SDKSupportedTestingFramework } from "../types.js";
2
- import { PercyInstructions } from "./types.js";
3
- /**
4
- * Retrieves Percy-specific instructions for a given language and framework.
5
- */
6
- export declare function getPercyInstructions(language: SDKSupportedLanguage, automationFramework: SDKSupportedBrowserAutomationFramework, testingFramework: SDKSupportedTestingFramework): PercyInstructions | null;
7
- /**
8
- * Formats the retrieved Percy instructions into a user-friendly string.
9
- */
10
- export declare function formatPercyInstructions(instructions: PercyInstructions): string;
@@ -1,5 +0,0 @@
1
- import { SDKSupportedBrowserAutomationFramework, SDKSupportedLanguage, SDKSupportedTestingFramework } from "../types.js";
2
- export interface PercyInstructions {
3
- script_updates: string;
4
- }
5
- export type PercyConfigMapping = Partial<Record<SDKSupportedLanguage, Partial<Record<SDKSupportedBrowserAutomationFramework, Partial<Record<SDKSupportedTestingFramework, PercyInstructions>>>>>>;
@@ -1,40 +0,0 @@
1
- export declare enum SDKSupportedLanguageEnum {
2
- nodejs = "nodejs",
3
- python = "python",
4
- java = "java",
5
- csharp = "csharp"
6
- }
7
- export type SDKSupportedLanguage = keyof typeof SDKSupportedLanguageEnum;
8
- export declare enum SDKSupportedBrowserAutomationFrameworkEnum {
9
- playwright = "playwright",
10
- selenium = "selenium",
11
- cypress = "cypress",
12
- webdriverio = "webdriverio"
13
- }
14
- export type SDKSupportedBrowserAutomationFramework = keyof typeof SDKSupportedBrowserAutomationFrameworkEnum;
15
- export declare enum SDKSupportedTestingFrameworkEnum {
16
- jest = "jest",
17
- codeceptjs = "codeceptjs",
18
- playwright = "playwright",
19
- pytest = "pytest",
20
- robot = "robot",
21
- behave = "behave",
22
- cucumber = "cucumber",
23
- nightwatch = "nightwatch",
24
- webdriverio = "webdriverio",
25
- mocha = "mocha",
26
- junit4 = "junit4",
27
- junit5 = "junit5",
28
- testng = "testng",
29
- serenity = "serenity",
30
- cypress = "cypress",
31
- nunit = "nunit",
32
- mstest = "mstest",
33
- xunit = "xunit",
34
- specflow = "specflow",
35
- reqnroll = "reqnroll"
36
- }
37
- export type SDKSupportedTestingFramework = keyof typeof SDKSupportedTestingFrameworkEnum;
38
- export type ConfigMapping = Record<SDKSupportedLanguageEnum, Partial<Record<SDKSupportedBrowserAutomationFrameworkEnum, Partial<Record<SDKSupportedTestingFrameworkEnum, {
39
- instructions: (username: string, accessKey: string) => string;
40
- }>>>>>;