Skip to main content
Glama
RonsDad
by RonsDad

browserbase_stagehand_act

Execute specific web page interactions like clicking buttons or typing text through cloud browser automation with AI commands.

Instructions

Performs an action on a web page element. Act actions should be as atomic and specific as possible, i.e. "Click the sign in button" or "Type 'hello' into the search input". AVOID actions that are more than one step, i.e. "Order me pizza" or "Send an email to Paul asking him to call me".

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesThe action to perform. Should be as atomic and specific as possible, i.e. 'Click the sign in button' or 'Type 'hello' into the search input'. AVOID actions that are more than one step, i.e. 'Order me pizza' or 'Send an email to Paul asking him to call me'. The instruction should be just as specific as possible, and have a strong correlation to the text on the page. If unsure, use observe before using act.
variablesNoVariables used in the action template. ONLY use variables if you're dealing with sensitive data or dynamic content. For example, if you're logging in to a website, you can use a variable for the password. When using variables, you MUST have the variable key in the action template. For example: {"action": "Fill in the password", "variables": {"password": "123456"}}

Implementation Reference

  • The handler function `handleAct` that performs the browser action using Stagehand's `page.act()` method.
    async function handleAct(
      context: Context,
      params: ActInput,
    ): Promise<ToolResult> {
      const action = async (): Promise<ToolActionResult> => {
        try {
          const stagehand = await context.getStagehand();
    
          await stagehand.page.act({
            action: params.action,
            variables: params.variables,
          });
    
          return {
            content: [
              {
                type: "text",
                text: `Action performed: ${params.action}`,
              },
            ],
          };
        } catch (error) {
          const errorMsg = error instanceof Error ? error.message : String(error);
          throw new Error(`Failed to perform action: ${errorMsg}`);
        }
      };
    
      return {
        action,
        waitForNetwork: false,
      };
    }
  • The tool schema definition including the name 'browserbase_stagehand_act', description, and reference to input schema.
    const actSchema: ToolSchema<typeof ActInputSchema> = {
      name: "browserbase_stagehand_act",
      description:
        "Performs an action on a web page element. Act actions should be as atomic and " +
        'specific as possible, i.e. "Click the sign in button" or "Type \'hello\' into the search input". ' +
        'AVOID actions that are more than one step, i.e. "Order me pizza" or "Send an email to Paul ' +
        'asking him to call me".',
      inputSchema: ActInputSchema,
    };
  • The Zod input schema `ActInputSchema` defining the `action` string and optional `variables` object.
    const ActInputSchema = z.object({
      action: z
        .string()
        .describe(
          "The action to perform. Should be as atomic and specific as possible, " +
            "i.e. 'Click the sign in button' or 'Type 'hello' into the search input'. AVOID actions that are more than one " +
            "step, i.e. 'Order me pizza' or 'Send an email to Paul asking him to call me'. The instruction should be just as specific as possible, " +
            "and have a strong correlation to the text on the page. If unsure, use observe before using act.",
        ),
      variables: z
        .object({})
        .optional()
        .describe(
          "Variables used in the action template. ONLY use variables if you're dealing " +
            "with sensitive data or dynamic content. For example, if you're logging in to a website, " +
            "you can use a variable for the password. When using variables, you MUST have the variable " +
            'key in the action template. For example: {"action": "Fill in the password", "variables": {"password": "123456"}}',
        ),
    });
  • The `actTool` is included in the `TOOLS` array export, making it available for registration in the MCP server.
    export const TOOLS = [
      ...multiSessionTools,
      ...sessionTools,
      navigateTool,
      actTool,
      extractTool,
      observeTool,
      screenshotTool,
      getUrlTool,
    ];
  • src/index.ts:196-226 (registration)
    Generic tool registration loop that registers all tools from the `TOOLS` array with the MCP server using `server.tool()`, including 'browserbase_stagehand_act'.
    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.4/5.0
Behavior3/5

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

No annotations provided; description gives some behavioral context (e.g., atomic actions) but lacks details on side effects, permissions, or reversibility, which is a gap for a tool with no annotations.

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 focused sentences with no fluff, front-loaded purpose, and clear structure. Every word adds value.

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?

Covers essential aspects for a simple 2-param tool: purpose, usage constraints, and examples. Lacks return value info, but given no output schema, it's reasonably complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, but description adds value by providing examples for 'action' and explaining the use of 'variables' for sensitive data, enhancing understanding beyond the schema.

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 tool performs actions on web page elements, with emphasis on atomicity and specificity, distinguishing it from siblings like observe or navigate.

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 actions to be atomic and specific, provides concrete examples of good and bad actions, and suggests using observe if unsure, offering clear when-to-use guidance.

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