Skip to main content
The Vercel AI SDK integration connects an AI SDK tool loop to the Stagehand facade MCP server over MCP/stdio. One server process owns the browser, so page state survives across run, snapshot, and screenshot calls.
Building with Eve? Use the native Eve integration to run the same tool contract in-process.
Stagehand ships this experimental integration from its repository and does not publish it as a standalone adapter.

Prerequisites

  • Node.js 24 or newer
  • pnpm 11.10.0
  • An OpenAI API key for the example agent
  • A current Google Chrome installation for local browser mode

Quickstart

1

Clone and build Stagehand

2

Configure the AI SDK agent

Set AI_SDK_STAGEHAND_MODEL to select another model supported by the example.
3

Choose the browser

The example uses local Chrome by default. To use Browserbase instead:
4

Run a browser task

Configuration

Keep the browser session alive

The example connects once with createMCPClient, loads the three tools, and closes the client only after the model loop finishes. Keep that lifetime when adapting the example; reconnecting for each call starts another browser and loses previous state. The MCP child receives only Stagehand and Browserbase configuration plus the process values required to launch Node. The host’s model credential remains in the AI SDK process.
run executes model-authored JavaScript in the browser. Use Browserbase for untrusted tasks and review the integration security boundary.

Vercel AI SDK integration source

Read the MCP client setup, agent loop, and contract tests.