@testingbot/mcp-server 1.2.0 → 1.4.0

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 (60) hide show
  1. package/README.md +85 -29
  2. package/dist/lib/tool-annotations.d.ts +11 -0
  3. package/dist/lib/tool-annotations.d.ts.map +1 -0
  4. package/dist/lib/tool-annotations.js +100 -0
  5. package/dist/lib/tool-annotations.js.map +1 -0
  6. package/dist/prompts.d.ts +30 -0
  7. package/dist/prompts.d.ts.map +1 -0
  8. package/dist/prompts.js +105 -0
  9. package/dist/prompts.js.map +1 -0
  10. package/dist/resources.d.ts +24 -0
  11. package/dist/resources.d.ts.map +1 -0
  12. package/dist/resources.js +110 -0
  13. package/dist/resources.js.map +1 -0
  14. package/dist/server-factory.d.ts +10 -1
  15. package/dist/server-factory.d.ts.map +1 -1
  16. package/dist/server-factory.js +57 -18
  17. package/dist/server-factory.js.map +1 -1
  18. package/dist/tools/accessibility.d.ts +45 -0
  19. package/dist/tools/accessibility.d.ts.map +1 -0
  20. package/dist/tools/accessibility.js +153 -0
  21. package/dist/tools/accessibility.js.map +1 -0
  22. package/dist/tools/ai-analysis.d.ts +19 -0
  23. package/dist/tools/ai-analysis.d.ts.map +1 -0
  24. package/dist/tools/ai-analysis.js +128 -0
  25. package/dist/tools/ai-analysis.js.map +1 -0
  26. package/dist/tools/app-automate.js +3 -3
  27. package/dist/tools/app-automate.js.map +1 -1
  28. package/dist/tools/browsers.d.ts.map +1 -1
  29. package/dist/tools/browsers.js +15 -5
  30. package/dist/tools/browsers.js.map +1 -1
  31. package/dist/tools/builds.js +3 -3
  32. package/dist/tools/builds.js.map +1 -1
  33. package/dist/tools/cdp.js +2 -2
  34. package/dist/tools/cdp.js.map +1 -1
  35. package/dist/tools/live.d.ts.map +1 -1
  36. package/dist/tools/live.js +10 -3
  37. package/dist/tools/live.js.map +1 -1
  38. package/dist/tools/logs.js +1 -1
  39. package/dist/tools/logs.js.map +1 -1
  40. package/dist/tools/maestro.js +6 -6
  41. package/dist/tools/maestro.js.map +1 -1
  42. package/dist/tools/project.js +1 -1
  43. package/dist/tools/project.js.map +1 -1
  44. package/dist/tools/screenshots.js +3 -3
  45. package/dist/tools/screenshots.js.map +1 -1
  46. package/dist/tools/storage.js +4 -4
  47. package/dist/tools/storage.js.map +1 -1
  48. package/dist/tools/team.js +18 -18
  49. package/dist/tools/team.js.map +1 -1
  50. package/dist/tools/tests.js +5 -5
  51. package/dist/tools/tests.js.map +1 -1
  52. package/dist/tools/tunnels.js +2 -2
  53. package/dist/tools/tunnels.js.map +1 -1
  54. package/dist/tools/user.js +2 -2
  55. package/dist/tools/user.js.map +1 -1
  56. package/dist/tools/visual.d.ts +41 -0
  57. package/dist/tools/visual.d.ts.map +1 -0
  58. package/dist/tools/visual.js +165 -0
  59. package/dist/tools/visual.js.map +1 -0
  60. package/package.json +5 -6
package/README.md CHANGED
@@ -10,7 +10,7 @@ TestingBot's official Model Context Protocol (MCP) server implementation. This s
10
10
 
11
11
  [![Install in VS Code](https://img.shields.io/badge/Install-VS_Code-007ACC?style=for-the-badge&logo=visualstudiocode&logoColor=white)](https://testingbot.com/mcp/install?client=vscode) [![Install in Cursor](https://img.shields.io/badge/Install-Cursor-000000?style=for-the-badge&logo=cursor&logoColor=white)](https://testingbot.com/mcp/install?client=cursor)
12
12
 
13
- **Claude Desktop**: download `mcp-server.mcpb` from the [releases page](https://github.com/testingbot/mcp-server/releases) and double-click it. Claude will set up the TestingBot MCP server automatically.
13
+ **Claude Desktop**: download `testingbot-mcp-server-<version>.mcpb` from the [latest release](https://github.com/testingbot/mcp-server/releases/latest) and double-click it. Claude will set up the TestingBot MCP server automatically.
14
14
 
15
15
  After install, set your credentials from [TestingBot account settings](https://testingbot.com/members/user/security).
16
16
 
@@ -195,7 +195,7 @@ The agent calls `startTunnel`, which needs **Java 17+**. The tool returns the tu
195
195
  | --- | --- |
196
196
  | `tb_openBrowser` (agent-driven browser) | `tunnelIdentifier` (**required**: sessions without it go direct). Or set `TESTINGBOT_TUNNEL_IDENTIFIER` |
197
197
  | `appium_session_management` (native apps) | `"tb:options": {"tunnel-identifier": "…"}` in the capabilities |
198
- | `startLiveSession` / `startDesktopLiveSession` / `startMobileLiveSession` | `tunnelId` (the numeric ID) |
198
+ | `startLiveSession` | `tunnelId` (the numeric ID) |
199
199
  | `runMaestroTest` | `tunnelIdentifier`. Without it, the account's newest running tunnel is used |
200
200
  | `takeScreenshot`, `runAppAutomateTest` (Espresso / XCUITest) | The account's newest running tunnel is used automatically |
201
201
 
@@ -224,32 +224,7 @@ Start an interactive live testing session on TestingBot. Returns a link that ope
224
224
  > "Start a live testing session on Chrome latest with Windows 11 for https://example.com"
225
225
  > "Open https://myapp.com on iPhone 14 with iOS 16 for manual testing"
226
226
 
227
- #### `startDesktopLiveSession`
228
- Convenience tool to start a desktop browser live testing session.
229
-
230
- **Parameters:**
231
- - `desiredURL`: The URL to open
232
- - `desiredOS`: Windows, Mac, or Linux
233
- - `desiredOSVersion`: OS version
234
- - `desiredBrowser`: chrome, firefox, safari, edge, or ie
235
- - `desiredBrowserVersion` (optional): Browser version or "latest" (default: latest)
236
- - `tunnelId` (optional): Numeric ID of a running tunnel, for localhost / private URLs
237
-
238
- **Example prompt:**
239
- > "Start desktop live session on Firefox 120 with Mac Monterey for https://example.com"
240
-
241
- #### `startMobileLiveSession`
242
- Convenience tool to start a mobile device live testing session.
243
-
244
- **Parameters:**
245
- - `desiredURL`: The URL to open
246
- - `desiredOS`: android or ios
247
- - `desiredOSVersion`: OS version
248
- - `desiredDevice`: Device name
249
- - `tunnelId` (optional): Numeric ID of a running tunnel, for localhost / private URLs
250
-
251
- **Example prompt:**
252
- > "Start mobile live session on Galaxy S23 with Android 13 for https://example.com"
227
+ `startDesktopLiveSession` and `startMobileLiveSession` are deprecated: `startLiveSession` covers both with `platformType`. They still work for now, but are no longer listed and will be removed in a later release.
253
228
 
254
229
  ### Browser & Device Management
255
230
 
@@ -331,6 +306,27 @@ Stop a running test by session ID.
331
306
  **Example prompt:**
332
307
  > "Stop test abc123"
333
308
 
309
+ ### AI Failure Analysis
310
+
311
+ Explanations from [TestingBot AI Insights](https://testingbot.com/support/ai/insights): summary, root cause, timeline, log evidence, suggested fixes, a failure category, the likely owner and a confidence score. The account owner must first enable **AI Analysis** in Account Settings, which records consent to sending curated, secret-masked test logs to TestingBot's AI provider; until then both tools say how to turn it on and nothing is sent.
312
+
313
+ #### `analyzeTestFailure`
314
+ Start (or reuse) an AI failure analysis of a finished test and wait for the result. A current analysis is returned without extra cost.
315
+
316
+ **Parameters:**
317
+ - `sessionId`: Session ID (or numeric test ID)
318
+ - `force` (optional): Run a fresh analysis even if one exists
319
+ - `waitSeconds` (optional): How long to wait for the result (default 90, 0 returns immediately)
320
+
321
+ **Example prompt:**
322
+ > "Why did test abc123 fail?"
323
+
324
+ #### `getAiFailureAnalysis`
325
+ Read an existing analysis. Never starts one.
326
+
327
+ **Parameters:**
328
+ - `sessionId`: Session ID (or numeric test ID)
329
+
334
330
  ### Build Management
335
331
 
336
332
  #### `getBuilds`
@@ -503,6 +499,44 @@ Start a run. Returns immediately with the run ID.
503
499
  #### `getAppAutomateRunStatus` / `getAppAutomateRunResults`
504
500
  Poll run progress, then fetch per-run outcomes and the JUnit XML report. Each run's Appium session ID is surfaced, so `getTestDetails` / `getFailureLogs` work for logs and video.
505
501
 
502
+ ### Visual Testing Review
503
+
504
+ Review [hosted visual tests](https://testingbot.com/support/visual-testing/ci#review-api): find failed runs, see what changed, approve or reject. When the account owner has turned on AI region names, each changed region carries a one-line AI description of the change; reading a run never sends anything to an AI provider.
505
+
506
+ #### `getVisualTests`
507
+ List hosted visual tests. **Parameters:** `offset`, `limit` (optional)
508
+
509
+ #### `getVisualRuns`
510
+ List visual runs, newest first. **Parameters:** `testId`, `state` (`failed`, `unreviewed`, `passed`), `offset`, `limit` (all optional)
511
+
512
+ #### `explainVisualRun`
513
+ What changed in a run: regions with names, AI change descriptions, text and CSS changes, and image links. **Parameters:** `runId`
514
+
515
+ **Example prompt:**
516
+ > "Which visual tests failed today, and what changed on the pricing page?"
517
+
518
+ #### `reviewVisualRun`
519
+ Approve or reject a run. **Parameters:** `runId`, `decision` (`approve`/`reject`), `makeBaseline` (optional, with approve)
520
+
521
+ ### Accessibility Testing
522
+
523
+ Results of scheduled [accessibility scans](https://testingbot.com/support/accessibility), scored like the dashboard: WCAG A/AA violations decide pass/fail; needs-review items and best-practice recommendations do not. Automated checks cover only part of WCAG.
524
+
525
+ #### `getAccessibilityTests`
526
+ Scheduled accessibility tests with their latest result. **Parameters:** `offset`, `limit` (optional)
527
+
528
+ #### `getAccessibilityRuns`
529
+ Scans of one test, newest first. **Parameters:** `testId`, `offset`, `limit`
530
+
531
+ #### `getAccessibilityFindings`
532
+ Failing rules with the elements (selector, HTML, how to fix) and what is new or resolved since the previous scan. **Parameters:** `runId`, `elementsPerRule` (optional, default 5)
533
+
534
+ **Example prompt:**
535
+ > "What accessibility issues does our checkout page have, and which are new since the last scan?"
536
+
537
+ #### `runAccessibilityTest`
538
+ Start a scan now. **Parameters:** `testId`
539
+
506
540
  ### Screenshot Testing
507
541
 
508
542
  #### `takeScreenshot`
@@ -566,11 +600,12 @@ Update user account information.
566
600
  ### Team Management
567
601
 
568
602
  #### `getTeam`
569
- Get team information including concurrency limits, allowed parallel VMs, and mobile concurrency.
603
+ Get team information including concurrency: parallel sessions allowed, running right now and queued (waiting for a free slot), for VMs and physical devices. Counts are team-wide and match the dashboard.
570
604
 
571
605
  **Example prompt:**
572
606
  > "Show my team information"
573
607
  > "What are my team's concurrency limits?"
608
+ > "How many of my tests are running or queued right now?"
574
609
 
575
610
  #### `getUsersInTeam`
576
611
  List all users in your team with their roles and access levels.
@@ -648,6 +683,27 @@ Delete an active TestingBot tunnel by ID. This terminates the tunnel connection.
648
683
  **Example prompt:**
649
684
  > "Delete tunnel 12345"
650
685
 
686
+ ## Prompts, Resources and Agent Skills
687
+
688
+ Besides tools, the server offers MCP **prompts**: task recipes your client can show as slash commands:
689
+
690
+ | Prompt | Arguments | What it does |
691
+ | --- | --- | --- |
692
+ | `why-did-my-test-fail` | `sessionId` | Test status, AI failure analysis when enabled, failing log lines, likely cause and fixes |
693
+ | `summarise-build` | `buildId` | Pass/fail counts, failures grouped by shared cause, what to fix first |
694
+ | `find-flaky-tests` | `timeRange` (optional, default `30d`) | Tests that both passed and failed, and why each is unstable |
695
+
696
+ and read-only **resources** a client can attach to a conversation:
697
+
698
+ | URI | Content |
699
+ | --- | --- |
700
+ | `testingbot://tests/{sessionId}` | Test details (JSON) |
701
+ | `testingbot://tests/{sessionId}/logs/{logType}` | One log file, last 200 KB (`selenium`, `browser`, `chrome`, `vm`, `appium`) |
702
+ | `testingbot://builds/{buildId}` | Tests in a build (JSON) |
703
+ | `testingbot://insights/flaky-tests` | Flaky tests over the last 30 days; `?time_range=7d` to change it |
704
+
705
+ The same recipes ship as agent skills in [`skills/`](skills/) (one `SKILL.md` per task) for agents that load skills from files.
706
+
651
707
  ## Usage Examples
652
708
 
653
709
  ### Example 1: Running Cross-Browser Tests
@@ -0,0 +1,11 @@
1
+ /**
2
+ * MCP tool annotations for this server's own tools. Clients use them to decide
3
+ * when to ask before running a tool; directories such as Glama use them to rate
4
+ * how well a tool is described. The browser (tb_*) and appium tools from
5
+ * @testingbot/automation-mcp carry their own.
6
+ *
7
+ * A test fails when a tool is registered without an entry here.
8
+ */
9
+ import { type ToolAnnotations } from "@testingbot/automation-mcp";
10
+ export declare const TOOL_ANNOTATIONS: Record<string, ToolAnnotations>;
11
+ //# sourceMappingURL=tool-annotations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-annotations.d.ts","sourceRoot":"","sources":["../../src/lib/tool-annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAC;AAKpC,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAoG5D,CAAC"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * MCP tool annotations for this server's own tools. Clients use them to decide
3
+ * when to ask before running a tool; directories such as Glama use them to rate
4
+ * how well a tool is described. The browser (tb_*) and appium tools from
5
+ * @testingbot/automation-mcp carry their own.
6
+ *
7
+ * A test fails when a tool is registered without an entry here.
8
+ */
9
+ import { DESTRUCTIVE, READ, WRITE, WRITE_IDEMPOTENT, } from "@testingbot/automation-mcp";
10
+ /** Reads this machine only (files, built-in docs); never calls TestingBot. */
11
+ const LOCAL_READ = { ...READ, openWorldHint: false };
12
+ export const TOOL_ANNOTATIONS = {
13
+ // Account and team
14
+ tb_login: { ...WRITE_IDEMPOTENT, title: "Log in to TestingBot" },
15
+ getUserInfo: { ...READ, title: "Show my account" },
16
+ updateUserInfo: { ...WRITE_IDEMPOTENT, title: "Update my account details" },
17
+ getTeam: { ...READ, title: "Show team plan and concurrency" },
18
+ getUsersInTeam: { ...READ, title: "List team members" },
19
+ getUserFromTeam: { ...READ, title: "Show a team member" },
20
+ // Browser and device catalog
21
+ getBrowsers: { ...READ, title: "List browsers and emulators" },
22
+ getDevices: { ...READ, title: "List real devices" },
23
+ // Tests and builds
24
+ getTests: { ...READ, title: "List recent tests" },
25
+ getTestDetails: { ...READ, title: "Show a test" },
26
+ getFailureLogs: { ...READ, title: "Read a test's logs" },
27
+ updateTest: { ...WRITE_IDEMPOTENT, title: "Update a test's name or status" },
28
+ deleteTest: { ...DESTRUCTIVE, title: "Delete a test" },
29
+ stopTest: { ...DESTRUCTIVE, title: "Stop a running test" },
30
+ getBuilds: { ...READ, title: "List builds" },
31
+ getTestsForBuild: { ...READ, title: "List a build's tests" },
32
+ deleteBuild: { ...DESTRUCTIVE, title: "Delete a build and its tests" },
33
+ // AI failure analysis: starting one sends logs to the AI provider and counts
34
+ // towards the account's AI limits; a current analysis is reused.
35
+ getAiFailureAnalysis: { ...READ, title: "Read a test's AI failure analysis" },
36
+ analyzeTestFailure: { ...WRITE, title: "Explain a test failure with AI" },
37
+ // Live sessions: only build a dashboard link; the user presses Start.
38
+ startLiveSession: { ...READ, title: "Link to a live session" },
39
+ // Remote browser for the user's own CDP client: starts a billed session.
40
+ createCdpSession: { ...WRITE, title: "Start a browser for CDP" },
41
+ // Screenshots
42
+ takeScreenshot: { ...WRITE, title: "Screenshot a URL in many browsers" },
43
+ retrieveScreenshots: { ...READ, title: "Get screenshot results" },
44
+ getScreenshotList: { ...READ, title: "List screenshot jobs" },
45
+ // Storage
46
+ uploadFile: { ...WRITE, title: "Upload a local app" },
47
+ uploadRemoteFile: { ...WRITE, title: "Upload an app from a URL" },
48
+ getStorageFiles: { ...READ, title: "List uploaded apps" },
49
+ deleteStorageFile: { ...DESTRUCTIVE, title: "Delete an uploaded app" },
50
+ // Tunnels
51
+ getTunnelList: { ...READ, title: "List running tunnels" },
52
+ // Reuses a running tunnel with the same identifier.
53
+ startTunnel: { ...WRITE_IDEMPOTENT, title: "Start a tunnel" },
54
+ stopTunnel: { ...DESTRUCTIVE, title: "Stop a tunnel started here" },
55
+ deleteTunnel: { ...DESTRUCTIVE, title: "Shut down a tunnel" },
56
+ // Maestro
57
+ maestroCheatSheet: { ...LOCAL_READ, title: "Maestro syntax reference" },
58
+ // Reuses an upload of the same binary.
59
+ uploadMaestroApp: { ...WRITE_IDEMPOTENT, title: "Upload an app for Maestro" },
60
+ // Replaces the project's previously uploaded flows.
61
+ uploadMaestroFlows: {
62
+ ...WRITE_IDEMPOTENT,
63
+ destructiveHint: true,
64
+ title: "Upload Maestro flows",
65
+ },
66
+ uploadMaestroCompanionApp: { ...WRITE, title: "Upload a Maestro companion app" },
67
+ runMaestroTest: { ...WRITE, title: "Run Maestro flows" },
68
+ getMaestroRunStatus: { ...READ, title: "Check a Maestro run" },
69
+ getMaestroRunResults: { ...READ, title: "Get Maestro run results" },
70
+ getMaestroFlowDetails: { ...READ, title: "Show a Maestro flow's result" },
71
+ listMaestroProjects: { ...READ, title: "List Maestro projects" },
72
+ listMaestroRuns: { ...READ, title: "List Maestro runs" },
73
+ cancelMaestroRun: { ...DESTRUCTIVE, title: "Cancel a Maestro run" },
74
+ retryMaestroRun: { ...WRITE, title: "Retry a Maestro run" },
75
+ // Espresso / XCUITest
76
+ uploadAppAutomateApp: { ...WRITE, title: "Upload an app for Espresso/XCUITest" },
77
+ uploadAppAutomateTests: { ...WRITE, title: "Upload an Espresso/XCUITest suite" },
78
+ runAppAutomateTest: { ...WRITE, title: "Run Espresso/XCUITest" },
79
+ getAppAutomateRunStatus: { ...READ, title: "Check an Espresso/XCUITest run" },
80
+ getAppAutomateRunResults: { ...READ, title: "Get Espresso/XCUITest results" },
81
+ // Visual review
82
+ getVisualTests: { ...READ, title: "List visual tests" },
83
+ getVisualRuns: { ...READ, title: "List visual runs" },
84
+ explainVisualRun: { ...READ, title: "Explain a visual change" },
85
+ // makeBaseline replaces the browser's baseline screenshot.
86
+ reviewVisualRun: {
87
+ ...WRITE_IDEMPOTENT,
88
+ destructiveHint: true,
89
+ title: "Approve or reject a visual run",
90
+ },
91
+ // Accessibility
92
+ getAccessibilityTests: { ...READ, title: "List accessibility tests" },
93
+ getAccessibilityRuns: { ...READ, title: "List accessibility scans" },
94
+ getAccessibilityFindings: { ...READ, title: "Show accessibility findings" },
95
+ runAccessibilityTest: { ...WRITE, title: "Run an accessibility scan now" },
96
+ // Local project helpers
97
+ listTestFiles: { ...LOCAL_READ, title: "Find test files in a project" },
98
+ setupTestingBot: { ...LOCAL_READ, title: "Get TestingBot setup for a project" },
99
+ };
100
+ //# sourceMappingURL=tool-annotations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-annotations.js","sourceRoot":"","sources":["../../src/lib/tool-annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,WAAW,EACX,IAAI,EACJ,KAAK,EACL,gBAAgB,GAEjB,MAAM,4BAA4B,CAAC;AAEpC,8EAA8E;AAC9E,MAAM,UAAU,GAAoB,EAAE,GAAG,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C7E,wBAAwB,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,+BAA+B,EAAE;IAE7E,gBAAgB;IAChB,cAAc,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,mBAAmB,EAAE;IACvD,aAAa,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,kBAAkB,EAAE;IACrD,gBAAgB,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,yBAAyB,EAAE;IAC/D,2DAA2D;IAC3D,eAAe,EAAE;QACf,GAAG,gBAAgB;QACnB,eAAe,EAAE,IAAI;QACrB,KAAK,EAAE,gCAAgC;KACxC;IAED,gBAAgB;IAChB,qBAAqB,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,0BAA0B,EAAE;IACrE,oBAAoB,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,0BAA0B,EAAE;IACpE,wBAAwB,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,6BAA6B,EAAE;IAC3E,oBAAoB,EAAE,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,+BAA+B,EAAE;IAE1E,wBAAwB;IACxB,aAAa,EAAE,EAAE,GAAG,UAAU,EAAE,KAAK,EAAE,8BAA8B,EAAE;IACvE,eAAe,EAAE,EAAE,GAAG,UAAU,EAAE,KAAK,EAAE,oCAAoC,EAAE;CAChF,CAAC"}
@@ -0,0 +1,30 @@
1
+ export interface PromptArgument {
2
+ name: string;
3
+ description: string;
4
+ required: boolean;
5
+ }
6
+ export interface PromptDefinition {
7
+ name: string;
8
+ title: string;
9
+ description: string;
10
+ arguments: PromptArgument[];
11
+ build: (args: Record<string, string>) => string;
12
+ }
13
+ export declare const PROMPTS: PromptDefinition[];
14
+ export declare function listPrompts(): {
15
+ name: string;
16
+ title: string;
17
+ description: string;
18
+ arguments: PromptArgument[];
19
+ }[];
20
+ export declare function getPrompt(name: string, args?: Record<string, string>): {
21
+ description: string;
22
+ messages: {
23
+ role: "user";
24
+ content: {
25
+ type: "text";
26
+ text: string;
27
+ };
28
+ }[];
29
+ };
30
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC;CACjD;AAOD,eAAO,MAAM,OAAO,EAAE,gBAAgB,EA0ErC,CAAC;AAEF,wBAAgB,WAAW;;;;;IAO1B;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;;;;;;;;;EAcxE"}
@@ -0,0 +1,105 @@
1
+ // MCP prompts (prompts/list, prompts/get): ready-made task recipes a client can
2
+ // offer as slash commands. Each one returns a single user message that tells the
3
+ // model which TestingBot tools and resources to use, in which order, and what to
4
+ // report. They only reference tools by name; nothing is called here.
5
+ function arg(args, name, fallback = "") {
6
+ const value = args[name];
7
+ return typeof value === "string" && value.trim() ? value.trim() : fallback;
8
+ }
9
+ export const PROMPTS = [
10
+ {
11
+ name: "why-did-my-test-fail",
12
+ title: "Why did my test fail?",
13
+ description: "Investigate one failed TestingBot test: status, AI failure analysis when enabled, and the failing log lines.",
14
+ arguments: [
15
+ {
16
+ name: "sessionId",
17
+ description: "Session ID (or numeric test ID) of the failed test.",
18
+ required: true,
19
+ },
20
+ ],
21
+ build: (args) => {
22
+ const id = arg(args, "sessionId");
23
+ return [
24
+ `Find out why TestingBot test ${id} failed.`,
25
+ "",
26
+ `1. Call getTestDetails for ${id} (or read the resource testingbot://tests/${id}) to get its status, status message, environment and which logs exist.`,
27
+ `2. If the analyzeTestFailure tool is available, call it for ${id}. If it reports that AI Analysis is not enabled, do not ask to enable it; carry on with the logs.`,
28
+ `3. Call getFailureLogs for ${id} with failuresOnly=true. Read the full log of one type only if the failing lines are not enough.`,
29
+ "4. Report: what the test was doing, the step that failed, the most likely cause (application bug, test script, environment or flaky), the log lines that show it, and one to three concrete fixes. Quote the evidence; say how sure you are and do not guess beyond it.",
30
+ ].join("\n");
31
+ },
32
+ },
33
+ {
34
+ name: "summarise-build",
35
+ title: "Summarise a build",
36
+ description: "Summarise a TestingBot build: pass/fail counts, the failures grouped by cause, and what to fix first.",
37
+ arguments: [
38
+ {
39
+ name: "buildId",
40
+ description: "ID of the build (from getBuilds).",
41
+ required: true,
42
+ },
43
+ ],
44
+ build: (args) => {
45
+ const id = arg(args, "buildId");
46
+ return [
47
+ `Summarise TestingBot build ${id}.`,
48
+ "",
49
+ `1. Call getTestsForBuild for build ${id} (or read testingbot://builds/${id}).`,
50
+ "2. Count passed, failed and unknown tests, and list the environments (browser/OS or device) they ran on.",
51
+ "3. For each failed test (at most 10), call getFailureLogs with failuresOnly=true. If analyzeTestFailure is available and enabled, use getAiFailureAnalysis to read existing analyses first; only start new ones for up to 3 tests.",
52
+ "4. Group the failures by shared cause (same error message, same environment, same step).",
53
+ "5. Report a short summary line, a table of failure groups with the affected tests and environments, and what to fix first. Mention tests that failed in one environment only.",
54
+ ].join("\n");
55
+ },
56
+ },
57
+ {
58
+ name: "find-flaky-tests",
59
+ title: "Find flaky tests",
60
+ description: "Find tests that both passed and failed recently and suggest why they are unstable.",
61
+ arguments: [
62
+ {
63
+ name: "timeRange",
64
+ description: "How far back to look, e.g. 7d or 30d (default 30d).",
65
+ required: false,
66
+ },
67
+ ],
68
+ build: (args) => {
69
+ const range = arg(args, "timeRange", "30d");
70
+ return [
71
+ `Find flaky TestingBot tests over the last ${range}.`,
72
+ "",
73
+ `1. Read the resource testingbot://insights/flaky-tests?time_range=${encodeURIComponent(range)}. It lists test names with their pass rate and a flaky flag, most flaky first.`,
74
+ "2. For the top 5 flaky tests, call getTests and pick one recent failed and one recent passed run of each; call getFailureLogs with failuresOnly=true on the failed run.",
75
+ "3. Look for timing problems (timeouts, waits, animations), order dependence, shared test data, or one environment failing more than others.",
76
+ "4. Report a ranked list: test name, pass rate, runs, the likely reason it is unstable, and a concrete change to make it stable.",
77
+ ].join("\n");
78
+ },
79
+ },
80
+ ];
81
+ export function listPrompts() {
82
+ return PROMPTS.map(({ name, title, description, arguments: args }) => ({
83
+ name,
84
+ title,
85
+ description,
86
+ arguments: args,
87
+ }));
88
+ }
89
+ export function getPrompt(name, args = {}) {
90
+ const prompt = PROMPTS.find((p) => p.name === name);
91
+ if (!prompt)
92
+ throw new Error(`Unknown prompt: ${name}`);
93
+ for (const a of prompt.arguments) {
94
+ if (a.required && !arg(args, a.name)) {
95
+ throw new Error(`Prompt ${name} needs the argument "${a.name}"`);
96
+ }
97
+ }
98
+ return {
99
+ description: prompt.description,
100
+ messages: [
101
+ { role: "user", content: { type: "text", text: prompt.build(args) } },
102
+ ],
103
+ };
104
+ }
105
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,iFAAiF;AACjF,iFAAiF;AACjF,qEAAqE;AAgBrE,SAAS,GAAG,CAAC,IAA4B,EAAE,IAAY,EAAE,QAAQ,GAAG,EAAE;IACpE,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,QA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C,WAAW;QAC/B,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,MAAe,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE;SACxF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ export declare const RESOURCE_TEMPLATES: {
2
+ uriTemplate: string;
3
+ name: string;
4
+ title: string;
5
+ description: string;
6
+ mimeType: string;
7
+ }[];
8
+ export declare const STATIC_RESOURCES: {
9
+ uri: string;
10
+ name: string;
11
+ title: string;
12
+ description: string;
13
+ mimeType: string;
14
+ }[];
15
+ type Contents = {
16
+ uri: string;
17
+ mimeType: string;
18
+ text: string;
19
+ };
20
+ export declare function readResource(testingBotApi: any, uri: string): Promise<{
21
+ contents: Contents[];
22
+ }>;
23
+ export {};
24
+ //# sourceMappingURL=resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,kBAAkB;;;;;;GAuB9B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;GAS5B,CAAC;AAEF,KAAK,QAAQ,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAoBhE,wBAAsB,YAAY,CAChC,aAAa,EAAE,GAAG,EAClB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAC,CAiDnC"}
@@ -0,0 +1,110 @@
1
+ import { sanitizeSessionId } from "./lib/utils.js";
2
+ // MCP resources (resources/list, resources/templates/list, resources/read):
3
+ // read-only TestingBot data a client can attach to a conversation.
4
+ //
5
+ // testingbot://tests/{sessionId} test details (JSON)
6
+ // testingbot://tests/{sessionId}/logs/{logType} one session log (text, tail)
7
+ // testingbot://builds/{buildId} tests in a build (JSON)
8
+ // testingbot://insights/flaky-tests most flaky tests (JSON)
9
+ const LOG_TYPES = ["selenium", "browser", "chrome", "vm", "appium"];
10
+ const MAX_LOG_BYTES = 200_000;
11
+ const LOG_TIMEOUT_MS = 15_000;
12
+ export const RESOURCE_TEMPLATES = [
13
+ {
14
+ uriTemplate: "testingbot://tests/{sessionId}",
15
+ name: "test",
16
+ title: "TestingBot test",
17
+ description: "Status, environment, duration, build and asset links of one test (session ID or numeric test ID).",
18
+ mimeType: "application/json",
19
+ },
20
+ {
21
+ uriTemplate: "testingbot://tests/{sessionId}/logs/{logType}",
22
+ name: "test-log",
23
+ title: "TestingBot test log",
24
+ description: `One log file of a test, the last ${MAX_LOG_BYTES / 1000} KB. logType: ${LOG_TYPES.join(", ")}.`,
25
+ mimeType: "text/plain",
26
+ },
27
+ {
28
+ uriTemplate: "testingbot://builds/{buildId}",
29
+ name: "build",
30
+ title: "TestingBot build",
31
+ description: "The tests in a build with their status.",
32
+ mimeType: "application/json",
33
+ },
34
+ ];
35
+ export const STATIC_RESOURCES = [
36
+ {
37
+ uri: "testingbot://insights/flaky-tests",
38
+ name: "flaky-tests",
39
+ title: "Flaky tests",
40
+ description: "Tests that both passed and failed in the last 30 days, most flaky first. Add ?time_range=7d to change the window.",
41
+ mimeType: "application/json",
42
+ },
43
+ ];
44
+ function json(uri, body) {
45
+ return { uri, mimeType: "application/json", text: JSON.stringify(body, null, 2) };
46
+ }
47
+ function cleanId(raw) {
48
+ const id = sanitizeSessionId(decodeURIComponent(raw));
49
+ if (!id)
50
+ throw new Error("Empty ID in resource URI");
51
+ return id;
52
+ }
53
+ async function fetchLogTail(url) {
54
+ const response = await fetch(url, { signal: AbortSignal.timeout(LOG_TIMEOUT_MS) });
55
+ if (!response.ok)
56
+ throw new Error(`HTTP ${response.status} fetching log`);
57
+ const text = await response.text();
58
+ if (text.length <= MAX_LOG_BYTES)
59
+ return text;
60
+ return `… (truncated ${text.length - MAX_LOG_BYTES} bytes) …\n` + text.slice(-MAX_LOG_BYTES);
61
+ }
62
+ export async function readResource(testingBotApi, uri) {
63
+ let parsed;
64
+ try {
65
+ parsed = new URL(uri);
66
+ }
67
+ catch {
68
+ throw new Error(`Invalid resource URI: ${uri}`);
69
+ }
70
+ if (parsed.protocol !== "testingbot:")
71
+ throw new Error(`Unknown resource URI: ${uri}`);
72
+ // For testingbot://tests/abc the "host" is "tests" and the path is "/abc".
73
+ const parts = [parsed.host, ...parsed.pathname.split("/").filter(Boolean)];
74
+ if (parts[0] === "tests" && parts.length === 2) {
75
+ const test = await testingBotApi.getTestDetails(cleanId(parts[1]), {
76
+ skip_fields: "steps",
77
+ });
78
+ return { contents: [json(uri, test)] };
79
+ }
80
+ if (parts[0] === "tests" && parts.length === 4 && parts[2] === "logs") {
81
+ const id = cleanId(parts[1]);
82
+ const logType = parts[3];
83
+ if (!LOG_TYPES.includes(logType)) {
84
+ throw new Error(`Unknown log type "${logType}". Use one of: ${LOG_TYPES.join(", ")}`);
85
+ }
86
+ const test = await testingBotApi.getTestDetails(id);
87
+ const url = test?.logs && typeof test.logs === "object" ? test.logs[logType] : undefined;
88
+ if (!url)
89
+ throw new Error(`Test ${id} has no ${logType} log`);
90
+ return { contents: [{ uri, mimeType: "text/plain", text: await fetchLogTail(url) }] };
91
+ }
92
+ if (parts[0] === "builds" && parts.length === 2) {
93
+ const tests = await testingBotApi.getTestsForBuild(cleanId(parts[1]));
94
+ return { contents: [json(uri, tests)] };
95
+ }
96
+ if (parts[0] === "insights" && parts[1] === "flaky-tests" && parts.length === 2) {
97
+ const range = parsed.searchParams.get("time_range") || "30d";
98
+ if (!/^\d{1,3}[hdw]$/.test(range))
99
+ throw new Error("time_range must look like 24h, 7d or 4w");
100
+ const body = await testingBotApi.request({
101
+ method: "GET",
102
+ url: "/insights/test-cases",
103
+ data: { sort: "flaky", sort_order: "desc", time_range: range, count: 50 },
104
+ });
105
+ const rows = Array.isArray(body?.data) ? body.data.filter((r) => r?.flaky) : [];
106
+ return { contents: [json(uri, { time_range: range, flaky_tests: rows, meta: body?.meta })] };
107
+ }
108
+ throw new Error(`Unknown resource URI: ${uri}`);
109
+ }
110
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,4EAA4E;AAC5E,mEAAmE;AACnE,EAAE;AACF,wEAAwE;AACxE,iFAAiF;AACjF,4EAA4E;AAC5E,4EAA4E;AAE5E,MAAM,SAAS,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;AACpE,MAAM,aAAa,GAAG,OAAO,CAAC;AAC9B,MAAM,cAAc,GAAG,MAAM,CAAC;AAE9B,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC;QACE,WAAW,EAAE,gCAAgC;QAC7C,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,iBAAiB;QACxB,WAAW,EACT,mGAAmG;QACrG,QAAQ,EAAE,kBAAkB;KAC7B;IACD;QACE,WAAW,EAAE,+CAA+C;QAC5D,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,qBAAqB;QAC5B,WAAW,EAAE,oCAAoC,aAAa,GAAG,IAAI,iBAAiB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QAC7G,QAAQ,EAAE,YAAY;KACvB;IACD;QACE,WAAW,EAAE,+BAA+B;QAC5C,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,yCAAyC;QACtD,QAAQ,EAAE,kBAAkB;KAC7B;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B;QACE,GAAG,EAAE,mCAAmC;QACxC,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,aAAa;QACpB,WAAW,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AAE;SAC1E,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACrF,OAAO,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;IAC/F,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAC;AAClD,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { Server as McpServer } from "@modelcontextprotocol/sdk/server/index.js";
2
2
  import { TestingBotConfig } from "./lib/types.js";
3
+ import { toolInputSchema } from "@testingbot/automation-mcp";
3
4
  export declare class TestingBotMcpServer {
4
5
  server: McpServer;
5
6
  tools: Record<string, any>;
@@ -9,10 +10,18 @@ export declare class TestingBotMcpServer {
9
10
  private closing;
10
11
  constructor(testingBotApi: any, config: TestingBotConfig);
11
12
  private setupHandlers;
13
+ handleResourceRead(uri: string): Promise<{
14
+ contents: {
15
+ uri: string;
16
+ mimeType: string;
17
+ text: string;
18
+ }[];
19
+ }>;
12
20
  listTools(): Array<{
13
21
  name: string;
14
22
  description: string;
15
23
  inputSchema: any;
24
+ annotations?: unknown;
16
25
  }>;
17
26
  handleToolCall(toolName: string, toolArgs: any): Promise<any>;
18
27
  private hasCredentials;
@@ -35,5 +44,5 @@ export declare class TestingBotMcpServer {
35
44
  run(): Promise<void>;
36
45
  close(): Promise<void>;
37
46
  }
38
- export declare function toolInputSchema(shape: Record<string, any> | undefined): any;
47
+ export { toolInputSchema };
39
48
  //# sourceMappingURL=server-factory.d.ts.map
@@ -1 +1 @@
1
-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