@browserstack/mcp-server 1.2.1 → 1.2.2-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.
- package/README.md +227 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/device-cache.d.ts +1 -0
- package/dist/lib/device-cache.js +28 -0
- package/dist/lib/inmemory-store.d.ts +1 -0
- package/dist/lib/inmemory-store.js +1 -0
- package/dist/lib/instrumentation.js +2 -0
- package/dist/oninitialized.js +4 -1
- package/dist/server-factory.js +3 -1
- package/dist/tools/accessibility.js +238 -78
- package/dist/tools/accessiblity-utils/auth-config.d.ts +39 -0
- package/dist/tools/accessiblity-utils/auth-config.js +125 -0
- package/dist/tools/accessiblity-utils/scanner.d.ts +1 -1
- package/dist/tools/accessiblity-utils/scanner.js +2 -1
- package/dist/tools/add-percy-snapshots.d.ts +5 -0
- package/dist/tools/add-percy-snapshots.js +17 -0
- package/dist/tools/appautomate-utils/appautomate.d.ts +2 -1
- package/dist/tools/appautomate-utils/appautomate.js +12 -9
- package/dist/tools/appautomate.js +56 -7
- package/dist/tools/applive-utils/start-session.d.ts +2 -1
- package/dist/tools/applive-utils/start-session.js +17 -6
- package/dist/tools/applive.d.ts +2 -1
- package/dist/tools/applive.js +21 -17
- package/dist/tools/bstack-sdk.d.ts +2 -15
- package/dist/tools/bstack-sdk.js +7 -124
- package/dist/tools/list-test-files.d.ts +2 -0
- package/dist/tools/list-test-files.js +33 -0
- package/dist/tools/percy-sdk.d.ts +4 -0
- package/dist/tools/percy-sdk.js +88 -0
- package/dist/tools/percy-snapshot-utils/constants.d.ts +16 -0
- package/dist/tools/percy-snapshot-utils/constants.js +500 -0
- package/dist/tools/percy-snapshot-utils/detect-test-files.d.ts +10 -0
- package/dist/tools/percy-snapshot-utils/detect-test-files.js +194 -0
- package/dist/tools/percy-snapshot-utils/types.d.ts +15 -0
- package/dist/tools/percy-snapshot-utils/utils.d.ts +4 -0
- package/dist/tools/percy-snapshot-utils/utils.js +30 -0
- package/dist/tools/sdk-utils/{commands.d.ts → bstack/commands.d.ts} +1 -1
- package/dist/tools/sdk-utils/bstack/commands.js +88 -0
- package/dist/tools/sdk-utils/bstack/configUtils.d.ts +4 -0
- package/dist/tools/sdk-utils/bstack/configUtils.js +66 -0
- package/dist/tools/sdk-utils/bstack/constants.d.ts +58 -0
- package/dist/tools/sdk-utils/{constants.js → bstack/constants.js} +128 -76
- package/dist/tools/sdk-utils/{constants.d.ts → bstack/frameworks.d.ts} +1 -1
- package/dist/tools/sdk-utils/bstack/frameworks.js +57 -0
- package/dist/tools/sdk-utils/bstack/index.d.ts +4 -0
- package/dist/tools/sdk-utils/bstack/index.js +5 -0
- package/dist/tools/sdk-utils/bstack/sdkHandler.d.ts +4 -0
- package/dist/tools/sdk-utils/bstack/sdkHandler.js +74 -0
- package/dist/tools/sdk-utils/common/constants.d.ts +10 -0
- package/dist/tools/sdk-utils/common/constants.js +86 -0
- package/dist/tools/sdk-utils/common/formatUtils.d.ts +5 -0
- package/dist/tools/sdk-utils/common/formatUtils.js +27 -0
- package/dist/tools/sdk-utils/common/index.d.ts +3 -0
- package/dist/tools/sdk-utils/common/index.js +4 -0
- package/dist/tools/sdk-utils/common/instructionUtils.d.ts +8 -0
- package/dist/tools/sdk-utils/common/instructionUtils.js +20 -0
- package/dist/tools/sdk-utils/common/schema.d.ts +61 -0
- package/dist/tools/sdk-utils/common/schema.js +28 -0
- package/dist/tools/sdk-utils/common/types.d.ts +66 -0
- package/dist/tools/sdk-utils/common/types.js +50 -0
- package/dist/tools/sdk-utils/common/utils.d.ts +25 -0
- package/dist/tools/sdk-utils/common/utils.js +84 -0
- package/dist/tools/sdk-utils/handler.d.ts +5 -0
- package/dist/tools/sdk-utils/handler.js +144 -0
- package/dist/tools/sdk-utils/percy-automate/constants.d.ts +11 -0
- package/dist/tools/sdk-utils/percy-automate/constants.js +365 -0
- package/dist/tools/sdk-utils/percy-automate/frameworks.d.ts +8 -0
- package/dist/tools/sdk-utils/percy-automate/frameworks.js +50 -0
- package/dist/tools/sdk-utils/percy-automate/handler.d.ts +3 -0
- package/dist/tools/sdk-utils/percy-automate/handler.js +30 -0
- package/dist/tools/sdk-utils/percy-automate/index.d.ts +1 -0
- package/dist/tools/sdk-utils/percy-automate/index.js +2 -0
- package/dist/tools/sdk-utils/percy-automate/types.d.ts +13 -0
- package/dist/tools/sdk-utils/percy-automate/types.js +1 -0
- package/dist/tools/sdk-utils/percy-bstack/constants.d.ts +4 -0
- package/dist/tools/sdk-utils/{percy → percy-bstack}/constants.js +13 -39
- package/dist/tools/sdk-utils/percy-bstack/frameworks.d.ts +2 -0
- package/dist/tools/sdk-utils/percy-bstack/frameworks.js +27 -0
- package/dist/tools/sdk-utils/percy-bstack/handler.d.ts +4 -0
- package/dist/tools/sdk-utils/percy-bstack/handler.js +99 -0
- package/dist/tools/sdk-utils/percy-bstack/index.d.ts +4 -0
- package/dist/tools/sdk-utils/percy-bstack/index.js +4 -0
- package/dist/tools/sdk-utils/percy-bstack/instructions.d.ts +7 -0
- package/dist/tools/sdk-utils/{percy → percy-bstack}/instructions.js +5 -9
- package/dist/tools/sdk-utils/percy-bstack/types.d.ts +13 -0
- package/dist/tools/sdk-utils/percy-bstack/types.js +5 -0
- package/dist/tools/sdk-utils/percy-web/constants.d.ts +41 -0
- package/dist/tools/sdk-utils/percy-web/constants.js +941 -0
- package/dist/tools/sdk-utils/percy-web/fetchPercyToken.d.ts +4 -0
- package/dist/tools/sdk-utils/percy-web/fetchPercyToken.js +28 -0
- package/dist/tools/sdk-utils/percy-web/frameworks.d.ts +7 -0
- package/dist/tools/sdk-utils/percy-web/frameworks.js +103 -0
- package/dist/tools/sdk-utils/percy-web/handler.d.ts +4 -0
- package/dist/tools/sdk-utils/percy-web/handler.js +27 -0
- package/dist/tools/sdk-utils/percy-web/index.d.ts +4 -0
- package/dist/tools/sdk-utils/percy-web/index.js +4 -0
- package/dist/tools/sdk-utils/percy-web/types.d.ts +12 -0
- package/dist/tools/sdk-utils/percy-web/types.js +1 -0
- package/dist/tools/sdk-utils/types.d.ts +2 -1
- package/dist/tools/sdk-utils/types.js +1 -0
- package/dist/tools/testmanagement-utils/create-testcase.d.ts +4 -0
- package/dist/tools/testmanagement-utils/create-testcase.js +6 -0
- package/package.json +1 -1
- package/dist/tools/sdk-utils/commands.js +0 -65
- package/dist/tools/sdk-utils/instructions.d.ts +0 -6
- package/dist/tools/sdk-utils/instructions.js +0 -99
- package/dist/tools/sdk-utils/percy/constants.d.ts +0 -3
- package/dist/tools/sdk-utils/percy/instructions.d.ts +0 -10
- package/dist/tools/sdk-utils/percy/types.d.ts +0 -5
- /package/dist/tools/{getFailureLogs.d.ts → get-failure-logs.d.ts} +0 -0
- /package/dist/tools/{getFailureLogs.js → get-failure-logs.js} +0 -0
- /package/dist/tools/{sdk-utils/percy → percy-snapshot-utils}/types.js +0 -0
package/README.md
CHANGED
|
@@ -35,6 +35,10 @@ Manage, execute, debug tests, and even fix code using plain English prompts.
|
|
|
35
35
|
#### Reduced context switching:
|
|
36
36
|
Stay in flow—keep all project context in one place and trigger actions directly from your IDE or LLM.
|
|
37
37
|
|
|
38
|
+
## ⚡️ One Click MCP Setup
|
|
39
|
+
|
|
40
|
+
[](http://mcp.browserstack.com/one-click-setup?client=vscode) [](http://mcp.browserstack.com/one-click-setup?client=cursor)
|
|
41
|
+
|
|
38
42
|
## 💡 Usage Examples
|
|
39
43
|
|
|
40
44
|
### 📱 Manual App Testing
|
|
@@ -138,6 +142,13 @@ Generate test cases from PRDs, convert manual tests to low-code automation, and
|
|
|
138
142
|
|
|
139
143
|
## 🛠️ Installation
|
|
140
144
|
|
|
145
|
+
### **One Click MCP Setup**
|
|
146
|
+
|
|
147
|
+
[](http://mcp.browserstack.com/one-click-setup?client=vscode) [](http://mcp.browserstack.com/one-click-setup?client=cursor)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
### **Alternate ways to Setup MCP server**
|
|
151
|
+
|
|
141
152
|
1. **Create a BrowserStack Account**
|
|
142
153
|
|
|
143
154
|
- Sign up for [BrowserStack](https://www.browserstack.com/users/sign_up) if you don't have an account already.
|
|
@@ -148,9 +159,21 @@ Generate test cases from PRDs, convert manual tests to low-code automation, and
|
|
|
148
159
|
- Once you have an account (and purchased appropriate plan), note down your `username` and `access_key` from [Account Settings](https://www.browserstack.com/accounts/profile/details).
|
|
149
160
|
|
|
150
161
|
2. Ensure you are using Node version >= `18.0`. Check your node version using `node --version`. Recommended version: `v22.15.0` (LTS)
|
|
162
|
+
|
|
151
163
|
3. **Install the MCP Server**
|
|
152
164
|
|
|
153
165
|
- VSCode (Copilot - Agent Mode): `.vscode/mcp.json`:
|
|
166
|
+
|
|
167
|
+
- Locate or Create the Configuration File:
|
|
168
|
+
In the root directory of your project, look for a folder named .vscode. This folder is usually hidden so you will need to find it as mentioned in the expand.
|
|
169
|
+
|
|
170
|
+
- If this folder doesn't exist, create it.
|
|
171
|
+
|
|
172
|
+
- Inside the .vscode folder, create a new file named mcp.json
|
|
173
|
+
|
|
174
|
+
- Add the Configuration: Open the mcp.json file and then add the following JSON content.
|
|
175
|
+
|
|
176
|
+
- Replace the username and <access_key> with your BrowserStack credentials.
|
|
154
177
|
|
|
155
178
|
```json
|
|
156
179
|
{
|
|
@@ -170,6 +193,30 @@ Generate test cases from PRDs, convert manual tests to low-code automation, and
|
|
|
170
193
|
- In VSCode, make sure to click on `Start` button in the MCP Server to start the server.
|
|
171
194
|

|
|
172
195
|
|
|
196
|
+
|
|
197
|
+
#### ** Alternate way to setup MCP on VSCode Copilot
|
|
198
|
+
|
|
199
|
+
1.Click on the gear icon to Select Tools
|
|
200
|
+
<div align="center">
|
|
201
|
+
<img src="assets/select_tools.png" alt="Select Tools" height="100">
|
|
202
|
+
</div>
|
|
203
|
+
2. A tool menu would appear at the top-centre, scroll down on the menu at the top and then Click on Add MCP Server
|
|
204
|
+
<div align="center">
|
|
205
|
+
<img src="assets/add_mcp_server.png" alt="Add MCP Server" height="100">
|
|
206
|
+
</div>
|
|
207
|
+
3. Select NPM package option (Install fron an NPM package) - 3rd in the list
|
|
208
|
+
<div align="center">
|
|
209
|
+
<img src="assets/select_npm_package.png" alt="Select NPM Package" height="100">
|
|
210
|
+
</div>
|
|
211
|
+
4. Enter NPM Package Name (@browserstack/mcp-server)
|
|
212
|
+
<div align="center">
|
|
213
|
+
<img src="assets/enter_npm_package.png" alt="Enter NPM Package" height="100">
|
|
214
|
+
</div>
|
|
215
|
+
5. Enter browserstack user name and access key
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
173
220
|
* For Cursor: `.cursor/mcp.json`:
|
|
174
221
|
|
|
175
222
|
```json
|
|
@@ -231,6 +278,186 @@ To install BrowserStack Test Platform Server for Claude Desktop automatically vi
|
|
|
231
278
|
npx -y @smithery/cli install @browserstack/mcp-server --client claude
|
|
232
279
|
```
|
|
233
280
|
|
|
281
|
+
|
|
282
|
+
### 💡 List of BrowserStack MCP Tools
|
|
283
|
+
|
|
284
|
+
As of now we support 20 tools.
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## 🧾 Test Management
|
|
290
|
+
|
|
291
|
+
1. `createProjectOrFolder` — Create a Test Management project and/or folders to organize test cases. Returns with Folder ID, Project ID and Test Management Link to access the TM Project Dashboard.
|
|
292
|
+
**Prompt example**
|
|
293
|
+
|
|
294
|
+
```text
|
|
295
|
+
Create a new Test Management project named 'Shopping App' with two folders - Login and Checkout
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
2. `createTestCase` — Add a manual test case under a specific project/folder (uses project identifier like PR-xxxxx and a folder ID).
|
|
300
|
+
**Prompt example**
|
|
301
|
+
|
|
302
|
+
```text
|
|
303
|
+
Add a test case named 'Invalid Login Scenario' to the Login folder in the 'Shopping App' project with PR-53617, Folder ID: 117869
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
3. `listTestCases` — List test cases for a project (supports filters like priority, status, tags).
|
|
307
|
+
**Prompt example**
|
|
308
|
+
|
|
309
|
+
```text
|
|
310
|
+
List all high-priority test cases in the 'Shopping App' project with project_identifier: PR-59457
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
4. `createTestRun` — Create a test run (suite) for selected test cases in a project.
|
|
314
|
+
**Prompt example**
|
|
315
|
+
|
|
316
|
+
```text
|
|
317
|
+
Create a test run for the Login folder in the 'Shopping App' project and name it 'Release v1.0 Login Flow'
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
5. `listTestRuns` — List test runs for a project (filter by dates, assignee, state).
|
|
321
|
+
**Prompt example**
|
|
322
|
+
|
|
323
|
+
```text
|
|
324
|
+
List all test runs from the 'Shopping App' project that were executed last week and are currently marked in-progress
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
6. `updateTestRun` — Partially update a test run (status, tags, notes, associated test cases).
|
|
328
|
+
**Prompt example**
|
|
329
|
+
|
|
330
|
+
```text
|
|
331
|
+
Update test run ID 1043 in the 'Shopping App' project and mark it as complete with the note 'Regression cycle done'
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
7. `addTestResult` — Add a manual execution result (passed/failed/blocked/skipped) for a test case within a run.
|
|
335
|
+
**Prompt example**
|
|
336
|
+
|
|
337
|
+
```text
|
|
338
|
+
Mark the test case 'Invalid Login Scenario' as passed in test run ID 1043 of the 'Shopping App' project
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
8. `createTestCasesFromFile` — Bulk-create test cases from an uploaded file (e.g., PDF).
|
|
342
|
+
**Prompt example**
|
|
343
|
+
|
|
344
|
+
```text
|
|
345
|
+
Upload test cases from '/Users/xyz/testcases.pdf' to the 'Shopping App' project in Test Management
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## ⚙️ BrowserStack SDK Setup / Automate Test
|
|
351
|
+
|
|
352
|
+
9. `setupBrowserStackAutomateTests` — Integrate BrowserStack SDK and run web tests on BrowserStack (optionally enable Percy).
|
|
353
|
+
**Prompt example**
|
|
354
|
+
|
|
355
|
+
```text
|
|
356
|
+
Run my Selenium-JUnit5 tests written in Java on Chrome and Firefox. Enable Percy for visual testing.
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
10. `fetchAutomationScreenshots` — Fetch screenshots captured during a given Automate/App Automate session.
|
|
360
|
+
**Prompt example**
|
|
361
|
+
|
|
362
|
+
```text
|
|
363
|
+
Get screenshots from Automate session ID abc123xyz for my desktop test run
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
## 🔍 Observability
|
|
369
|
+
|
|
370
|
+
11. `getFailureLogs` — Retrieve error logs for Automate/App Automate sessions (optionally by Build ID for App Automate).
|
|
371
|
+
**Prompt example**
|
|
372
|
+
|
|
373
|
+
```text
|
|
374
|
+
Get the error logs from the session ID: 21a864032a7459f1e7634222249b316759d6827f, Build ID: dt7ung4wmjittzff8kksrjadjax9gzvbscoyf9qn of App Automate test session
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## 📱 App Live
|
|
380
|
+
|
|
381
|
+
12. `runAppLiveSession` — Start a manual app testing session on a real device in the cloud.
|
|
382
|
+
**Prompt example**
|
|
383
|
+
|
|
384
|
+
```text
|
|
385
|
+
Open my app on iPhone 15 Pro Max with iOS 17. App path is /Users/xyz/app.ipa
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## 💻 Live
|
|
391
|
+
|
|
392
|
+
13. `runBrowserLiveSession` — Start a Live session for website testing on desktop or mobile browsers.
|
|
393
|
+
**Prompt example**
|
|
394
|
+
|
|
395
|
+
```text
|
|
396
|
+
Open www.google.com on the latest version of Microsoft Edge on Windows 11
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## 📲 App Automate
|
|
402
|
+
|
|
403
|
+
14. `takeAppScreenshot` — Launch the app on a specified device and captures a quick verification screenshot. This tool is just to verify whether your app has been launched.
|
|
404
|
+
**Prompt example**
|
|
405
|
+
|
|
406
|
+
```text
|
|
407
|
+
Take a screenshot of my app on Google Pixel 6 with Android 14 while testing on App Automate. App file path: /Users/xyz/app-debug.apk
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
15. `runAppTestsOnBrowserStack` — Run automated mobile tests (Espresso/XCUITest, etc.) on real devices.
|
|
411
|
+
**Prompt example**
|
|
412
|
+
|
|
413
|
+
```text
|
|
414
|
+
Run Espresso tests from /tests/checkout.zip on Galaxy S21 and Pixel 6 with Android 14. App path is /apps/beta-release.apk under project 'Checkout Flow'
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## ♿ Accessibility
|
|
420
|
+
|
|
421
|
+
16. `accessibilityExpert` — Ask A11y Expert (WCAG 2.0/2.1/2.2, mobile/web usability, best practices).
|
|
422
|
+
**Prompt example**
|
|
423
|
+
|
|
424
|
+
```text
|
|
425
|
+
What WCAG guidelines apply to form field error messages on mobile web?
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
17. `startAccessibilityScan` — Start a web accessibility scan and return the result link.
|
|
429
|
+
**Prompt example**
|
|
430
|
+
|
|
431
|
+
```text
|
|
432
|
+
Run accessibility scan for "www.example.com"
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
## 🤖 BrowserStack AI Agents
|
|
438
|
+
|
|
439
|
+
18. `fetchSelfHealedSelectors` — Retrieve AI self-healed selectors to fix flaky tests due to DOM changes.
|
|
440
|
+
**Prompt example**
|
|
441
|
+
|
|
442
|
+
```text
|
|
443
|
+
Fetch and fix flaky test selectors in Automate session ID session_9482 using MCP
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
19. `createLCASteps` — Generate Low Code Automation steps from a manual test case in Test Management.
|
|
447
|
+
**Prompt example**
|
|
448
|
+
|
|
449
|
+
```text
|
|
450
|
+
Convert the manual test case 'Add to Cart' in the 'Shopping App' project into LCA steps
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
20. `uploadProductRequirementFile` — Upload a PRD/screenshot/PDF and get a file mapping ID (used with `createTestCasesFromFile`).
|
|
454
|
+
**Prompt example**
|
|
455
|
+
|
|
456
|
+
```text
|
|
457
|
+
Upload PRD from /Users/xyz/Desktop/login-flow.pdf and use BrowserStack AI to generate test cases
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
|
|
234
461
|
## 🤝 Recommended MCP Clients
|
|
235
462
|
|
|
236
463
|
- We recommend using **Github Copilot or Cursor** for automated testing + debugging use cases.
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,3 +7,4 @@ export declare enum BrowserStackProducts {
|
|
|
7
7
|
* Fetches and caches BrowserStack datasets (live + app_live + app_automate) with a shared TTL.
|
|
8
8
|
*/
|
|
9
9
|
export declare function getDevicesAndBrowsers(type: BrowserStackProducts): Promise<any>;
|
|
10
|
+
export declare function shouldSendStartedEvent(): boolean;
|
package/dist/lib/device-cache.js
CHANGED
|
@@ -2,9 +2,11 @@ import fs from "fs";
|
|
|
2
2
|
import os from "os";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { apiClient } from "./apiClient.js";
|
|
5
|
+
import config from "../config.js";
|
|
5
6
|
const CACHE_DIR = path.join(os.homedir(), ".browserstack", "combined_cache");
|
|
6
7
|
const CACHE_FILE = path.join(CACHE_DIR, "data.json");
|
|
7
8
|
const TTL_MS = 24 * 60 * 60 * 1000; // 1 day
|
|
9
|
+
const TTL_STARTED_MS = 3 * 60 * 60 * 1000; // 3 Hours
|
|
8
10
|
export var BrowserStackProducts;
|
|
9
11
|
(function (BrowserStackProducts) {
|
|
10
12
|
BrowserStackProducts["LIVE"] = "live";
|
|
@@ -49,3 +51,29 @@ export async function getDevicesAndBrowsers(type) {
|
|
|
49
51
|
fs.writeFileSync(CACHE_FILE, JSON.stringify(cache), "utf8");
|
|
50
52
|
return cache[type];
|
|
51
53
|
}
|
|
54
|
+
// Rate limiter for started event (3H)
|
|
55
|
+
export function shouldSendStartedEvent() {
|
|
56
|
+
try {
|
|
57
|
+
if (config && config.REMOTE_MCP) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (!fs.existsSync(CACHE_DIR)) {
|
|
61
|
+
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
|
62
|
+
}
|
|
63
|
+
let cache = {};
|
|
64
|
+
if (fs.existsSync(CACHE_FILE)) {
|
|
65
|
+
const raw = fs.readFileSync(CACHE_FILE, "utf8");
|
|
66
|
+
cache = JSON.parse(raw || "{}");
|
|
67
|
+
const last = parseInt(cache.lastStartedEvent, 10);
|
|
68
|
+
if (!isNaN(last) && Date.now() - last < TTL_STARTED_MS) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
cache.lastStartedEvent = Date.now();
|
|
73
|
+
fs.writeFileSync(CACHE_FILE, JSON.stringify(cache, null, 2), "utf8");
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -4,6 +4,7 @@ import { createRequire } from "module";
|
|
|
4
4
|
const require = createRequire(import.meta.url);
|
|
5
5
|
const packageJson = require("../../package.json");
|
|
6
6
|
import axios from "axios";
|
|
7
|
+
import globalConfig from "../config.js";
|
|
7
8
|
export function trackMCP(toolName, clientInfo, error, config) {
|
|
8
9
|
const instrumentationEndpoint = "https://api.browserstack.com/sdk/v1/event";
|
|
9
10
|
const isSuccess = !error;
|
|
@@ -22,6 +23,7 @@ export function trackMCP(toolName, clientInfo, error, config) {
|
|
|
22
23
|
tool_name: toolName,
|
|
23
24
|
mcp_client: mcpClient,
|
|
24
25
|
success: isSuccess,
|
|
26
|
+
is_remote: globalConfig.REMOTE_MCP,
|
|
25
27
|
},
|
|
26
28
|
};
|
|
27
29
|
// Add error details if applicable
|
package/dist/oninitialized.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { trackMCP } from "./lib/instrumentation.js";
|
|
2
|
+
import { shouldSendStartedEvent } from "./lib/device-cache.js";
|
|
2
3
|
export function setupOnInitialized(server, config) {
|
|
3
4
|
const nodeVersion = process.versions.node;
|
|
4
5
|
// Check for Node.js version
|
|
@@ -6,6 +7,8 @@ export function setupOnInitialized(server, config) {
|
|
|
6
7
|
throw new Error("Node version is not supported. Please upgrade to 18.0.0 or later.");
|
|
7
8
|
}
|
|
8
9
|
server.server.oninitialized = () => {
|
|
9
|
-
|
|
10
|
+
if (shouldSendStartedEvent()) {
|
|
11
|
+
trackMCP("started", server.server.getClientVersion(), undefined, config);
|
|
12
|
+
}
|
|
10
13
|
};
|
|
11
14
|
}
|
package/dist/server-factory.js
CHANGED
|
@@ -4,11 +4,12 @@ const require = createRequire(import.meta.url);
|
|
|
4
4
|
const packageJson = require("../package.json");
|
|
5
5
|
import logger from "./logger.js";
|
|
6
6
|
import addSDKTools from "./tools/bstack-sdk.js";
|
|
7
|
+
import addPercyTools from "./tools/percy-sdk.js";
|
|
7
8
|
import addBrowserLiveTools from "./tools/live.js";
|
|
8
9
|
import addAccessibilityTools from "./tools/accessibility.js";
|
|
9
10
|
import addTestManagementTools from "./tools/testmanagement.js";
|
|
10
11
|
import addAppAutomationTools from "./tools/appautomate.js";
|
|
11
|
-
import addFailureLogsTools from "./tools/
|
|
12
|
+
import addFailureLogsTools from "./tools/get-failure-logs.js";
|
|
12
13
|
import addAutomateTools from "./tools/automate.js";
|
|
13
14
|
import addSelfHealTools from "./tools/selfheal.js";
|
|
14
15
|
import addAppLiveTools from "./tools/applive.js";
|
|
@@ -38,6 +39,7 @@ export class BrowserStackMcpServer {
|
|
|
38
39
|
const toolAdders = [
|
|
39
40
|
addAccessibilityTools,
|
|
40
41
|
addSDKTools,
|
|
42
|
+
addPercyTools,
|
|
41
43
|
addAppLiveTools,
|
|
42
44
|
addBrowserLiveTools,
|
|
43
45
|
addTestManagementTools,
|