Skip to main content
Glama
MesuterPikin

Browserbase MCP Server

by MesuterPikin

browserbase_stagehand_extract

Extract structured data or text from web pages using specific instructions to target and retrieve information from the current page.

Instructions

Extract structured data or text from the current page using an instruction.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instructionYesThe specific instruction for what information to extract from the current page. Be as detailed and specific as possible about what you want to extract. For example: 'Extract all product names and prices from the listing page'.The more specific your instruction, the better the extraction results will be.

Implementation Reference

  • The `handleExtract` function that implements the core logic of the `browserbase_stagehand_extract` tool. It retrieves the stagehand instance from context, calls `extract` with the instruction, formats the result as text content, and handles errors.
    async function handleExtract(
      context: Context,
      params: ExtractInput,
    ): Promise<ToolResult> {
      const action = async (): Promise<ToolActionResult> => {
        try {
          const stagehand = await context.getStagehand();
    
          const extraction = await stagehand.extract(params.instruction);
    
          return {
            content: [
              {
                type: "text",
                text: `Extracted content:\n${JSON.stringify(extraction, null, 2)}`,
              },
            ],
          };
        } catch (error) {
          const errorMsg = error instanceof Error ? error.message : String(error);
          throw new Error(`Failed to extract content: ${errorMsg}`);
        }
      };
    
      return {
        action,
        waitForNetwork: false,
      };
    }
  • The tool schema defining the name `browserbase_stagehand_extract`, description, and input schema (instruction: string). The input schema `ExtractInputSchema` is defined earlier (lines 15-22).
    const extractSchema: ToolSchema<typeof ExtractInputSchema> = {
      name: "browserbase_stagehand_extract",
      description: `Extract structured data or text from the current page using an instruction.`,
      inputSchema: ExtractInputSchema,
    };
  • The `extractTool` object that combines the schema and handler, exported as default for inclusion in the tools registry.
    const extractTool: Tool<typeof ExtractInputSchema> = {
      capability: "core",
      schema: extractSchema,
      handle: handleExtract,
    };
    
    export default extractTool;
  • The `extractTool` is imported and included in the `TOOLS` array, which is imported by the MCP server (`src/index.ts`) to dynamically register all tools.
    export const TOOLS = [
      ...sessionTools,
      navigateTool,
      actTool,
      extractTool,
      observeTool,
      screenshotTool,
      getUrlTool,
      agentTool,
    ];
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 extraction but doesn't specify details like whether it requires a loaded page, how it handles errors, what formats the output might be in, or any performance considerations. This leaves significant gaps for an agent to understand the tool's behavior beyond basic functionality.

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 a single, efficient sentence that front-loads the core purpose without unnecessary details. It's appropriately sized for a tool with one parameter and no annotations, with zero waste or redundancy.

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 data extraction tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns, how to interpret results, or any behavioral traits like error handling. This makes it inadequate for an agent to use the tool effectively in varied contexts.

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 schema description coverage is 100%, with the 'instruction' parameter well-documented in the schema. The description adds minimal value beyond the schema by reiterating the need for an instruction but doesn't provide additional semantic context or examples not already covered. Baseline 3 is appropriate as 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: 'Extract structured data or text from the current page using an instruction.' It specifies the verb ('extract'), resource ('structured data or text'), and context ('from the current page'). However, it doesn't explicitly differentiate from sibling tools like 'browserbase_stagehand_observe' or 'browserbase_stagehand_agent', which might have overlapping or related functionality.

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 doesn't mention sibling tools or contexts where extraction is preferred over other actions like navigation or observation. Usage is implied by the purpose but lacks explicit when/when-not instructions or prerequisites.

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

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