When you give your agent a browser, Mastra gives it the tools to navigate pages, click through flows, fill forms, and extract structured data. This lets it work with sites that don’t have APIs and still complete tasks end to end.
Because this is integrated into Studio, you can see everything it’s doing. Each interaction is streamed live, and you can step in or stop it at any point.
We’re starting with Stagehand and AgentBrowser, with more providers coming. You can run browsers locally, or connect to managed browser services like Browserbase if you don’t want to manage browsers or the underlying infrastructure yourself.
Get started
Install a browser provider (requires @mastra/core@1.22.0 or later):
1npm install @mastra/stagehandCreate a browser instance and assign it to an agent. This example uses a local StagehandBrowser running in headless mode (no visible UI).
1import { Agent } from "@mastra/core/agent";
2import { StagehandBrowser } from "@mastra/stagehand";
3
4const browser = new StagehandBrowser({
5 headless: true,
6 model: "openai/gpt-5.4-mini"
7});
8
9export const agent = new Agent({
10 id: "browser-agent",
11 model: "anthropic/claude-opus-4-6",
12 browser,
13 instructions:
14 "You are a web automation assistant. Use browser tools to navigate websites and complete tasks."
15});
16
17// When a browser is attached, the agent automatically receives browser tools
18// (e.g. navigate, act, extract, observe), depending on the provider.For more information and full configuration options, see:
You can also see this walkthrough from Kristian from the Mastra community.
