@browserstack/mcp-server 1.2.11 → 1.2.12-beta.1

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.
@@ -101,7 +101,7 @@ async function fetchAccessibilityIssues(scanId, scanRunId, config, cursor = 0) {
101
101
  async function executeAccessibilityScan(args, context, server, config) {
102
102
  try {
103
103
  trackMCP("startAccessibilityScan", server.server.getClientVersion(), undefined, config);
104
- return await runAccessibilityScan(args.name, args.pageURL, context, config, args.authConfigId);
104
+ return await runAccessibilityScan(args.name, args.pageURL, context, config, args.authConfigId, args.advancedRules);
105
105
  }
106
106
  catch (error) {
107
107
  return handleMCPError("startAccessibilityScan", server, config, error);
@@ -191,9 +191,9 @@ function createScanSuccessResponse(name, totalIssues, pageLength, records, scanI
191
191
  }
192
192
  return createSuccessResponse(messages);
193
193
  }
194
- async function runAccessibilityScan(name, pageURL, context, config, authConfigId) {
194
+ async function runAccessibilityScan(name, pageURL, context, config, authConfigId, advancedRules) {
195
195
  const scanner = await initializeScanner(config);
196
- const startResp = await scanner.startScan(name, [pageURL], authConfigId);
196
+ const startResp = await scanner.startScan(name, [pageURL], authConfigId, advancedRules);
197
197
  const scanId = startResp.data.id;
198
198
  const scanRunId = startResp.data.scanRunId;
199
199
  await notifyScanProgress(context, `Accessibility scan "${name}" started`, 0);
@@ -222,6 +222,10 @@ export default function addAccessibilityTools(server, config) {
222
222
  .number()
223
223
  .optional()
224
224
  .describe("Optional auth config ID for authenticated scans"),
225
+ advancedRules: z
226
+ .boolean()
227
+ .optional()
228
+ .describe("Enable advanced accessibility rules in the scan settings"),
225
229
  }, async (args, context) => {
226
230
  return await executeAccessibilityScan(args, context, server, config);
227
231
  });
@@ -22,17 +22,27 @@ export class AccessibilityReportFetcher {
22
22
  throw new Error(`Failed to initiate report: ${initData.error || initData.data.message}`);
23
23
  }
24
24
  const taskId = initData.data.task_id;
25
- // Fetch the generated CSV link
25
+ // Poll for the generated CSV link (task is async, may take a few seconds)
26
26
  const reportUrl = `https://api-accessibility.browserstack.com/api/website-scanner/v1/scans/${scanId}/scan_runs/issues?task_id=${encodeURIComponent(taskId)}`;
27
- // Use apiClient for the report link request as well
28
- const reportResp = await apiClient.get({
29
- url: reportUrl,
30
- headers: basicAuthHeader ? { Authorization: basicAuthHeader } : undefined,
31
- });
32
- const reportData = reportResp.data;
33
- if (!reportData.success) {
34
- throw new Error(`Failed to fetch report: ${reportData.error}`);
27
+ const maxAttempts = 3;
28
+ const pollIntervalMs = 2000;
29
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
30
+ const reportResp = await apiClient.get({
31
+ url: reportUrl,
32
+ headers: basicAuthHeader
33
+ ? { Authorization: basicAuthHeader }
34
+ : undefined,
35
+ });
36
+ const reportData = reportResp.data;
37
+ if (!reportData.success) {
38
+ throw new Error(`Failed to fetch report: ${reportData.error}`);
39
+ }
40
+ const link = reportData.data?.reportLink;
41
+ if (link) {
42
+ return link;
43
+ }
44
+ await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
35
45
  }
36
- return reportData.data.reportLink;
46
+ throw new Error(`Report link was not available after ${maxAttempts} attempts. The CSV generation may still be in progress.`);
37
47
  }
38
48
  }
@@ -19,7 +19,7 @@ export declare class AccessibilityScanner {
19
19
  username: string;
20
20
  password: string;
21
21
  }): void;
22
- startScan(name: string, urlList: string[], authConfigId?: number): Promise<AccessibilityScanResponse>;
22
+ startScan(name: string, urlList: string[], authConfigId?: number, advancedRules?: boolean): Promise<AccessibilityScanResponse>;
23
23
  pollStatus(scanId: string, scanRunId: string): Promise<AccessibilityScanStatus>;
24
24
  waitUntilComplete(scanId: string, scanRunId: string, context: any): Promise<string>;
25
25
  }
@@ -8,7 +8,7 @@ export class AccessibilityScanner {
8
8
  setAuth(auth) {
9
9
  this.auth = auth;
10
10
  }
11
- async startScan(name, urlList, authConfigId) {
11
+ async startScan(name, urlList, authConfigId, advancedRules) {
12
12
  if (!this.auth?.username || !this.auth?.password) {
13
13
  throw new Error("BrowserStack credentials are not set for AccessibilityScanner.");
14
14
  }
@@ -48,6 +48,9 @@ export class AccessibilityScanner {
48
48
  urlList: transformedUrlList,
49
49
  recurring: false,
50
50
  ...(authConfigId && { authConfigId }),
51
+ ...(advancedRules !== undefined && {
52
+ scanSettings: { advancedRules },
53
+ }),
51
54
  };
52
55
  let requestBody = baseRequestBody;
53
56
  if (hasLocal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browserstack/mcp-server",
3
- "version": "1.2.11",
3
+ "version": "1.2.12-beta.1",
4
4
  "description": "BrowserStack's Official MCP Server",
5
5
  "mcpName": "io.github.browserstack/mcp-server",
6
6
  "main": "dist/index.js",