Browserbase and Stagehand: MCP setup and Python tutorial
Learn Browserbase MCP setup in Claude Code and Stagehand browser automation in Python, with local execution and a Google Flights scraping example.
Player not loading? Watch on YouTube
This sponsored tutorial covers Browserbase remote browser sessions and the Stagehand SDK for web automation. The speaker connects Browserbase to Claude Code through an MCP server, adds an API key, restarts Claude Code and checks the connection with /mcp. A YouTube search demonstrates the workflow, while the Browserbase dashboard provides live session viewing, network logs and recorded replays.
The Python examples use Stagehand to extract structured data from Hacker News. They explain how extract returns data in a chosen schema, observe finds available interactions and act performs an action. A Google Flights example uses execute for a multistep search, then extracts three flight results. The speaker reports that this run took about four minutes and explains that caching can speed up later runs.
Stagehand can also control a browser on the user's own computer. Local browser execution is distinct from local model inference: the examples use model API keys or Browserbase's Model Gateway. Remote execution adds Browserbase credentials and a project ID. The speaker suggests remote sessions for an AI agent running on a VPS without its own browser.
The final comparison presents Stagehand's natural-language instructions as easier to maintain than manual Playwright selectors. Claims about recovery from page changes and avoiding access blocks are the speaker's claims, rather than guarantees established by these examples.