Skip to main content
Glama
browserstack

BrowserStack MCP server

Official

getFailuresInLastRun

Identify and debug test failures from the last run of your test suite on BrowserStack using the browserstack.yml configuration file. Specify build and project names for targeted results.

Instructions

Use this tool to debug failures in the last run of the test suite on BrowserStack. Use only when browserstack.yml file is present in the project root.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
buildNameYesName of the build to get failures for. This is the 'build' key in the browserstack.yml file. If not sure, ask the user for the build name.
projectNameYesName of the project to get failures for. This is the 'projectName' key in the browserstack.yml file. If not sure, ask the user for the project name.

Implementation Reference

  • Core handler function that fetches the latest BrowserStack build info, extracts observability URL, overview insight, and top error details, then formats and returns them as tool result.
    export async function getFailuresInLastRun(
      buildName: string,
      projectName: string,
      config: BrowserStackConfig,
    ): Promise<CallToolResult> {
      const buildsData = await getLatestO11YBuildInfo(
        buildName,
        projectName,
        config,
      );
    
      if (!buildsData.data) {
        throw new Error(
          "No observability URL found in build data, this is likely because the build is not yet available on BrowserStack Observability.",
        );
      }
      const observabilityUrl = buildsData.data.observability_url;
      if (!observabilityUrl) {
        throw new Error(
          "No observability URL found in build data, this is likely because the build is not yet available on BrowserStack Observability.",
        );
      }
    
      let overview = "No overview available";
      if (buildsData.data.unique_errors?.overview?.insight) {
        overview = buildsData.data.unique_errors.overview.insight;
      }
    
      let details = "No error details available";
      if (buildsData.data.unique_errors?.top_unique_errors?.length > 0) {
        details = buildsData.data.unique_errors.top_unique_errors
          .map((error: any) => error.error)
          .filter(Boolean)
          .join("\n");
      }
    
      return {
        content: [
          {
            type: "text",
            text: `Observability URL: ${observabilityUrl}\nOverview: ${overview}\nError Details: ${details}`,
          },
        ],
      };
    }
  • Zod input schema defining parameters buildName and projectName for the tool.
    {
      buildName: z
        .string()
        .describe(
          "Name of the build to get failures for. This is the 'build' key in the browserstack.yml file. If not sure, ask the user for the build name.",
        ),
      projectName: z
        .string()
        .describe(
          "Name of the project to get failures for. This is the 'projectName' key in the browserstack.yml file. If not sure, ask the user for the project name.",
        ),
    },
  • Registers the getFailuresInLastRun tool with the MCP server, including description, input schema, and a wrapper handler that provides tracking and error handling around the core logic.
    server.tool(
      "getFailuresInLastRun",
      "Use this tool to debug failures in the last run of the test suite on BrowserStack. Use only when browserstack.yml file is present in the project root.",
      {
        buildName: z
          .string()
          .describe(
            "Name of the build to get failures for. This is the 'build' key in the browserstack.yml file. If not sure, ask the user for the build name.",
          ),
        projectName: z
          .string()
          .describe(
            "Name of the project to get failures for. This is the 'projectName' key in the browserstack.yml file. If not sure, ask the user for the project name.",
          ),
      },
      async (args) => {
        try {
          trackMCP(
            "getFailuresInLastRun",
            server.server.getClientVersion()!,
            undefined,
            config,
          );
          return await getFailuresInLastRun(
            args.buildName,
            args.projectName,
            config,
          );
        } catch (error) {
          logger.error("Failed to get failures in the last run: %s", error);
          trackMCP(
            "getFailuresInLastRun",
            server.server.getClientVersion()!,
            error,
            config,
          );
          return {
            content: [
              {
                type: "text",
                text: `Failed to get failures in the last run. Error: ${error}. Please open an issue on GitHub if this is an issue with BrowserStack`,
                isError: true,
              },
            ],
            isError: true,
          };
        }
      },
    );
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 mentions the prerequisite (browserstack.yml file) and implies a read-only debugging function, but it lacks details on permissions, rate limits, error handling, or what the output looks like (e.g., failure details format). For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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

Conciseness5/5

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

The description is two sentences, front-loaded with the purpose and followed by a usage condition. Every sentence adds value without redundancy, making it efficient and well-structured for quick comprehension.

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

Completeness3/5

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

Given no annotations and no output schema, the description is moderately complete. It covers the purpose and a key prerequisite, but it lacks details on behavioral aspects like output format, error cases, or integration with sibling tools. For a debugging tool with two required parameters, this is adequate but leaves room for improvement in contextual richness.

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%, with clear descriptions for both parameters (buildName and projectName) in the input schema. The description adds no additional parameter information beyond what the schema provides, such as examples or constraints. Baseline 3 is appropriate since the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'debug failures in the last run of the test suite on BrowserStack.' It specifies the action (debug failures) and resource (test suite on BrowserStack), though it doesn't explicitly differentiate from sibling tools like 'runTestsOnBrowserStack' or 'startAccessibilityScan' beyond the debugging focus.

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

Usage Guidelines4/5

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

The description provides clear context for when to use the tool: 'Use only when browserstack.yml file is present in the project root.' This gives a prerequisite condition, but it doesn't explicitly state when not to use it or name alternatives among the sibling tools, such as when to choose this over 'runTestsOnBrowserStack' for debugging versus execution.

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