browserbase_stagehand_act
Execute specific web page actions like clicking buttons or typing text through browser automation commands.
Instructions
Perform a single action on the page (e.g., click, type).
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'. | |
| variables | No | Variables used in the action template. ONLY use variables if you're dealing with sensitive data or dynamic content. When using variables, you MUST have the variable key in the action template. ie: {"action": "Fill in the password", "variables": {"password": "123456"}} |
Implementation Reference
- src/tools/act.ts:36-66 (handler)The main handler function for the 'browserbase_stagehand_act' tool. It retrieves the stagehand from context and executes the act action with provided parameters.async function handleAct( context: Context, params: ActInput, ): Promise<ToolResult> { const action = async (): Promise<ToolActionResult> => { try { const stagehand = await context.getStagehand(); await stagehand.act(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:30-34 (schema)The schema definition for the tool, including name, description, and input schema reference.const actSchema: ToolSchema<typeof ActInputSchema> = { name: "browserbase_stagehand_act", description: `Perform a single action on the page (e.g., click, type).`, inputSchema: ActInputSchema, };
- src/tools/act.ts:13-26 (schema)The Zod input schema defining the expected parameters: 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'.`, ), variables: z .object({}) .optional() .describe( `Variables used in the action template. ONLY use variables if you're dealing with sensitive data or dynamic content. When using variables, you MUST have the variable key in the action template. ie: {"action": "Fill in the password", "variables": {"password": "123456"}}`, ), });
- src/tools/act.ts:68-74 (registration)The tool object that combines the schema and handler, exported for registration in the MCP server.const actTool: Tool<typeof ActInputSchema> = { capability: "core", schema: actSchema, handle: handleAct, }; export default actTool;