When you need a tunnel
A browser reaches only what its own machine reaches. On the desktop, the
browsers run on your machine, so they reach a dev server on
localhost:3000 directly. On hosted, the browsers run on our
hardware, where localhost means the fleet. A tunnel holds a port
on your machine open to the fleet's browsers.
| Where the browser runs | Where your dev server runs | Tunnel |
|---|---|---|
| Your machine (desktop app) | Your machine | Not needed |
| The hosted fleet | Your laptop | vitro-tunnel tunnel |
| The hosted fleet | A CI runner or sandbox | vitro-tunnel tunnel, unless the platform already publishes the port |
| The hosted fleet | A public URL | Not needed |
An assistant checks its own work
The common case: an AI assistant has changed your app and needs to see the
result in a real browser. With a tunnel open, the assistant's prompt and your
code stay the same. When the agent calls navigate with
http://localhost:3000, it gets your machine's port 3000. Only
navigate is translated this way.
new_page(url:) with a localhost URL does not reach the tunnel
today, so open the page on about:blank and then navigate.
Start your dev server as usual in one terminal. In another:
vitro-tunnel login
vitro-tunnel tunnel 3000
With no port, tunnel finds the dev server already running in the
current directory. One fleet machine serves many teams, so the fleet
allocates the port the tunnel answers on, and tunnel prints it
when it connects:
localhost:41007 in the fleet → 127.0.0.1:3000 here
holding; interrupt to close
The number varies. When it differs from the one you named, a
note: line between the two names the URL that reaches it.
navigate translates the port you named to the allocated one, so
the agent keeps using http://localhost:3000 and works as it
would against any site:
create_session(client_key: "my-assistant")
new_page(session_id, lease)
navigate(session_id, lease, page_id, url: "http://localhost:3000")
find(session_id, lease, page_id, role: "button", name: "Save")
click(session_id, lease, page_id, snapshot_id, uid)
get_errors(session_id, lease)
The session timeline shows each request that crossed the tunnel with its
status, such as GET /api/users 500, next to the click that caused
it. The assistant reads the failure with get_errors or
list_network_requests, fixes the code, reloads, and checks again.
You can watch the session on the wall. To show you what it saw, the assistant
can write the image to your disk:
vitro-tunnel screenshot --page "$PAGE" -o broken.png
Install and sign in
curl -fsSL https://vitro.run/tunnel/install.sh | sh
vitro-tunnel login
vitro-tunnel tunnel
vitro-tunnel is one static binary for Linux and macOS on amd64 and arm64. The install script is plain text, so you can read it first.
login opens a browser and runs the same OAuth flow as
claude mcp add. It saves the grant in
~/.vitro/config.json and refreshes it, so a tunnel can outlive one
access token. On a machine with no browser, such as a sandbox, login
detects that and shows a code to approve on your laptop or phone. To ask for
the code directly, run vitro-tunnel login --device.
In CI, where nobody can approve anything, use an API key. Pass it as a file or
on stdin so it never appears in ps or shell history:
vitro-tunnel --key-file /run/secrets/vitro tunnel
vitro-tunnel --key @/run/secrets/vitro tunnel
vitro-tunnel --key - tunnel < /run/secrets/vitro
Running a tunnel
vitro-tunnel tunnel # find the dev server, hold it open
vitro-tunnel tunnel 3000 # name the port yourself
vitro-tunnel tunnel --to 8080 3000 # serve it from a different local port
vitro-tunnel tunnel --once 3000 # do not reconnect, exit when it drops
By default a tunnel reconnects when the connection drops. It relays TCP, so
websockets, HTTP/2 and server-sent events work, including a dev server that
pushes hot reloads over a websocket. vitro reads only the first line of each
direction, which is how the timeline shows a method, a path and a status. An
HTTPS dev server is recorded as tls: true.
If your platform already publishes the port, tunnel says so, and
you can skip the tunnel.
On the desktop
The desktop app has its own command, vitro tunnel (no hyphen, no
sign-in). It holds a named port open and journals each connection, and
--to serves the port from a different local one. Desktop browsers
already reach your localhost, so you need it only when the app
expects one port and the dev server runs on another, or to put each
dev-server connection on the session's timeline. Both ends share one machine,
so pass --to whenever the dev server already holds the
named port.
vitro tunnel 3000 --to 8080 # localhost:3000 in the browser reaches port 8080
vitro tunnel 3000 # hold it open until you stop it
vitro tunnel 3000 --service # keep it across restarts
vitro tunnel 3000 --service --print # show the unit file, install nothing
vitro tunnel list
vitro tunnel stop 3000
--service installs a launchd agent on macOS or a systemd user unit
on Linux, so the tunnel outlives the terminal and reconnects when vitro
restarts. The token is never written into the unit file. Service tunnels are
easy to forget, so vitro status and vitro tunnel list
both report the live ones.
What the tunnel exposes
- One named port per tunnel, dialed on
127.0.0.1, never on0.0.0.0. - No SOCKS mode.
- Every crossing is journaled, and panes that show a tunneled origin are marked, since an agent looking at your laptop is a different fact from an agent looking at the internet.
Only navigate to localhost reaches the tunnel;
new_page(url:) does not today, so open about:blank
and then navigate. Stop the command and the port closes. See
security for the rest.
Other jobs
vitro-tunnel also routes MCP for a client that cannot reach the fleet on its
own. You need neither command below if your client can reach
https://vitro.run/mcp directly. Many agent platforms exempt
remote MCP from their network policy, so check that first.
vitro-tunnel mcp # bridge stdio MCP to the fleet
vitro-tunnel serve --port 43218 # expose /mcp on loopback, key attached
mcp is for stdio-only clients. serve is for HTTP
clients that cannot hold the credential. On a machine shared with
other users, add --require-token and register the URL it prints,
including the ?token= part. Without it, any local account can
drive your fleet through the port.
Two commands move bytes onto your disk, which MCP cannot do:
vitro-tunnel screenshot --page "$PAGE" -o broken.png
vitro-tunnel fetch -o shot.png vitro://artifact/9f2c
fetch takes the resource_uri from a screenshot tool
result. Both need a session. Run vitro-tunnel use SESSION_ID LEASE
once so you stop passing it, or vitro-tunnel forget to clear it.
Any tool can also be called as JSON, to reproduce an agent's call from a shell:
vitro-tunnel call --scoped get_errors.
In CI and sandboxes
vitro.run/sandbox.json lists the hosts that must be
reachable, as data, so you can check before installing anything. Only outbound
connections are needed. From inside the box,
vitro-tunnel doctor --json reports what the binary can reach and
exits non-zero when it cannot reach the fleet, so it works as a gate in a
script. A key never contacts the sign-in host, so using one shrinks the
allowlist to one entry.
Pin the version for scripts that run unattended:
V=1.2.3
curl -fsSL "https://vitro.run/tunnel/linux-amd64?version=$V" -o vitro-tunnel
curl -fsSL "https://vitro.run/tunnel/linux-amd64/sha256?version=$V" \
| sed 's| .*| vitro-tunnel|' | shasum -a 256 -c -
chmod +x vitro-tunnel
Settings
| Variable | What it does |
|---|---|
VITRO_URL | Which deployment to use. Defaults to https://vitro.run. |
VITRO_KEY | An API key. Prefer the file forms above. |
VITRO_KEY_FILE | A file with mode 0600 that holds the key. |
VITRO_HOME | Where login saves things. Defaults to ~/.vitro. |
VITRO_PIN | A sha256/... pin for the server's public key. vitro-tunnel pin prints it. |
SSL_CERT_FILE | A private CA, for sandboxes that terminate TLS themselves. |
HTTPS_PROXY | Honored, as are HTTP_PROXY, NO_PROXY and ALL_PROXY, including socks5://. |
Flags win over environment variables. A saved sign-in is only presented to the
deployment it was saved for, so if VITRO_URL points elsewhere,
pass a key or run login against that deployment.
When it does not connect
- Run
vitro-tunnel doctor --json. - Check that the required host in sandbox.json is allowed.
- If
loginhangs, the machine has no browser. Uselogin --device. - If MCP works and the tunnel does not, the platform exempts remote MCP but not the tunnel. Add the host to the allowlist.
The vitro-tunnel page has the same material in reference form, and troubleshooting covers other common problems.