Skip to main content
Glama
RonsDad
by RonsDad

browserbase_screenshot

Capture screenshots of web pages during browser automation to visually verify page states and locate elements when other methods are insufficient.

Instructions

Takes a screenshot of the current page. Use this tool to learn where you are on the page when controlling the browser with Stagehand. Only use this tool when the other tools are not sufficient to get the information you need.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoThe name of the screenshot

Implementation Reference

  • The main handler function for the browserbase_screenshot tool. It captures a screenshot of the current active Browserbase page, converts it to base64, stores it in the screenshots resource map, notifies the client of resource changes, and returns the screenshot as image content.
    async function handleScreenshot(
      context: Context,
      params: ScreenshotInput,
    ): Promise<ToolResult> {
      const action = async (): Promise<ToolActionResult> => {
        try {
          const page = await context.getActivePage();
          if (!page) {
            throw new Error("No active page available");
          }
    
          const screenshotBuffer = await page.screenshot({
            fullPage: false,
          });
    
          // Convert buffer to base64 string and store in memory
          const screenshotBase64 = screenshotBuffer.toString("base64");
          const name = params.name
            ? `screenshot-${params.name}-${new Date()
                .toISOString()
                .replace(/:/g, "-")}`
            : `screenshot-${new Date().toISOString().replace(/:/g, "-")}` +
              context.config.browserbaseProjectId;
          screenshots.set(name, screenshotBase64);
    
          // Notify the client that the resources changed
          const serverInstance = context.getServer();
    
          if (serverInstance) {
            serverInstance.notification({
              method: "notifications/resources/list_changed",
            });
          }
    
          return {
            content: [
              {
                type: "text",
                text: `Screenshot taken with name: ${name}`,
              },
              {
                type: "image",
                data: screenshotBase64,
                mimeType: "image/png",
              },
            ],
          };
        } catch (error) {
          const errorMsg = error instanceof Error ? error.message : String(error);
          throw new Error(`Failed to take screenshot: ${errorMsg}`);
        }
      };
    
      return {
        action,
        waitForNetwork: false,
      };
    }
  • The schema definition for the browserbase_screenshot tool, including name, description, and input schema (ScreenshotInputSchema defined above).
    const screenshotSchema: ToolSchema<typeof ScreenshotInputSchema> = {
      name: "browserbase_screenshot",
      description:
        "Takes a screenshot of the current page. Use this tool to learn where you are on the page when controlling the browser with Stagehand. Only use this tool when the other tools are not sufficient to get the information you need.",
      inputSchema: ScreenshotInputSchema,
    };
  • Local registration of the screenshot tool object, combining schema and handler, exported as default.
    const screenshotTool: Tool<typeof ScreenshotInputSchema> = {
      capability: "core",
      schema: screenshotSchema,
      handle: handleScreenshot,
    };
    
    export default screenshotTool;
  • Includes the screenshotTool in the main TOOLS array exported from tools/index.ts, which collects all available tools.
    export const TOOLS = [
      ...multiSessionTools,
      ...sessionTools,
      navigateTool,
      actTool,
      extractTool,
      observeTool,
      screenshotTool,
      getUrlTool,
    ];
  • src/index.ts:196-226 (registration)
    Registers all tools from TOOLS array with the MCP server using server.tool(), wrapping the tool handler with context.run(tool, params). This is where 'browserbase_screenshot' is registered in the MCP protocol.
    const tools: MCPToolsArray = [...TOOLS];
    
    // Register each tool with the Smithery server
    tools.forEach((tool) => {
      if (tool.schema.inputSchema instanceof z.ZodObject) {
        server.tool(
          tool.schema.name,
          tool.schema.description,
          tool.schema.inputSchema.shape,
          async (params: z.infer<typeof tool.schema.inputSchema>) => {
            try {
              const result = await context.run(tool, params);
              return result;
            } catch (error) {
              const errorMessage =
                error instanceof Error ? error.message : String(error);
              process.stderr.write(
                `[Smithery Error] ${new Date().toISOString()} Error running tool ${tool.schema.name}: ${errorMessage}\n`,
              );
              throw new Error(
                `Failed to run tool '${tool.schema.name}': ${errorMessage}`,
              );
            }
          },
        );
      } else {
        console.warn(
          `Tool "${tool.schema.name}" has an input schema that is not a ZodObject. Schema type: ${tool.schema.inputSchema.constructor.name}`,
        );
      }
    });

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.0.0
    • addedInput schema / $schema
      Added value: +"http://json-schema.org/draft-07/schema#"
    • addedInput schema / additionalProperties
      Added value: +false
  2. First observed

TDQS

A4.1/5.0
Behavior3/5

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

No annotations provided, so description bears full burden. Discloses purpose but omits details on output (e.g., image format, storage), side effects, or authorization needs. Adequate but not thorough.

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?

Two sentences, concise and front-loaded with the action. No unnecessary words.

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?

Lacks output schema; description does not specify return type or behavior (e.g., base64 image, file path). With only one optional parameter, more detail on the tool's output would enhance completeness.

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?

100% schema coverage for the single 'name' parameter. Description does not elaborate on the parameter's role or format beyond the schema, meeting the baseline but adding no extra value.

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

Purpose5/5

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

Clearly states 'Takes a screenshot of the current page' and explains its purpose for spatial awareness. Distinguishes from sibling tools by positioning it as a fallback when other tools are insufficient.

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

Usage Guidelines5/5

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

Explicitly advises when to use ('to learn where you are') and when not to ('only use when other tools are not sufficient'), providing clear context for tool selection.

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