Skip to content

Commit 8287585

Browse files
refactor: update fetchAccessibilityIssues function to use cursor instead of nextPage for pagination
1 parent 40588dd commit 8287585

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/tools/accessibility.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ async function executeAccessibilityRAG(
138138
}
139139

140140
async function executeFetchAccessibilityIssues(
141-
args: { scanId: string; scanRunId: string; nextPage?: number },
141+
args: { scanId: string; scanRunId: string; cursor?: number },
142142
server: McpServer,
143143
config: BrowserStackConfig,
144144
): Promise<CallToolResult> {
@@ -153,7 +153,7 @@ async function executeFetchAccessibilityIssues(
153153
args.scanId,
154154
args.scanRunId,
155155
config,
156-
args.nextPage,
156+
args.cursor,
157157
);
158158
} catch (error) {
159159
return handleMCPError("fetchAccessibilityIssues", server, config, error);
@@ -164,29 +164,29 @@ async function fetchAccessibilityIssues(
164164
scanId: string,
165165
scanRunId: string,
166166
config: BrowserStackConfig,
167-
nextPage = 0,
167+
cursor = 0,
168168
): Promise<CallToolResult> {
169169
const reportFetcher = await initializeReportFetcher(config);
170170
const reportLink = await reportFetcher.getReportLink(scanId, scanRunId);
171171

172172
const { records, page_length, total_issues, next_page } =
173-
await parseAccessibilityReportFromCSV(reportLink, { nextPage });
173+
await parseAccessibilityReportFromCSV(reportLink, { nextPage: cursor });
174174

175175
const currentlyShown =
176-
nextPage === 0
176+
cursor === 0
177177
? page_length
178-
: Math.floor(nextPage / JSON.stringify(records[0] || {}).length) +
178+
: Math.floor(cursor / JSON.stringify(records[0] || {}).length) +
179179
page_length;
180180
const remainingIssues = total_issues - currentlyShown;
181181

182182
const messages = [
183-
`📊 Retrieved ${page_length} accessibility issues (Total: ${total_issues})`,
183+
`Retrieved ${page_length} accessibility issues (Total: ${total_issues})`,
184184
`Issues: ${JSON.stringify(records, null, 2)}`,
185185
];
186186

187187
if (next_page !== null) {
188188
messages.push(
189-
`📄 ${remainingIssues} more issues available. Use fetchAccessibilityIssues with nextPage: ${next_page} to get the next batch.`,
189+
`${remainingIssues} more issues available. Use fetchAccessibilityIssues with cursor: ${next_page} to get the next batch.`,
190190
);
191191
} else {
192192
messages.push(`✅ All issues retrieved.`);
@@ -344,19 +344,19 @@ function createScanSuccessResponse(
344344
scanId: string,
345345
scanRunId: string,
346346
reportUrl: string,
347-
nextPage: number | null,
347+
cursor: number | null,
348348
): CallToolResult {
349349
const messages = [
350-
`Accessibility scan "${name}" completed. check the BrowserStack dashboard for more details [https://scanner.browserstack.com/site-scanner/scan-details/${name}].`,
350+
`Accessibility scan "${name}" completed. check the BrowserStack dashboard for more details [https://scanner.browserstack.com/site-scanner/scan-details/${name}].`,
351351
`Scan ID: ${scanId} and Scan Run ID: ${scanRunId}`,
352352
`You can also download the full report from the following link: ${reportUrl}`,
353353
`We found ${totalIssues} issues. Below are the details of the ${pageLength} most critical issues.`,
354354
`Scan results: ${JSON.stringify(records, null, 2)}`,
355355
];
356356

357-
if (nextPage !== null) {
357+
if (cursor !== null) {
358358
messages.push(
359-
`📄 More issues available. Use fetchAccessibilityIssues tool with scanId: "${scanId}", scanRunId: "${scanRunId}", and nextPage: ${nextPage} to get the next batch.`,
359+
`More issues available. Use fetchAccessibilityIssues tool with scanId: "${scanId}", scanRunId: "${scanRunId}", and cursor: ${cursor} to get the next batch.`,
360360
);
361361
}
362362

@@ -486,15 +486,15 @@ export default function addAccessibilityTools(
486486

487487
tools.fetchAccessibilityIssues = server.tool(
488488
"fetchAccessibilityIssues",
489-
"Fetch accessibility issues from a completed scan with pagination support. Use nextPage parameter to get subsequent pages of results.",
489+
"Fetch accessibility issues from a completed scan with pagination support. Use cursor parameter to get subsequent pages of results.",
490490
{
491491
scanId: z
492492
.string()
493493
.describe("The scan ID from a completed accessibility scan"),
494494
scanRunId: z
495495
.string()
496496
.describe("The scan run ID from a completed accessibility scan"),
497-
nextPage: z
497+
cursor: z
498498
.number()
499499
.optional()
500500
.describe(

0 commit comments

Comments
 (0)