Create a Cloudflare Worker project with npm create cloudflare and add @browserbasehq/stagehand and puppeteer as dependencies
In wrangler.toml, add a Browser binding: [browser] binding = 'BROWSER'
In the Worker handler, call const browser = await puppeteer.launch(env.BROWSER) to get a Cloudflare-managed browser instance
Pass the browser to Stagehand: const stagehand = new Stagehand({ browser, llm: { modelName: 'claude-opus-4-5', apiKey: env.ANTHROPIC_API_KEY } })
Run act/extract/observe or agent().execute() calls within the Worker request handler
Return the extracted data as a JSON response and ensure the browser is closed with browser.close()
Known gotchas
Cloudflare Workers have a 30-second CPU time limit; long-running agent loops must be offloaded to a Durable Object or Queue to avoid being killed mid-task
Only one concurrent browser session is available per Worker invocation; do not attempt to open multiple pages in parallel within one Worker
Paid Browser Rendering billing began August 2025; monitor usage in the Cloudflare dashboard to avoid unexpected charges
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp