browserbase_stagehand_act
Execute specific web page actions like clicking buttons or typing text through automated browser control for precise web automation tasks.
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
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | 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 | No | 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"}} |
Implementation Reference
- src/tools/act.ts:38-69 (handler)The handler function `handleAct` that performs the core logic of the tool by invoking `stagehand.page.act()` with the action and optional variables.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, }; }
- src/tools/act.ts:28-36 (schema)The tool schema defining the name 'browserbase_stagehand_act', description, and references the input schema for validation.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, };
- src/tools/act.ts:6-24 (schema)The Zod input schema defining the parameters: action (required 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"}}', ), });
- src/tools/index.ts:43-52 (registration)The central TOOLS array where actTool (containing the browserbase_stagehand_act tool) is registered alongside other tools for use in the MCP server.export const TOOLS = [ ...multiSessionTools, ...sessionTools, navigateTool, actTool, extractTool, observeTool, screenshotTool, getUrlTool, ];
- src/tools/act.ts:71-77 (registration)The actTool object that registers the schema and handler together, exported for inclusion in the tools index.const actTool: Tool<typeof ActInputSchema> = { capability: "core", schema: actSchema, handle: handleAct, }; export default actTool;