Skip to main content
Use Stagehand as the browser layer in an agent you build with an agent framework. Your framework manages the model, instructions, and tool loop; Stagehand keeps the browser session available as the agent navigates, interacts with pages, and reads results. Choose an integration based on your framework and how it connects tools: Each integration provides run, snapshot, and screenshot. To connect an existing coding agent instead, see CLI Agents.
These integrations are experimental and run from the Stagehand repository. The adapters and shared integration package are not published as standalone packages.

Tool contract

The agent framework integrations expose the same browser capabilities.
Read a compact accessibility tree for the active page. Pass the bracketed IDs on interactive elements to run actions.IDs are valid only for the latest snapshot of the active page. Take another snapshot after navigation or when an ID becomes stale.
Execute JavaScript against Playwright-shaped page, context, and browser objects, or send a batch of actions that reference snapshot IDs.run accepts exactly one of code or actions. Snapshot actions support click, hover, fill, type, press, and select.
JavaScript
Snapshot actions
Capture the active page as a PNG or JPEG for visual inspection. The integration adapts the image to the tool-result format supported by your framework.

How sessions work

The tools share a browser for the lifetime of the integration’s client session. A navigation performed by run is visible to the next snapshot, and authentication and page state remain available across calls. With MCP, keep one client connection open so the server and browser stay alive across calls. With native bindings, keep the browser runtime available for the lifetime of the agent session. Deployment-specific persistence and reconnection behavior are documented in each integration guide.
Do not create a new MCP process for every tool call. Doing so starts a new browser and invalidates any snapshot IDs from the previous call.

Set up your framework

Start with your framework’s guide for its runtime requirements, installation steps, and tool registration. Integrations can connect through a stdio MCP server or bind browser tools directly in the agent process.
  1. Install the integration and its required runtime dependencies.
  2. Register the browser tools with your framework’s agent loop.
  3. Configure the browser and the agent’s model credentials.
  4. Keep the browser connection available across tool calls, and close it when the session ends.

Choose a browser

Use local Chrome for development or a Browserbase session for hosted browser execution. Set the browser mode explicitly when you need predictable behavior across environments; defaults and environment-variable handling depend on the integration. For Browserbase, provide an API key and any project configuration required by the integration. For local mode, install a supported version of Chrome. See your framework’s guide for the exact settings.

Configure models

Your framework’s agent model decides which browser tool to call and what input to send. Configure that model and its credentials through your framework. Stagehand’s browser tools do not require a separate model for deterministic operations such as navigation, snapshots, and screenshots. If your integration supports Stagehand AI methods such as act, extract, or observe, configure a Stagehand model when using those methods. Keep the agent model and Stagehand model configuration separate. Credential forwarding and provider-key inference vary by integration; use its guide for the supported configuration names and how to pass credentials.

Security boundary

run executes model-authored JavaScript inside the Stagehand browser extension’s service worker, not in the agent host process. That code can control the browser and access anything available in its session.
Use Browserbase as the isolation boundary for untrusted tasks. Treat authenticated browser sessions and any data reachable from them as privileged.
Pass only the credentials required by the browser runtime. Configure the framework’s tool permissions and credential handling according to its integration guide.

View all integration source

Browse the shared implementation and all framework examples on GitHub.