Skip to main content
Glama

browserbase_screenshot

Capture browser screenshots to verify page state and locate elements during web automation workflows.

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 handler function that takes a screenshot of the active page using Puppeteer, stores the base64 image in resources, notifies the client, and returns text and 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 tool schema defining the name, description, and input schema (ScreenshotInputSchema with optional 'name') for the browserbase_screenshot tool.
    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,
    };
  • The screenshotTool is included in the TOOLS array exported from tools/index.ts, which is used to register all tools with the MCP server.
    export const TOOLS = [
      ...multiSessionTools,
      ...sessionTools,
      navigateTool,
      actTool,
      extractTool,
      observeTool,
      screenshotTool,
      getUrlTool,
    ];
  • src/index.ts:192-222 (registration)
    The loop that registers every tool from the TOOLS array (including browserbase_screenshot) with the MCP server by calling server.tool() for each.
    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}`,
        );
      }
    });
Behavior3/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. It mentions the tool's purpose and usage context but lacks details on behavioral traits such as performance impact, file output format, or error conditions. However, it does add value by explaining the tool's role in the Stagehand workflow, which isn't covered by structured fields.

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 highly concise and front-loaded, with two sentences that efficiently convey purpose and usage guidelines without unnecessary details. Every sentence earns its place by providing critical information for tool selection.

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

Completeness4/5

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

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is reasonably complete. It covers purpose and usage well but could benefit from mentioning behavioral aspects like what the screenshot returns or any limitations. However, for a simple tool, it provides sufficient context for effective use.

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?

The input schema has 100% description coverage for its single parameter ('name'), so the schema already documents it fully. The description does not add any parameter-specific information beyond what the schema provides, resulting in a baseline score of 3 as per the rules.

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?

The description clearly states the specific action ('Takes a screenshot') and resource ('of the current page'), distinguishing it from sibling tools like navigation or extraction tools. It explicitly mentions the context of 'controlling the browser with Stagehand,' which helps differentiate its purpose from generic screenshot tools.

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?

The description provides explicit guidance on when to use this tool ('to learn where you are on the page when controlling the browser with Stagehand') and when not to use it ('Only use this tool when the other tools are not sufficient to get the information you need'). This directly addresses alternatives among sibling tools, offering clear decision criteria.

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

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/vaibhavAtlys/mcp-server-browserbase'

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