From 56f311cd52a77a56e54a965a7dccd19002dbaaca Mon Sep 17 00:00:00 2001 From: tech-sushant Date: Thu, 16 Oct 2025 13:23:20 +0530 Subject: [PATCH] chore: Bump version to 1.2.6 and refactor SDK setup instructions for improved clarity and functionality --- package-lock.json | 4 +-- package.json | 2 +- src/tools/sdk-utils/bstack/commands.ts | 12 +------- src/tools/sdk-utils/bstack/configUtils.ts | 26 +++++++++++----- src/tools/sdk-utils/bstack/constants.ts | 9 +++++- src/tools/sdk-utils/bstack/sdkHandler.ts | 33 ++++++++++++--------- src/tools/sdk-utils/percy-bstack/handler.ts | 19 +++++++----- 7 files changed, 61 insertions(+), 44 deletions(-) diff --git a/package-lock.json b/package-lock.json index f654e564..414e471a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@browserstack/mcp-server", - "version": "1.2.5", + "version": "1.2.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@browserstack/mcp-server", - "version": "1.2.5", + "version": "1.2.6", "license": "ISC", "dependencies": { "@modelcontextprotocol/sdk": "^1.18.1", diff --git a/package.json b/package.json index 19dd5c6d..eae70a86 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/tools/sdk-utils/bstack/commands.ts b/src/tools/sdk-utils/bstack/commands.ts index ff71f0de..1f600d72 100644 --- a/src/tools/sdk-utils/bstack/commands.ts +++ b/src/tools/sdk-utils/bstack/commands.ts @@ -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, @@ -121,8 +112,7 @@ export function getSDKPrefixCommand( case "java": return getJavaSDKInstructions(framework, username, accessKey); - case "python": - return getPythonSDKInstructions(username, accessKey); + default: return ""; } diff --git a/src/tools/sdk-utils/bstack/configUtils.ts b/src/tools/sdk-utils/bstack/configUtils.ts index 04391046..a38f13ae 100644 --- a/src/tools/sdk-utils/bstack/configUtils.ts +++ b/src/tools/sdk-utils/bstack/configUtils.ts @@ -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); @@ -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} diff --git a/src/tools/sdk-utils/bstack/constants.ts b/src/tools/sdk-utils/bstack/constants.ts index b801bd77..47a7bac8 100644 --- a/src/tools/sdk-utils/bstack/constants.ts +++ b/src/tools/sdk-utils/bstack/constants.ts @@ -32,7 +32,7 @@ browserstack-sdk pytest }; export const generatePythonFrameworkInstructions = - (framework: string) => () => { + (framework: string) => (username: string, accessKey: string) => { const setup = ` ---STEP--- @@ -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 = ` diff --git a/src/tools/sdk-utils/bstack/sdkHandler.ts b/src/tools/sdk-utils/bstack/sdkHandler.ts index 22f00488..54171d4b 100644 --- a/src/tools/sdk-utils/bstack/sdkHandler.ts +++ b/src/tools/sdk-utils/bstack/sdkHandler.ts @@ -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, @@ -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", diff --git a/src/tools/sdk-utils/percy-bstack/handler.ts b/src/tools/sdk-utils/percy-bstack/handler.ts index 989c17a4..9ee200fc 100644 --- a/src/tools/sdk-utils/percy-bstack/handler.ts +++ b/src/tools/sdk-utils/percy-bstack/handler.ts @@ -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({