> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stagehand.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Frameworks

> Add persistent browser tools to your agent framework through MCP or native bindings.

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:

| Framework | Connection | Guide |
| - | - | - |
| Eve | Native TypeScript tools in the Eve process. | [Eve](/v4/integrations/agent-frameworks/eve) |
| Deep Agents | MCP over stdio locally, or native Python tools in Managed Deep Agents. | [Deep Agents](/v4/integrations/agent-frameworks/deep-agents) |
| CrewAI | Python agent connected to the TypeScript MCP server over stdio. | [CrewAI](/v4/integrations/agent-frameworks/crewai) |
| Mastra | MCP tools in a Mastra agent. | [Mastra](/v4/integrations/agent-frameworks/mastra) |
| Vercel AI SDK | MCP tools in an AI SDK tool loop. | [Vercel AI SDK](/v4/integrations/agent-frameworks/vercel-ai-sdk) |

Each integration provides `run`, `snapshot`, and `screenshot`. To connect an existing coding agent instead, see [CLI Agents](/v4/integrations/cli-agents/overview).

<Info>
  These integrations are experimental and run from the Stagehand repository. The adapters and shared integration package are not published as standalone packages.
</Info>

## Tool contract

The agent framework integrations expose the same browser capabilities.

<AccordionGroup>
  <Accordion title="snapshot">
    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.
  </Accordion>

  <Accordion title="run">
    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`.

    ```json JavaScript theme={null}
    {
      "code": "await page.goto('https://example.com'); return await page.title();"
    }
    ```

    ```json Snapshot actions theme={null}
    {
      "actions": [{ "op": "click", "id": "1-42" }]
    }
    ```
  </Accordion>

  <Accordion title="screenshot">
    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.
  </Accordion>
</AccordionGroup>

## 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.

<Warning>
  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.
</Warning>

## 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.

<Warning>
  Use Browserbase as the isolation boundary for untrusted tasks. Treat authenticated browser sessions and any data reachable from them as privileged.
</Warning>

Pass only the credentials required by the browser runtime. Configure the framework’s tool permissions and credential handling according to its integration guide.

<Card title="View all integration source" icon="github" href="https://github.com/browserbase/stagehand/tree/main/packages/integrations">
  Browse the shared implementation and all framework examples on GitHub.
</Card>
