Skip to content

Automate browser based workflows with AI

Add browser tunneling documentation (#4972)

Shuchang Zhengec175b5b5493
diff --git a/README.md b/README.md
index eafd5591c..894ca6653 100644
--- a/README.md
+++ b/README.md
@@ -269,18 +269,32 @@ BROWSER_TYPE=cdp-connect
Restart Skyvern service `skyvern run all` and run the task through UI or code
-### Run Skyvern with any remote browser
-Grab the cdp connection url and pass it to Skyvern
+### Connect Skyvern Cloud to your local browser
+
+Let Skyvern Cloud control a Chrome browser running on your machine — with all your existing cookies, logins, and extensions. Useful for automating sites where you're already logged in or behind a VPN.
+
+```bash
+# One command to start Chrome + create a tunnel to Skyvern Cloud
+skyvern browser serve --tunnel
+```
+
+Then use the tunnel URL in your task:
```python
from skyvern import Skyvern
-skyvern = Skyvern(cdp_url="your cdp connection url")
+skyvern = Skyvern(api_key="your-api-key")
task = await skyvern.run_task(
- prompt="Find the top post on hackernews today",
+ prompt="Download the latest invoice from my account",
+ browser_address="https://abc123.ngrok-free.dev",
)
```
+> [!WARNING]
+> Always use `--api-key` when exposing your browser via a tunnel. Without it, anyone with the URL has full control of your browser. See the [security docs](https://www.skyvern.com/docs/optimization/browser-tunneling#security).
+
+See the [full documentation](https://www.skyvern.com/docs/optimization/browser-tunneling) for all options, manual tunnel setup, and troubleshooting.
+
### Get consistent output schema from your run
You can do this by adding the `data_extraction_schema` parameter:
```python
diff --git a/docs/docs.json b/docs/docs.json
index 9b3dcdf9b..4ddf8ce0e 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -46,6 +46,7 @@
"group": "Optimization",
"pages": [
"optimization/browser-sessions",
+ "optimization/browser-tunneling",
"optimization/browser-profiles",
"optimization/cost-control"
]
diff --git a/docs/integrations/cli.mdx b/docs/integrations/cli.mdx
index e0007d558..21195d87b 100644
--- a/docs/integrations/cli.mdx
+++ b/docs/integrations/cli.mdx
@@ -83,6 +83,29 @@ skyvern browser login --url https://app.example.com --credential-id cred_xxx
Every browser command supports `--json` for machine-readable output, and `--session` / `--cdp` to target a specific session. If omitted, the CLI uses the last active session automatically.
</Tip>
+### Connect your local browser to Skyvern Cloud
+
+Expose your local Chrome to Skyvern Cloud so tasks can access localhost, internal tools, and your existing login sessions.
+
+```bash
+# Launch with ngrok tunnel and your Chrome profile's cookies/logins
+skyvern browser serve --tunnel --use-local-profile
+
+# Use a specific Chrome profile
+skyvern browser serve --tunnel --use-local-profile --chrome-profile-name "Profile 2"
+
+# Headless mode with JSON output (for scripting)
+skyvern browser serve --tunnel --headless --json
+```
+
+The `--use-local-profile` flag clones cookies and saved passwords from your Chrome profile into the served browser. Your original profile is never modified, and it works while Chrome is open.
+
+<Warning>
+Always pass `--api-key` when using `--tunnel`. Without it, anyone with the ngrok URL has full browser control.
+</Warning>
+
+See the [full guide](/optimization/browser-tunneling) for all options, manual tunnel setup, and security details.
+
### Workflows
```bash
diff --git a/docs/optimization/browser-sessions.mdx b/docs/optimization/browser-sessions.mdx
index 8f96b1710..94119e6a7 100644
--- a/docs/optimization/browser-sessions.mdx
+++ b/docs/optimization/browser-sessions.mdx
@@ -692,6 +692,13 @@ You can create a [Browser Profile](/optimization/browser-profiles) from a comple
## Next steps
<CardGroup cols={2}>
+ <Card
+ title="Connect Your Local Browser"
+ icon="laptop"
+ href="/optimization/browser-tunneling"
+ >
+ Let Skyvern Cloud use your local browser with your existing logins
+ </Card>
<Card
title="Browser Profiles"
icon="floppy-disk"
diff --git a/docs/optimization/browser-tunneling.mdx b/docs/optimization/browser-tunneling.mdx
new file mode 100644
index 000000000..10f1df9e9
--- /dev/null
+++ b/docs/optimization/browser-tunneling.mdx
@@ -0,0 +1,258 @@
+---
+title: Connect Skyvern to Your Local Browser
+subtitle: Run automations using your existing cookies, logins, and extensions
+slug: optimization/browser-tunneling
+---
+
+Want Skyvern Cloud to automate a site where you're already logged in? With `skyvern browser serve`, Skyvern Cloud can control a Chrome browser running on your machine — using your existing cookies, sessions, extensions, and saved passwords.
+
+**Common use cases:**
+- Automate sites where you're already authenticated (no need to re-login)
+- Reach internal tools behind a VPN or firewall
+- Use browser extensions you've already installed (ad blockers, auth tools, etc.)
+- Keep all browser data on your own machine
+
+---
+
+## Quick start
+
+One command starts Chrome on your machine and creates a tunnel so Skyvern Cloud can connect:
+
+```bash
+skyvern browser serve --tunnel
+```
+
+That's it. The CLI launches Chrome, starts a local proxy server, and opens an ngrok tunnel. You'll see a tunnel URL in the output — pass it as `browser_address` when running tasks.
+
+<Note>
+The `--tunnel` flag requires [ngrok](https://ngrok.com/download) to be installed and authenticated. Run `ngrok authtoken <your-token>` once to set it up.
+</Note>
+
+### Step-by-step (manual tunnel)
+
+If you prefer to manage the tunnel yourself:
+
+```bash
+# 1. Start the browser server
+skyvern browser serve
+
+# 2. In a separate terminal, create a tunnel
+ngrok http 9222
+
+# 3. Copy the ngrok URL and use it as browser_address in your task
+```
+
+---
+
+## Run a task on your local browser
+
+Once the tunnel is running, pass the tunnel URL as `browser_address`:
+
+<CodeGroup>
+```python Python
+import asyncio
+from skyvern import Skyvern
+
+async def main():
+ client = Skyvern(api_key="YOUR_API_KEY")
+
+ result = await client.run_task(
+ prompt="Download the latest invoice from my account",
+ browser_address="wss://abc123.ngrok-free.dev",
+ )
+
+ print(f"Status: {result.status}")
+ print(f"Output: {result.output}")
+
+asyncio.run(main())
+```
+
+```typescript TypeScript
+import { Skyvern } from "@skyvern/client";
+
+async function main() {
+ const client = new Skyvern({ apiKey: process.env.SKYVERN_API_KEY! });
+
+ const result = await client.runTask({
+ body: {
+ prompt: "Download the latest invoice from my account",
+ browser_address: "wss://abc123.ngrok-free.dev",
+ },
+ waitForCompletion: true,
+ });
+
+ console.log(`Status: ${result.status}`);
+ console.log(`Output: ${JSON.stringify(result.output)}`);
+}
+
+main();
+```
+
+```bash cURL
+curl -X POST "https://api.skyvern.com/v1/run/tasks" \
+ -H "x-api-key: $SKYVERN_API_KEY" \
+ -H "Content-Type: application/json" \
+ -d '{
+ "prompt": "Download the latest invoice from my account",
+ "browser_address": "wss://abc123.ngrok-free.dev"
+ }'
+```
+</CodeGroup>
+
+---
+
+## How it works
+
+```
+┌──────────────────────────────────────────────────────┐
+│ Your machine │
+│ │
+│ ┌────────────┐ CDP (internal) ┌──────────────┐ │
+│ │ Chrome │◄─────────────────►│ Unified │ │
+│ │ (port │ port 10222 │ Server │ │
+│ │ 10222) │ │ (port 9222) │ │
+│ └────────────┘ └──────┬───────┘ │
+│ │ │
+└──────────────────────────────────────────┼───────────┘
+ │
+ ngrok / tunnel│
+ │
+ ┌──────▼───────┐
+ │ Skyvern Cloud│
+ └──────────────┘
+```
+
+`skyvern browser serve`:
+
+1. **Launches Chrome** with CDP (Chrome DevTools Protocol) enabled on an internal port
+2. **Starts a proxy server** on the exposed port (default `9222`) that forwards CDP traffic to Chrome
+3. **Optionally creates a tunnel** (`--tunnel`) so Skyvern Cloud can reach it from the internet
+
+---
+
+## CLI options
+
+| Option | Default | Description |
+|---|---|---|
+| `--port` | `9222` | Port for the proxy server. Chrome uses `port + 1000` internally. |
+| `--profile-dir` | `~/.skyvern/chrome-profile` | Chrome user data directory. Point this at an existing profile to reuse cookies and logins. |
+| `--download-dir` | `~/.skyvern/downloads/{browser_id}` | Directory for browser downloads. |
+| `--api-key` | (none) | API key for authenticating incoming requests. See [Security](#security). |
+| `--headless` | `false` | Run Chrome in headless mode (no visible window). |
+| `--chrome-path` | (auto-detect) | Path to Chrome/Chromium executable. |
+| `--tunnel` | `false` | Automatically start an ngrok tunnel. Requires `ngrok` installed. |
+| `--json` | `false` | Output connection info as JSON (for scripting). Cannot combine with `--tunnel`. |
+
+The `--api-key` option can also be set via the `SKYVERN_BROWSER_SERVE_API_KEY` environment variable.
+
+### Examples
+
+```bash
+# Use a specific Chrome profile (reuse your existing logins)
+skyvern browser serve --profile-dir ~/Library/Application\ Support/Google/Chrome/Default
+
+# Run headless with auto-tunnel
+skyvern browser serve --headless --tunnel
+
+# Custom port with API key authentication
+skyvern browser serve --port 8222 --api-key "my-secret-key"
+
+# Output connection info as JSON (useful for scripting)
+skyvern browser serve --json
+```
+
+---
+
+## Security
+
+<Warning>
+**Read this section before exposing your browser to the internet.**
+
+When you run `skyvern browser serve` without `--api-key` and expose it via a tunnel, **anyone with the tunnel URL has full remote control of your Chrome browser**. This includes access to all logged-in sessions, cookies, saved passwords, and anything visible in the browser.
+</Warning>
+
+### API key authentication
+
+Use your Skyvern API key (from [Settings](https://app.skyvern.com/settings)) with the `--api-key` flag to require authentication on every incoming request:
+
+```bash
+skyvern browser serve --api-key "your-skyvern-api-key"
+```
+
+Or set it via environment variable:
+
+```bash
+export SKYVERN_BROWSER_SERVE_API_KEY="your-skyvern-api-key"
+skyvern browser serve
+```
+
+When enabled, all requests without a valid `x-api-key` header receive a `401 Unauthorized` response. Skyvern Cloud automatically sends the correct API key when connecting.
+
+### Additional security measures
+
+The built-in API key provides basic protection. For additional security such as IP allowlisting, mTLS, or VPN-based access, contact **[email protected]**.
+
+---
+
+## When to use this vs other options
+
+| Approach | When to use |
+|----------|-------------|
+| **Connect to your local browser** (`skyvern browser serve`) | You want Skyvern Cloud to use your local browser with your existing sessions |
+| **[Browser Sessions](/optimization/browser-sessions)** | You want Skyvern Cloud to manage the browser entirely in the cloud |
+| **[Browser Profiles](/optimization/browser-profiles)** | You want to save and reuse cookies/storage state across cloud sessions |
+| **[CDP Connect](/self-hosted/browser#cdp-connect-external-chrome)** (self-hosted) | You're running Skyvern locally and want to connect to an existing Chrome instance |
+
+---
+
+## Troubleshooting
+
+<AccordionGroup>
+ <Accordion title="ngrok not found">
+ Install ngrok from [ngrok.com/download](https://ngrok.com/download) and authenticate it:
+
+ ```bash
+ ngrok authtoken <your-token>
+ ```
+ </Accordion>
+
+ <Accordion title="Chrome not found">
+ Use `--chrome-path` to specify the path to your Chrome executable:
+
+ ```bash
+ # macOS
+ skyvern browser serve --chrome-path "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
+
+ # Linux
+ skyvern browser serve --chrome-path /usr/bin/google-chrome
+
+ # Windows
+ skyvern browser serve --chrome-path "C:\Program Files\Google\Chrome\Application\chrome.exe"
+ ```
+ </Accordion>
+
+ <Accordion title="Port already in use">
+ Another process is using port 9222. Either stop that process or use a different port:
+
+ ```bash
+ skyvern browser serve --port 8222
+ ```
+ </Accordion>
+
+ <Accordion title="Tunnel connection drops">
+ ngrok free tier tunnels have connection limits. For production use, consider an ngrok paid plan or contact [email protected] for alternative tunnel options.
+ </Accordion>
+</AccordionGroup>
+
+---
+
+## Next steps
+
+<CardGroup cols={2}>
+ <Card title="Browser Sessions" icon="window" href="/optimization/browser-sessions">
+ Use cloud-managed browser sessions for multi-step tasks
+ </Card>
+ <Card title="Browser Profiles" icon="floppy-disk" href="/optimization/browser-profiles">
+ Save and reuse authenticated browser state
+ </Card>
+</CardGroup>
diff --git a/fern/docs.yml b/fern/docs.yml
index c5c916113..c3cb62a1e 100644
--- a/fern/docs.yml
+++ b/fern/docs.yml
@@ -82,6 +82,8 @@ navigation:
path: running-tasks/cancel-runs.mdx
- page: Webhooks FAQ
path: running-tasks/webhooks-faq.mdx
+ - page: Connect Your Local Browser
+ path: running-tasks/connect-local-browser.mdx
- page: Proxy & Geo Targeting
path: running-tasks/proxy-location.mdx
- page: Advanced Settings for tasks
diff --git a/fern/running-tasks/connect-local-browser.mdx b/fern/running-tasks/connect-local-browser.mdx
new file mode 100644
index 000000000..7dbb4dd73
--- /dev/null
+++ b/fern/running-tasks/connect-local-browser.mdx
@@ -0,0 +1,102 @@
+---
+title: Connect Skyvern to Your Local Browser
+subtitle: Run automations using your existing cookies, logins, and extensions
+slug: running-tasks/connect-local-browser
+---
+
+## Why connect your local browser?
+
+With `skyvern browser serve`, Skyvern Cloud can control a Chrome browser running on your machine — using your existing cookies, sessions, extensions, and saved passwords. This is useful when:
+
+- You need to automate a site where you're already logged in
+- The target site is behind a VPN or firewall that only your machine can reach
+- You want Skyvern to use browser extensions you've already installed
+
+## Quick start
+
+```bash
+skyvern browser serve --tunnel
+```
+
+This launches Chrome on your machine, starts a CDP proxy server, and creates an ngrok tunnel so Skyvern Cloud can connect automatically.
+
+> The `--tunnel` flag requires [ngrok](https://ngrok.com/download) installed and authenticated (`ngrok authtoken <your-token>`).
+
+### Manual tunnel setup
+
+```bash
+# 1. Start the browser server
+skyvern browser serve
+
+# 2. In a separate terminal, create a tunnel
+ngrok http 9222
+
+# 3. Copy the ngrok URL and use it as browser_address in your task
+```
+
+## Run a task on your local browser
+
+Pass the tunnel URL as `browser_address`:
+
+```python
+from skyvern import Skyvern
+
+skyvern = Skyvern(api_key="YOUR_API_KEY")
+
+result = await skyvern.run_task(
+ prompt="Download the latest invoice from my account",
+ browser_address="wss://abc123.ngrok-free.dev",
+)
+```
+
+## How it works
+
+```
+┌──────────────────────────────────────────────────────┐
+│ Your machine │
+│ │
+│ ┌────────────┐ CDP (internal) ┌──────────────┐ │
+│ │ Chrome │◄─────────────────►│ Unified │ │
+│ │ (port │ port 10222 │ Server │ │
+│ │ 10222) │ │ (port 9222) │ │
+│ └────────────┘ └──────┬───────┘ │
+│ │ │
+└──────────────────────────────────────────┼───────────┘
+ │
+ ngrok / tunnel│
+ │
+ ┌──────▼───────┐
+ │ Skyvern Cloud│
+ └──────────────┘
+```
+
+1. **Launches Chrome** with CDP enabled on an internal port (`exposed_port + 1000`)
+2. **Starts a proxy server** on the exposed port (default `9222`) that forwards CDP traffic to Chrome
+3. **Optionally creates a tunnel** (`--tunnel`) so Skyvern Cloud can reach it from the internet
+
+## CLI options
+
+| Option | Default | Description |
+|---|---|---|
+| `--port` | `9222` | Port for the proxy server. Chrome uses `port + 1000` internally. |
+| `--profile-dir` | `~/.skyvern/chrome-profile` | Chrome user data directory. Point this at an existing profile to reuse cookies and logins. |
+| `--download-dir` | `~/.skyvern/downloads/{browser_id}` | Directory for browser downloads. |
+| `--api-key` | (none) | API key for authenticating incoming requests. |
+| `--headless` | `false` | Run Chrome in headless mode (no visible window). |
+| `--chrome-path` | (auto-detect) | Path to Chrome/Chromium executable. |
+| `--tunnel` | `false` | Automatically start an ngrok tunnel. |
+| `--json` | `false` | Output connection info as JSON (for scripting). |
+
+The `--api-key` option can also be set via the `SKYVERN_BROWSER_SERVE_API_KEY` environment variable.
+
+## Security
+
+> **Warning:** When you run `skyvern browser serve` without `--api-key` and expose it via a tunnel, anyone with the tunnel URL has full remote control of your Chrome browser — including access to all logged-in sessions, cookies, and saved passwords.
+
+Always use `--api-key` when exposing your browser:
+
+```bash
+skyvern browser serve --api-key "your-skyvern-api-key" --tunnel
+```
+
+Skyvern Cloud automatically sends the correct API key when connecting. For additional security (IP allowlisting, mTLS, VPN), contact **[email protected]**.
diff --git a/skyvern/cli/init_command.py b/skyvern/cli/init_command.py
index 0f66f3cb6..943bdbfbd 100644
--- a/skyvern/cli/init_command.py
+++ b/skyvern/cli/init_command.py
@@ -138,6 +138,14 @@ def init_env(
return False
update_or_add_env_var("SKYVERN_BASE_URL", base_url)
+ console.print(
+ "\n[bold yellow]Tip:[/bold yellow] Want Skyvern Cloud to use your local browser "
+ "(with your existing cookies, logins, and extensions)?"
+ )
+ console.print(" Run: [reverse green] skyvern browser serve --tunnel [/reverse green]")
+ console.print(" This starts Chrome on your machine and creates a tunnel so Skyvern Cloud can control it.")
+ console.print(" Learn more: [link]https://www.skyvern.com/docs/optimization/browser-tunneling[/link]")
+
analytics_id_input = Prompt.ask("Please enter your email for analytics (press enter to skip)", default="")
analytics_id = analytics_id_input if analytics_id_input else str(uuid.uuid4())
update_or_add_env_var("ANALYTICS_ID", analytics_id)