Browser Agent
A powerful integration that combines the capabilities of Browserbase's Stagehand with Mastra for advanced web automation, scraping, and AI-powered web interactions.
Why we built this
This project enables AI agents to interact with web pages through the Mastra framework using Stagehand's browser automation capabilities. It provides tools for web navigation, element observation, data extraction, and action execution, all orchestrated through Mastra's agent system.
Features
- Web Navigation: Navigate to websites programmatically
- Element Observation: Identify and locate elements on web pages
- Action Execution: Perform actions like clicking buttons or filling forms
- Data Extraction: Extract structured data from web pages
- Session Management: Smart session handling with automatic timeouts and reconnection
- AI-Powered Interactions: Leverage OpenAI models for intelligent web interactions
Prerequisites
- OpenAI API key — used by default, but you can swap in any model
- Browserbase API key — for page scraping
Quickstart 🚀
- Clone the template
- Run
npx create-mastra@latest --template browsing-agentto scaffold the project locally.
- Run
- Add your API keys
- Copy
.env.exampleto.envand fill in your keys.
- Copy
- Start the dev server
- Run
npm run devand open localhost:4111 to try it out.
- Run
Making it yours
Open Studio and select the "Web Assistant" agent.
About Mastra templates
Mastra templates are ready-to-use projects that show off what you can build — clone one, poke around, and make it yours. They live in the Mastra monorepo and are automatically synced to standalone repositories for easier cloning.
Want to contribute? See CONTRIBUTING.md.
