Skip to main content
Glama

BrowserStack MCP server

Official
review-agent.ts2.33 kB
import { BrowserStackConfig } from "../lib/types.js"; import { getBrowserStackAuth } from "../lib/get-auth.js"; import { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; import { getPercyBuildCount } from "./review-agent-utils/build-counts.js"; import { getChangedPercySnapshotIds } from "./review-agent-utils/percy-snapshots.js"; import { PercyIntegrationTypeEnum } from "./sdk-utils/common/types.js"; import { fetchPercyToken } from "./sdk-utils/percy-web/fetchPercyToken.js"; import { getPercySnapshotDiffs, PercySnapshotDiff, } from "./review-agent-utils/percy-diffs.js"; export async function fetchPercyChanges( args: { project_name: string }, config: BrowserStackConfig, ): Promise<CallToolResult> { const { project_name } = args; const authorization = getBrowserStackAuth(config); // Get Percy token for the project const percyToken = await fetchPercyToken(project_name, authorization, { type: PercyIntegrationTypeEnum.WEB, }); // Get build info (noBuilds, isFirstBuild, lastBuildId) const { noBuilds, isFirstBuild, lastBuildId, orgId, browserIds } = await getPercyBuildCount(percyToken); if (noBuilds) { return { content: [ { type: "text", text: "No Percy builds found. Please run your first Percy scan to start visual testing.", }, ], }; } if (isFirstBuild || !lastBuildId) { return { content: [ { type: "text", text: "This is the first Percy build. No baseline exists to compare changes.", }, ], }; } // Get snapshot IDs for the latest build const snapshotIds = await getChangedPercySnapshotIds( lastBuildId, config, orgId, browserIds, ); // Fetch all diffs concurrently and flatten results const allDiffs = await getPercySnapshotDiffs(snapshotIds, percyToken); if (allDiffs.length === 0) { return { content: [ { type: "text", text: "AI Summary is not yet available for this build/framework. There may still be visual changes—please review the build on the dashboard.", }, ], }; } return { content: allDiffs.map((diff: PercySnapshotDiff) => ({ type: "text", text: `${diff.name} → ${diff.title}: ${diff.description ?? ""}`, })), }; }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/browserstack/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server