Skip to main content
Glama

browserbase_stagehand_extract

Extract structured data or text from web pages using specific instructions. Define what information to collect from the current page for automated data extraction.

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 executes the tool logic: retrieves stagehand from context, calls stagehand.extract with the instruction, formats the result as text content, 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,
      };
    }
  • Defines the Zod input schema (instruction string) and the tool schema including name, description, and inputSchema.
    const ExtractInputSchema = z.object({
      instruction: z.string().describe(
        `The 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.`,
      ),
    });
    
    type ExtractInput = z.infer<typeof ExtractInputSchema>;
    
    const extractSchema: ToolSchema<typeof ExtractInputSchema> = {
      name: "browserbase_stagehand_extract",
      description: `Extract structured data or text from the current page using an instruction.`,
      inputSchema: ExtractInputSchema,
    };
  • Creates and exports the tool object combining capability, schema, and handle function for registration.
    const extractTool: Tool<typeof ExtractInputSchema> = {
      capability: "core",
      schema: extractSchema,
      handle: handleExtract,
    };
    
    export default extractTool;
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 'from the current page' implying it operates within an existing browser context, but doesn't specify prerequisites (e.g., requires an active session), performance characteristics (e.g., execution time, reliability), or what happens on failure. For a tool with no annotation coverage, this leaves significant behavioral gaps.

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 extremely concise - a single sentence that efficiently communicates the core functionality. Every word earns its place: 'Extract' (action), 'structured data or text' (what), 'from the current page' (where), 'using an instruction' (how). There's no wasted language or unnecessary elaboration.

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 the tool's moderate complexity (extraction operation with one parameter) and 100% schema coverage but no annotations or output schema, the description is minimally adequate. It explains what the tool does but doesn't address behavioral aspects, usage context, or output format. For a tool that performs content extraction without safety annotations, more guidance would be beneficial.

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 description doesn't add meaningful parameter semantics beyond what's already in the input schema. The schema has 100% coverage with a detailed description of the 'instruction' parameter including examples. The tool description merely repeats 'using an instruction' without providing additional context about parameter usage or constraints. With high schema coverage, the baseline score of 3 is appropriate.

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 from current page), and mechanism (using an instruction). However, it doesn't explicitly differentiate from sibling tools like 'browserbase_stagehand_observe' which might also involve page content analysis.

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. With sibling tools like 'browserbase_stagehand_observe' (which might monitor page content) and 'browserbase_screenshot' (which captures visual data), there's no indication of when extraction is preferred over observation or other methods. The description only states what the tool does, not when it's appropriate.

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/kolbertistvan2/stagehand-mcp-server'

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