# Use tunnl.gg from AI coding agents

> AI coding agents such as Claude Code, Cursor and Codex can run shell commands, and tunnl.gg is a single SSH command, so there's nothing to install and no MCP server to set up. Add `output=json` and the agent gets the URL and every incoming request as JSON lines it can read reliably: handy for testing webhooks, OAuth callbacks or a mobile build end to end.

## 1. Start the tunnel in the background

```bash
ssh -n -T -o ServerAliveInterval=30 -R 80:localhost:3000 stable@proxy.tunnl.gg output=json > tunnel.jsonl 2>&1 &
```

- `-n -T`: no input and no terminal, so it runs in the background without stopping
- `stable@`: the same URL every time for this machine's SSH key, so a webhook registered once keeps working
- `output=json`: one JSON object per line instead of the banner, QR code and request table

## 2. Read the URL

The first line describes the tunnel. Wait for it, then take the URL:

```bash
until grep -q '"event":"tunnel"' tunnel.jsonl 2>/dev/null; do sleep 1; done
head -1 tunnel.jsonl | jq -r .url
```

Without `jq`:

```bash
sed -n 's/.*"url":"\([^"]*\)".*/\1/p' tunnel.jsonl | head -1
```

The line looks like this:

```json
{"event":"tunnel","url":"https://brave-fox-7c41e09b.tunnl.gg","subdomain":"brave-fox-7c41e09b","stable":true,"idle_timeout_seconds":7200,"max_lifetime_seconds":86400}
```

## 3. Watch requests

Every request through the tunnel adds a line, so the agent can check that a webhook arrived and what the app answered:

```bash
grep '"event":"request"' tunnel.jsonl | tail -5
```

```json
{"event":"request","time":"2026-10-09T08:14:03Z","method":"POST","path":"/webhooks/stripe","status":200,"bytes":2,"duration_ms":41,"visitor":"54.187.174.169"}
```

A failed request carries a `detail` saying why, like your app not answering. `from_tunnl: true` marks requests tunnl answered itself, such as rate limits. Lines with `"event":"notice"` are messages from tunnl, like a warning before a time limit and a summary when tunnl closes the tunnel.

## 4. Stop it

```bash
kill %1    # or: pkill -f 'stable@proxy.tunnl.gg'
```

## Tell your agent how

Paste this into your project's `AGENTS.md` or `CLAUDE.md`, so the agent uses tunnl.gg whenever it needs a public URL:

````markdown
## Public URLs for local servers

To give a local server a public HTTPS URL (webhooks, OAuth callbacks, testing on a phone),
use tunnl.gg. Nothing to install: it's one SSH command.

1. Start it in the background, with the app's port:
   `ssh -n -T -o ServerAliveInterval=30 -R 80:localhost:PORT stable@proxy.tunnl.gg output=json > /tmp/tunnl.jsonl 2>&1 &`
2. Wait for the URL: `until grep -q '"event":"tunnel"' /tmp/tunnl.jsonl; do sleep 1; done; head -1 /tmp/tunnl.jsonl`
   The `url` field is the public URL. It stays the same on every run.
3. Each request adds a line with `"event":"request"` (method, path, status, duration_ms).
4. Stop it with `pkill -f 'stable@proxy.tunnl.gg'` when done.

Docs: https://tunnl.gg/guides/ai-coding-agents.md
````

## Inspect and replay requests over MCP

`output=json` shows each request's method, path and status. To read full headers and bodies, or replay a request after fixing a handler, connect the agent to the [request inspector](/request-inspector#use-it-from-claude-and-other-ai-assistants-mcp)'s MCP server at `https://app.tunnl.gg/mcp`. In Claude Code:

```bash
claude mcp add --transport http tunnl https://app.tunnl.gg/mcp
```

Then run `/mcp` to sign in. It works with tunnels connected to your free account as `pro@proxy.tunnl.gg`.

## Things to know

- **Same URL every run.** With `stable@`, the URL comes from the SSH key, so the agent can register it with Stripe, GitHub or an OAuth provider once. Without `stable@`, every run gets a new random URL.
- **One tunnel per key.** Starting a second `stable@` tunnel with the same key replaces the first. For two apps at once, use a second key: see [Stable URLs](/stable-urls).
- **The warning page is for browsers only.** Webhooks, `curl` and other non-browser clients reach your app directly. If the agent tests with a headless browser, send the `tunnl-skip-browser-warning` header: see the [docs](/docs#the-browser-warning-page).
- **Time limits.** Free tunnels close after 2 hours without traffic or 24 hours at most; the `tunnel` line says so in seconds. Run it again for the same URL, or [keep it running](/guides/keep-a-tunnel-running). [Pro](/pro) tunnels have no time limits.
- **Daily transfer.** Free tunnels may transfer 5 GB a day per IP (10 GB on Pro). Past that, requests get HTTP 429 until 00:00 UTC, and a `notice` line says so.
- **It's public.** Anyone with the URL can reach the app while the tunnel is open. Verify webhook signatures, and don't tunnel anything with real data.
- **Stable URLs need a registered key.** The machine's SSH key must be [registered to a free account](/stable-urls#register-your-key): run `ssh -t link@proxy.tunnl.gg` once yourself and open the link it prints. No SSH key on the machine? Run `ssh-keygen -t ed25519` first. Or drop `stable@` for a random URL, which needs no account.

The full list of JSON fields is in the [README on GitHub](https://github.com/klipitkas/tunnl.gg#json-output-for-scripts-and-agents).

## Related

- [Test webhooks locally](/guides/test-webhooks-locally)
- [Keep a tunnel running](/guides/keep-a-tunnel-running)
- [Stable URLs](/stable-urls)
- [tunnl.gg documentation](/docs)
- [ngrok alternatives compared](/compare)
