run, snapshot, and screenshot tools backed by one persistent Stagehand browser per Pi session. Pi ships without built-in MCP by design; extensions register tools directly, so this integration runs in process without an MCP server or bridge. The tool descriptions, runtime validators, and system prompt come from the shared facade contract, so the tools behave the same as the MCP-based integrations.
Stagehand ships this experimental integration from the repository rather than publishing it as a standalone adapter.
Prerequisites
- Node.js 24 or newer
- pnpm 11.10.0
- A model-provider credential for Pi (
OPENAI_API_KEYorANTHROPIC_API_KEY) - A current Google Chrome installation for local browser mode
Quickstart
1
Clone and build Stagehand
2
Configure the Pi model
ANTHROPIC_API_KEY instead to use an Anthropic model. This credential is for Pi’s own model, not the browser.3
Choose the browser
The extension defaults to Browserbase when
BROWSERBASE_API_KEY is set, otherwise it uses local Chrome:4
Run a browser task
start script runs pi -e ./extensions/stagehand.ts --no-session -p, so no install step is required; Pi loads TypeScript directly and resolves @browserbasehq/stagehand-integrations through the workspace.Two headless gotchas: print mode reads piped stdin (always redirect
</dev/null), and non-interactive runs never show the project-trust prompt. Load the extension with -e as above, or use -a after trusting the project.Install permanently
To register the extension for every Pi session instead of loading it per invocation:pi manifest key in the package’s package.json points at the extension.
Configuration
Session lifecycle
The extension factory does not start a browser; factories also run in invocations that never start a session, such aspi --list-models. The browser launches lazily on the first tool call, relaunches if it closed, and closes on session shutdown. Shutdown awaits a still-pending launch before closing so it does not leak a racing launch.
snapshot and run return text content. screenshot returns real image content because Pi supports multimodal tool results.
Pi integration source
Read the extension tool registrations and lazy browser lifecycle.

