Skip to main content
Glama
browserstack

BrowserStack MCP server

Official

runTestsOnBrowserStack

Generate setup instructions to run tests on BrowserStack based on the automation framework, testing framework, programming language, and desired platforms in your project.

Instructions

Use this tool to get instructions for running tests on BrowserStack.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
desiredPlatformsYesThe platforms the user wants to test on. Always ask this to the user, do not try to infer this.
detectedBrowserAutomationFrameworkYesThe automation framework configured in the project. Example: 'playwright', 'selenium'
detectedLanguageYesThe programming language used in the project. Example: 'nodejs', 'python'
detectedTestingFrameworkYesThe testing framework used in the project. Example: 'jest', 'pytest'

Implementation Reference

  • Registers the BrowserStack tool 'setupBrowserStackAutomateTests' which internally tracks and calls 'runTestsOnBrowserStackHandler' as the tool logic.
    export function registerRunBrowserStackTestsTool(
      server: McpServer,
      config: BrowserStackConfig,
    ) {
      const tools: Record<string, any> = {};
    
      tools.setupBrowserStackAutomateTests = server.tool(
        "setupBrowserStackAutomateTests",
        RUN_ON_BROWSERSTACK_DESCRIPTION,
        RunTestsOnBrowserStackParamsShape,
        async (args) => {
          try {
            trackMCP(
              "runTestsOnBrowserStack",
              server.server.getClientVersion()!,
              config,
            );
            return await runTestsOnBrowserStackHandler(args, config);
          } catch (error) {
            return handleMCPError("runTestsOnBrowserStack", server, config, error);
          }
        },
      );
    
      return tools;
    }
  • The primary handler function named runTestsOnBrowserStackHandler. It parses the raw input using the schema and delegates to the core BrowserStack SDK implementation.
    export async function runTestsOnBrowserStackHandler(
      rawInput: unknown,
      config: BrowserStackConfig,
    ): Promise<CallToolResult> {
      const input = RunTestsOnBrowserStackSchema.parse(rawInput);
      const result = await runBstackSDKOnly(input, config);
      return await formatToolResult(result);
    }
  • Core handler logic (runBstackSDKOnly) that implements the tool by generating step-by-step instructions for BrowserStack SDK setup, device validation, framework-specific configs, and browserstack.yml generation.
    export async function runBstackSDKOnly(
      input: RunTestsOnBrowserStackInput,
      config: BrowserStackConfig,
      isPercyAutomate = false,
    ): Promise<RunTestsInstructionResult> {
      const steps: RunTestsStep[] = [];
      const authString = getBrowserStackAuth(config);
      const [username, accessKey] = authString.split(":");
    
      const tupleTargets: Array<Array<string>> =
        input.devices?.map((device) => {
          const platform = device.platform.toLowerCase();
          if (platform === "windows" || platform === "macos") {
            // Desktop: ["platform", "osVersion", "browser", "browserVersion"]
            return [
              platform,
              device.osVersion || "latest",
              device.browser || "",
              device.browserVersion || "latest",
            ];
          } else {
            // Mobile: ["platform", "deviceName", "osVersion", "browser"]
            return [
              platform,
              device.deviceName || "",
              device.osVersion || "latest",
              device.browser || "",
            ];
          }
        }) || [];
    
      const validatedEnvironments = await validateDevices(
        tupleTargets,
        input.detectedBrowserAutomationFramework,
      );
    
      // Handle frameworks with unique setup instructions that don't use browserstack.yml
      if (
        input.detectedBrowserAutomationFramework === "cypress" ||
        input.detectedTestingFramework === "webdriverio"
      ) {
        const frameworkInstructions = getInstructionsForProjectConfiguration(
          input.detectedBrowserAutomationFramework as SDKSupportedBrowserAutomationFramework,
          input.detectedTestingFramework as SDKSupportedTestingFramework,
          input.detectedLanguage as SDKSupportedLanguage,
          username,
          accessKey,
        );
    
        if (frameworkInstructions) {
          if (frameworkInstructions.setup) {
            steps.push({
              type: "instruction",
              title: "Framework-Specific Setup",
              content: frameworkInstructions.setup,
            });
          }
    
          if (frameworkInstructions.run && !isPercyAutomate) {
            steps.push({
              type: "instruction",
              title: "Run the tests",
              content: frameworkInstructions.run,
            });
          }
        }
    
        return {
          steps,
          requiresPercy: false,
          missingDependencies: [],
        };
      }
    
      // Default flow using browserstack.yml
      const sdkSetupCommand = getSDKPrefixCommand(
        input.detectedLanguage as SDKSupportedLanguage,
        input.detectedTestingFramework as SDKSupportedTestingFramework,
        username,
        accessKey,
      );
    
      if (sdkSetupCommand) {
        steps.push({
          type: "instruction",
          title: "Install BrowserStack SDK",
          content: sdkSetupCommand,
        });
      }
    
      const frameworkInstructions = getInstructionsForProjectConfiguration(
        input.detectedBrowserAutomationFramework as SDKSupportedBrowserAutomationFramework,
        input.detectedTestingFramework as SDKSupportedTestingFramework,
        input.detectedLanguage as SDKSupportedLanguage,
        username,
        accessKey,
      );
    
      if (frameworkInstructions) {
        if (frameworkInstructions.setup) {
          steps.push({
            type: "instruction",
            title: "Framework-Specific Setup",
            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",
            title: "Run the tests",
            content: frameworkInstructions.run,
          });
        }
      }
    
      return {
        steps,
        requiresPercy: false,
        missingDependencies: [],
      };
    }
  • Zod schema definitions for RunTestsOnBrowserStackParamsShape, RunTestsOnBrowserStackSchema, and related types used for input validation in the tool.
    export const RunTestsOnBrowserStackParamsShape = {
      projectName: z
        .string()
        .describe("A single name for your project to organize all your tests."),
      detectedLanguage: z.nativeEnum(SDKSupportedLanguageEnum),
      detectedBrowserAutomationFramework: z.nativeEnum(
        SDKSupportedBrowserAutomationFrameworkEnum,
      ),
      detectedTestingFramework: z.nativeEnum(SDKSupportedTestingFrameworkEnum),
      devices: z
        .array(DeviceSchema)
        .max(3)
        .default([])
        .describe(
          "Device objects array. Use the object format directly - no transformation needed. Add only when user explicitly requests devices. Examples: [{ platform: 'windows', osVersion: '11', browser: 'chrome', browserVersion: 'latest' }] or [{ platform: 'android', deviceName: 'Samsung Galaxy S24', osVersion: '14', browser: 'chrome' }].",
        ),
    };
    
    export const SetUpPercySchema = z.object(SetUpPercyParamsShape);
    
    export const RunTestsOnBrowserStackSchema = z.object(
      RunTestsOnBrowserStackParamsShape,
    );
    
    export type SetUpPercyInput = z.infer<typeof SetUpPercySchema>;
    export type RunTestsOnBrowserStackInput = z.infer<
      typeof RunTestsOnBrowserStackSchema
    >;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'get instructions' but does not clarify what form these instructions take (e.g., text, links, steps), whether it's a read-only operation, if it requires authentication, or any rate limits. This leaves significant gaps in understanding the tool's behavior beyond its basic purpose.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, straightforward sentence that efficiently states the tool's purpose without unnecessary words. It is front-loaded with the core action, but could be slightly more informative to improve utility while maintaining brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a tool with 4 required parameters and no annotations or output schema, the description is incomplete. It does not explain what the instructions entail, how they are generated, or what the user should expect as a result. This leaves too many gaps for effective agent use, especially without behavioral context or output details.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all four parameters. The description adds no additional meaning about parameters beyond what the schema provides, such as explaining why these inputs are needed for generating instructions. With high schema coverage, the baseline score of 3 is appropriate, as the description does not compensate but also does not detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool's purpose as 'to get instructions for running tests on BrowserStack', which is clear but vague. It specifies the action ('get instructions') and target ('running tests on BrowserStack'), but lacks specificity about what kind of instructions or how they are delivered. It does not distinguish from siblings like 'runAppLiveSession' or 'runBrowserLiveSession', which might also involve BrowserStack testing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It does not mention prerequisites, context, or exclusions, and there is no comparison to sibling tools like 'runAppLiveSession' or 'startAccessibilityScan'. Usage is implied only by the purpose, with no explicit when/when-not instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/browserstack/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server