Skip to content

Commit 3b09f6b

Browse files
authored
Merge branch 'browserstack:main' into main
2 parents 077c9e5 + 3aebfeb commit 3b09f6b

21 files changed

+204
-204
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ Manage, execute, debug tests, and even fix code using plain English prompts.
3535
#### Reduced context switching:
3636
Stay in flow—keep all project context in one place and trigger actions directly from your IDE or LLM.
3737

38-
## ⚡️ One Click MCP Setup
38+
## ⚡️ One Click MCP Setup
39+
40+
Click on the buttons below to install MCP in your respective IDE:
41+
42+
<a href="http://mcp.browserstack.com/one-click-setup?client=vscode"><img src="assets/one-click-vs-code.png" alt="Install in VS Code" width="160" height="80"></a>&nbsp;&nbsp;&nbsp;<a href="http://mcp.browserstack.com/one-click-setup?client=cursor"><img src="assets/one-click-cursor.png" alt="Install in Cursor" width="150" height="70"></a>
3943

40-
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](http://mcp.browserstack.com/one-click-setup?client=vscode) &nbsp; [![Install in Cursor](https://img.shields.io/badge/Cursor-Install_Server-24bfa5?style=flat-square&color=000000&logo=visualstudiocode&logoColor=white)](http://mcp.browserstack.com/one-click-setup?client=cursor)
4144
#### Note : Ensure you are using Node version >= `18.0`
4245
- Check your node version using `node --version`. Recommended version: `v22.15.0` (LTS)
4346
- To Upgrade Node :
@@ -156,8 +159,9 @@ Generate test cases from PRDs, convert manual tests to low-code automation, and
156159
157160
### **One Click MCP Setup**
158161
159-
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](http://mcp.browserstack.com/one-click-setup?client=vscode) &nbsp; [![Install in Cursor](https://img.shields.io/badge/Cursor-Install_Server-24bfa5?style=flat-square&color=000000&logo=visualstudiocode&logoColor=white)](http://mcp.browserstack.com/one-click-setup?client=cursor)
162+
Click on the buttons below to install MCP in your respective IDE:
160163
164+
<a href="http://mcp.browserstack.com/one-click-setup?client=vscode"><img src="assets/one-click-vs-code.png" alt="Install in VS Code" width="160" height="80"></a>&nbsp;&nbsp;&nbsp;<a href="http://mcp.browserstack.com/one-click-setup?client=cursor"><img src="assets/one-click-cursor.png" alt="Install in Cursor" width="150" height="70"></a>
161165
162166
### **Alternate ways to Setup MCP server**
163167

assets/one-click-cursor.png

5.16 KB
Loading

assets/one-click-vs-code.png

7.88 KB
Loading

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "@browserstack/mcp-server",
3-
"version": "1.2.3",
3+
"version": "1.2.4",
44
"description": "BrowserStack's Official MCP Server",
5+
"mcpName": "io.github.browserstack/mcp-server",
56
"main": "dist/index.js",
67
"repository": {
78
"type": "git",

src/lib/utils.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import sharp from "sharp";
22
import type { ApiResponse } from "./apiClient.js";
33
import { BrowserStackConfig } from "./types.js";
44
import { getBrowserStackAuth } from "./get-auth.js";
5+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6+
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
7+
import { trackMCP } from "../index.js";
58

69
export function sanitizeUrlParam(param: string): string {
710
// Remove any characters that could be used for command injection
@@ -62,3 +65,27 @@ export async function fetchFromBrowserStackAPI(
6265

6366
return res.json();
6467
}
68+
69+
function errorContent(message: string): CallToolResult {
70+
return {
71+
content: [{ type: "text", text: message }],
72+
isError: true,
73+
};
74+
}
75+
76+
export function handleMCPError(
77+
toolName: string,
78+
server: McpServer,
79+
config: BrowserStackConfig,
80+
error: unknown,
81+
) {
82+
trackMCP(toolName, server.server.getClientVersion()!, error, config);
83+
84+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
85+
86+
const readableToolName = toolName.replace(/([A-Z])/g, " $1").toLowerCase();
87+
88+
return errorContent(
89+
`Failed to ${readableToolName}: ${errorMessage}. Please open an issue on GitHub if the problem persists`,
90+
);
91+
}

src/tools/appautomate-utils/appium-sdk/types.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,8 @@ export interface AppSDKInstruction {
6060
export const SUPPORTED_CONFIGURATIONS = {
6161
appium: {
6262
ruby: ["cucumberRuby"],
63-
java: [
64-
"junit5",
65-
"junit4",
66-
"testng",
67-
"cucumberTestng",
68-
"selenide",
69-
"jbehave",
70-
],
71-
csharp: ["nunit", "xunit", "mstest", "specflow", "reqnroll"],
63+
java: [],
64+
csharp: [],
7265
python: ["pytest", "robot", "behave", "lettuce"],
7366
nodejs: ["jest", "mocha", "cucumberJs", "webdriverio", "nightwatch"],
7467
},

src/tools/appautomate-utils/appium-sdk/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,15 @@ export function validateSupportforAppAutomate(
9696
);
9797
}
9898

99-
const testingFrameworks = SUPPORTED_CONFIGURATIONS[framework][language];
99+
const testingFrameworks = SUPPORTED_CONFIGURATIONS[framework][
100+
language
101+
] as string[];
102+
103+
if (testingFrameworks.length === 0) {
104+
throw new Error(
105+
`No testing frameworks are supported for language '${language}' and framework '${framework}'.`,
106+
);
107+
}
100108
if (!testingFrameworks.includes(testingFramework)) {
101109
throw new Error(
102110
`Unsupported testing framework '${testingFramework}' for language '${language}' and framework '${framework}'. Supported testing frameworks: ${testingFrameworks.join(", ")}`,

src/tools/bstack-sdk.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { BrowserStackConfig } from "../lib/types.js";
33
import { RunTestsOnBrowserStackParamsShape } from "./sdk-utils/common/schema.js";
44
import { runTestsOnBrowserStackHandler } from "./sdk-utils/handler.js";
55
import { RUN_ON_BROWSERSTACK_DESCRIPTION } from "./sdk-utils/common/constants.js";
6+
import { handleMCPError } from "../lib/utils.js";
7+
import { trackMCP } from "../lib/instrumentation.js";
68

79
export function registerRunBrowserStackTestsTool(
810
server: McpServer,
@@ -15,7 +17,16 @@ export function registerRunBrowserStackTestsTool(
1517
RUN_ON_BROWSERSTACK_DESCRIPTION,
1618
RunTestsOnBrowserStackParamsShape,
1719
async (args) => {
18-
return runTestsOnBrowserStackHandler(args, config);
20+
try {
21+
trackMCP(
22+
"runTestsOnBrowserStack",
23+
server.server.getClientVersion()!,
24+
config,
25+
);
26+
return await runTestsOnBrowserStackHandler(args, config);
27+
} catch (error) {
28+
return handleMCPError("runTestsOnBrowserStack", server, config, error);
29+
}
1930
},
2031
);
2132

src/tools/build-insights.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { z } from "zod";
33
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
44
import logger from "../logger.js";
55
import { BrowserStackConfig } from "../lib/types.js";
6-
import { fetchFromBrowserStackAPI } from "../lib/utils.js";
6+
import { fetchFromBrowserStackAPI, handleMCPError } from "../lib/utils.js";
7+
import { trackMCP } from "../lib/instrumentation.js";
78

89
// Tool function that fetches build insights from two APIs
910
export async function fetchBuildInsightsTool(
@@ -78,18 +79,14 @@ export default function addBuildInsightsTools(
7879
},
7980
async (args) => {
8081
try {
82+
trackMCP(
83+
"fetchBuildInsights",
84+
server.server.getClientVersion()!,
85+
config,
86+
);
8187
return await fetchBuildInsightsTool(args, config);
8288
} catch (error) {
83-
const errorMessage =
84-
error instanceof Error ? error.message : "Unknown error";
85-
return {
86-
content: [
87-
{
88-
type: "text",
89-
text: `Error during fetching build insights: ${errorMessage}`,
90-
},
91-
],
92-
};
89+
return handleMCPError("fetchBuildInsights", server, config, error);
9390
}
9491
},
9592
);

0 commit comments

Comments
 (0)