---
title: "Attach"
description: "Read open tabs in your own logged-in browser"
canonical_url: "https://browsers.agntn.dev/providers/attach"
---
# Attach

> Read open tabs in your own logged-in browser

<provider-facts name="attach">



</provider-facts>

Want your agent to read a borrowed archive.org book? Or an SSO dashboard? `attach` reads the tabs in your own browser. Your logins stay where they are. No new browser and no key.

Choose it with `-p attach` or `provider: "attach"`. A call without a provider never lands here. That's a good boundary. This browser belongs to you.

## Start the browser

Chrome and Chromium use CDP through `playwright-core`. Start the browser with `--remote-debugging-port=9222`. Since Chrome 136, that switch is ignored on the default profile. Chrome wants a separate `--user-data-dir`. Log in once inside that profile.

Firefox and its forks use WebDriver BiDi. Start Firefox with `--remote-debugging-port 9222`. Firefox has no such profile restriction. Neither protocol needs a separate client installed. BiDi uses Node's own WebSocket.

Which one does it pick? On an `http://` address, Chromium advertises its socket at `/json/version`. Firefox returns 404, so `attach` uses `ws://host:port/session`. A `ws://` path of `/session` selects BiDi. Other `ws://` paths select CDP.

## Connect and pick a tab

The default address is `http://127.0.0.1:9222`. Set `ATTACH_URL` to override it. In the library, use `create("attach", { baseURL })`.

Only loopback hosts are allowed: `localhost`, any `127.x.x.x` address, or `[::1]`. Other hosts raise `InvalidInputError` before connecting. Your debugging port doesn't get a free trip elsewhere.

Which tab? The URL names one. It doesn't load a page. First, `attach` looks for an exact address, ignoring the fragment. Otherwise, it picks the first tab under that address. `/book` matches `/book/page/3`, not `/bookshelf`.

No match? `InvalidInputError` lists open tabs, up to twenty. If there are more, it adds "and N more". The agent can pick from what's actually open.

```text
$ browsers scrape https://example.com/borrowed -p attach
No open tab at https://example.com/borrowed. attach reads tabs you opened and never loads a page itself. Open tabs: https://example.com/.
```

## Read without taking over

Scrape returns the current title, HTML, text and links. Its result URL includes the tab's fragment. There's no status code. Nothing was loaded. `waitFor` works, and `links` works without a session.

Screenshots support PNG and JPEG, not WebP. `selector` captures an element cut from the viewport. Full page and `waitFor` work too.

A screenshot brings its tab to the front. Chrome only paints the visible tab. A background tab that had just scrolled took up to 20 seconds to give a frame. That's the visible interruption. No mouse grabbing.

`navigate()` throws `UnsupportedOperationError`. Attach never navigates or closes a tab or browser. Releasing a session only disconnects.

## Sessions

`createSession()` connects to the browser. The first scrape or screenshot with a URL picks a tab. The session keeps it for `evaluate(script, session)`. Evaluate before that pick fails with "This attach session has no tab yet".

Firefox allows one BiDi session at a time. Calls without a session open and end one, even on failure. A held session takes the slot. Other calls fail until you release it. The CLI releases attach sessions before exiting.

There's no crawl, PDF, search, extract or accessibility tree. Sessions expose no CDP URL either.


## Sitemap

See the full [sitemap](https://browsers.agntn.dev/sitemap.md) for all pages.
