Automatic MCP server generation for browser automation.
This repo contains two Cloudflare Workers:
orchestrator-workers/- Cloudflare Worker with:- MCP endpoint (
/mcp) - automation endpoints (
/automate,/automate/:id) - workflows + codegen + GitHub publish
- MCP endpoint (
stagehand-service/- Browserbase + Stagehand execution service (/execute)
orchestrator-workers:- Exposes MCP tool
automate_websiteat/mcp - Calls
stagehand-servicevia Cloudflare Service Binding - Codegens MCP server from discovered actions/cache
- Tests generated code in Cloudflare Sandbox
- Pushes to GitHub and returns repo URL
- Exposes MCP tool
stagehand-service:- Executes browser steps using Stagehand + Browserbase
- Returns step logs + artifacts (screenshots/html/cache)
cd stagehand-service
cp .env.example .env
# Set BROWSERBASE_PROJECT_ID, BROWSERBASE_API_KEY, AI_PROVIDER, AI_API_KEY
bun install
bun run devRuns on http://localhost:8788
cd orchestrator-workers
bun install
# Optional for local fallback only (without Service Binding):
# set STAGEHAND_SERVICE_URL=http://localhost:8788
bun run devRuns on http://localhost:8787
Deploy in this order:
- Deploy
stagehand-service - Deploy
orchestrator-workers(depends on service binding to stagehand)
For both Workers in Cloudflare:
- Install command:
bun install --frozen-lockfile - Build command:
bun run build - Deploy command:
npx wrangler deploy - Root directory:
stagehand-serviceproject:stagehand-serviceorchestrator-workersproject:orchestrator-workers
Set these in Cloudflare for stagehand-service:
BROWSERBASE_PROJECT_ID(secret)BROWSERBASE_API_KEY(secret)AI_PROVIDER(var; example:openaiorgoogle)AI_API_KEY(secret)
Set these in Cloudflare for orchestrator-workers:
AI_PROVIDER(var; currently codegen supportsopenaiandgoogle)AI_API_KEY(secret)GITHUB_TOKEN(secret; required for repo creation)GITHUB_OWNER(optional; auto-resolved from token if omitted)STAGEHAND_SERVICE_URL(optional var; only for non-binding fallback)
Run from repo root:
# Stagehand service secrets
cd stagehand-service
bunx wrangler secret put BROWSERBASE_PROJECT_ID
bunx wrangler secret put BROWSERBASE_API_KEY
bunx wrangler secret put AI_API_KEY
# Orchestrator workers secrets
cd ../orchestrator-workers
bunx wrangler secret put AI_API_KEY
bunx wrangler secret put GITHUB_TOKENNon-secret vars (AI_PROVIDER, optional GITHUB_OWNER, optional STAGEHAND_SERVICE_URL) should be set in each project's wrangler.jsonc vars section (or in the Cloudflare dashboard for the Worker).
orchestrator-workers/wrangler.jsonc includes:
servicesbindingSTAGEHAND_SERVICE -> stagehand-service
The target script name must exactly match the deployed script name in Cloudflare.
If Cloudflare renames scripts in CI, update binding service to that exact deployed name.
orchestrator-workers uses Sandbox DO and must keep migration configured:
"migrations": [{ "tag": "v1", "new_sqlite_classes": ["Sandbox"] }]
After both deploy successfully:
curl -X POST "https://<orchestrator-domain>/debug/stagehand-smoke" \
-H "Content-Type: application/json" \
-d '{"websiteUrl":"https://example.com","task":"Observe the page and summarize content"}'Expect:
ok: truetransport: "service-binding"(orurl-fallbackwhen using fallback URL mode)
Could not resolve service binding STAGEHAND_SERVICE:- Stagehand worker not deployed yet, wrong account, or wrong target script name.
STAGEHAND_SERVICE_URLfallback errors:- URL is wrong, host is down, or
/executeroute not reachable.
- URL is wrong, host is down, or
lockfile is frozen:- run
bun installlocally in that project, commit updatedbun.lock, redeploy.
- run
- Worker name mismatch warning in CI:
- align Cloudflare project worker name and
wrangler.jsoncname to avoid confusion.
- align Cloudflare project worker name and
Set your repository URL here after deployment.