Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@browserstack/mcp-server",
"version": "1.2.5",
"version": "1.2.6",
"description": "BrowserStack's Official MCP Server",
"mcpName": "io.github.browserstack/mcp-server",
"main": "dist/index.js",
Expand Down
12 changes: 1 addition & 11 deletions src/tools/sdk-utils/bstack/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,6 @@ Alternative setup for Gradle users:
${GRADLE_SETUP_INSTRUCTIONS}`;
}

function getPythonSDKInstructions(username: string, accessKey: string): string {
return `---STEP---
Install BrowserStack Python SDK and setup:
\`\`\`bash
pip install browserstack-sdk
browserstack-sdk setup --username "${username}" --key "${accessKey}"
\`\`\``;
}

// Main function to get SDK setup commands based on language and framework
export function getSDKPrefixCommand(
language: SDKSupportedLanguage,
Expand All @@ -121,8 +112,7 @@ export function getSDKPrefixCommand(

case "java":
return getJavaSDKInstructions(framework, username, accessKey);
case "python":
return getPythonSDKInstructions(username, accessKey);

default:
return "";
}
Expand Down
26 changes: 19 additions & 7 deletions src/tools/sdk-utils/bstack/configUtils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import { ValidatedEnvironment } from "../common/device-validator.js";

export function generateBrowserStackYMLInstructions(config: {
validatedEnvironments?: ValidatedEnvironment[];
platforms?: string[];
enablePercy?: boolean;
projectName: string;
}): string {
import { BrowserStackConfig } from "../../../lib/types.js";
import { getBrowserStackAuth } from "../../../lib/get-auth.js";

export function generateBrowserStackYMLInstructions(
config: {
validatedEnvironments?: ValidatedEnvironment[];
platforms?: string[];
enablePercy?: boolean;
projectName: string;
},
browserStackConfig: BrowserStackConfig,
): string {
const enablePercy = config.enablePercy || false;
const projectName = config.projectName || "BrowserStack Automate Build";

// Get credentials from config
const authString = getBrowserStackAuth(browserStackConfig);
const [username, accessKey] = authString.split(":");

// Generate platform configurations using the utility function
const platformConfigs = generatePlatformConfigs(config);

Expand All @@ -22,6 +31,9 @@ export function generateBrowserStackYMLInstructions(config: {
# BrowserStack Reporting
# ======================

userName: ${username}
accessKey: ${accessKey}

# TODO: Replace these sample values with your actual project details
projectName: ${projectName}
buildName: ${buildName}
Expand Down
9 changes: 8 additions & 1 deletion src/tools/sdk-utils/bstack/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ browserstack-sdk pytest <path-to-test-directory>
};

export const generatePythonFrameworkInstructions =
(framework: string) => () => {
(framework: string) => (username: string, accessKey: string) => {
const setup = `
---STEP---

Expand All @@ -41,6 +41,13 @@ Install the BrowserStack SDK:
\`\`\`bash
python3 -m pip install browserstack-sdk
\`\`\`

---STEP---

Setup the BrowserStack SDK with framework-specific configuration:
\`\`\`bash
browserstack-sdk setup --framework "${framework}" --username "${username}" --key "${accessKey}"
\`\`\`
`;

const run = `
Expand Down
33 changes: 19 additions & 14 deletions src/tools/sdk-utils/bstack/sdkHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,6 @@ export async function runBstackSDKOnly(
});
}

const ymlInstructions = generateBrowserStackYMLInstructions({
validatedEnvironments,
enablePercy: false,
projectName: input.projectName,
});

if (ymlInstructions) {
steps.push({
type: "instruction",
title: "Configure browserstack.yml",
content: ymlInstructions,
});
}

const frameworkInstructions = getInstructionsForProjectConfiguration(
input.detectedBrowserAutomationFramework as SDKSupportedBrowserAutomationFramework,
input.detectedTestingFramework as SDKSupportedTestingFramework,
Expand All @@ -116,7 +102,26 @@ export async function runBstackSDKOnly(
content: frameworkInstructions.setup,
});
}
}

const ymlInstructions = generateBrowserStackYMLInstructions(
{
validatedEnvironments,
enablePercy: false,
projectName: input.projectName,
},
config,
);

if (ymlInstructions) {
steps.push({
type: "instruction",
title: "Configure browserstack.yml",
content: ymlInstructions,
});
}

if (frameworkInstructions) {
if (frameworkInstructions.run && !isPercyAutomate) {
steps.push({
type: "instruction",
Expand Down
19 changes: 11 additions & 8 deletions src/tools/sdk-utils/percy-bstack/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,17 @@ export function runPercyWithBrowserstackSDK(
});
}

const ymlInstructions = generateBrowserStackYMLInstructions({
platforms:
((input as any).devices as string[][] | undefined)?.map((t) =>
t.join(" "),
) || [],
enablePercy: true,
projectName: input.projectName,
});
const ymlInstructions = generateBrowserStackYMLInstructions(
{
platforms:
((input as any).devices as string[][] | undefined)?.map((t) =>
t.join(" "),
) || [],
enablePercy: true,
projectName: input.projectName,
},
config,
);

if (ymlInstructions) {
steps.push({
Expand Down