Skip to main content
Glama
1claw-inject

1claw-inject

by 1clawAI
README.md
# 1Claw Inject

Let an AI agent sign in to a website without ever holding the password.

The agent drives a real browser. When it needs to log in, it asks
[1Claw Browser Bridge](https://github.com/1clawAI/browser-bridge) to do it. The
bridge takes the password from your [1Claw](https://1claw.co) vault and types it
on a page the agent cannot see or script. The agent gets back
`{"status":"filled"}` and a signed-in browser. Nothing else.

```
  agent  ──────CDP──────▶  Browser Bridge  ──────▶  browser
  (script or Claude)             │   ▲                (the page)
                                 │   └── types the password here
                                 ▼
                            1Claw vault
                        (holds the password)
```

It comes in two forms:

- **A Claude Desktop extension** (an MCP server): Claude is the agent. It gets a
  "sign in" tool that returns a status, tools to open and read pages, and a
  "set up a site" tool that hands the typing of the password to you.
- **A terminal demo** (`npm run demo`): a Puppeteer script plays the agent. It
  shows a page refusing it, signs in through the bridge, shows the same page
  now open, then browses around and saves screenshots.

It works with any site whose login is a username and password on one page. No
sites ship with it: you add your own, as many as you like, by giving Claude a
login page address. Each gets its own password in your vault; they all share
one pairing of your machine.

> A [1Claw](https://1claw.co) project, built on `@1claw/browser-bridge` 0.2.0.

## Contents

- [What you need](#what-you-need)
- [Quick start](#quick-start)
- [Setup in detail](#setup-in-detail)
- [The terminal demo](#the-terminal-demo)
- [Claude Desktop](#claude-desktop)
- [Your sites](#your-sites)
- [Choosing the browser](#choosing-the-browser)
- [What is stored where](#what-is-stored-where)
- [How it works](#how-it-works)
- [Limits](#limits)
- [Troubleshooting](#troubleshooting)
- [Development](#development)
- [License](#license)

## What you need

- Node.js 20.10 or newer
- A Chromium-family browser (Chrome, Brave, Edge, Chromium, Vivaldi, Opera)
- A 1Claw account (a Human API key only for the older `--with-key` setup)
- An account on the site you want to sign in to
- macOS or Linux

## Quick start

**In Claude Desktop, with no terminal:**

1. Download
   [`1claw-inject.mcpb`](https://github.com/1clawAI/1claw-inject/releases/latest/download/1claw-inject.mcpb)
   and open it with Claude Desktop. There is nothing to fill in.
2. Ask Claude: *"Set up sign-in for https://example.com/login, my username is
   me@example.com."*
3. 1Claw's approval page opens in your browser. Check it shows the code Claude
   gave you, type the site's password there and approve. Claude does not see
   that page.
4. Ask Claude: *"Sign in to example and tell me what is on my account page."*

Repeat steps 2 and 3 for each site. After the first one, you can ask for
several at once and approve them in any order.

**In a terminal, from a clone:**

```bash
git clone https://github.com/1clawAI/1claw-inject.git && cd 1claw-inject
npm install
npm run add-site -- https://example.com/login   # work out the login form
npm run bootstrap     # set it up; you approve it on 1claw.co
npm run demo          # watch it sign in
```

**In a terminal, without cloning:**

```bash
npx github:1clawAI/1claw-inject setup https://example.com/login
npx github:1clawAI/1claw-inject demo --site example
```

All three write to the same place, so a site set up one way works in the others.

## Setup in detail

Setup is the same whether Claude Desktop starts it or you run
`npm run bootstrap`. It goes through 1Claw's own approval page:

1. The tool asks 1Claw for a setup request, naming the site, its login page and
   this machine. It gets back a short code and an approval link.
2. You open the link, signed in to 1Claw. The page shows the code, the device,
   the site and where the request came from. You type the site's password
   there and approve with one passkey or authenticator confirmation.
3. The tool collects a device credential and an agent key, once, and writes
   them to `~/.config/1claw-inject/setup.env`, readable only by you.

That one approval stores the password in your vault, creates the browser
binding (this secret may be typed into these hosts), pairs this machine as a
bridge device, and gives a new agent read access to that one secret. A second
site reuses the device and the agent. On a machine first set up with an API
key, the pairing is kept but the first approval creates a new agent, because
the old one cannot read from the vault approvals store into.

No Human API key is involved in setup, and the site password never passes
through this project: you type it on `1claw.co`. Running setup again for a site
stores a new password. A request expires after 15 minutes.

**Always check the code.** The approval page is the only thing standing between
a request and your vault. Approve only a request you started, showing the code
you were given.

If you set up with version 1.0.0, which wrote to the project's `.env`,
`npm run bootstrap` moves that file's setup across before doing anything else.

### Setting up with an API key instead

`npm run bootstrap -- --with-key` is the older way, done entirely from the
terminal. It asks for:

| Input | Env var (optional) | Used for |
| --- | --- | --- |
| 1Claw Human API key | `ONECLAW_API_KEY` | creating everything below |
| Site username or email | `<SITE>_EMAIL`, e.g. `EXAMPLE_EMAIL` | typed by the bridge at login |
| Site password | `<SITE>_PASSWORD` | stored in the vault |

Secrets are prompted for with hidden input. You can instead put them in `.env`
(see `.env.example`) or the environment. They are never accepted as
command-line arguments, which would expose them in `ps` and shell history.

It then:

1. finds or creates a vault called `browser-use-demo`
2. stores the site password at `<site>/password`
3. creates an agent, which may ask for a fill but can never collect a password
4. grants that agent read access to that one secret path
5. pairs this machine as a bridge device
6. creates a browser binding: this secret may be typed into these hosts

Finished steps are skipped on a re-run. Use this way if your organisation
requires approvals for creating policies, which the approval page cannot yet
complete.

### The step-up confirmation (with `--with-key`)

Steps 5 and 6 need more than the API key: 1Claw requires you to confirm them.
Setup picks the method your account needs.

- **Passkey** (detected automatically). On macOS a 1Claw tab opens in your own
  Chrome and you approve the passkey prompt, once per step. This needs a
  one-time Chrome setting, which the script asks for:
  *View > Developer > Allow JavaScript from Apple Events*. Bring the Chrome
  profile that holds the passkey to the front first, and switch the setting off
  again afterwards.
  - `--passkey-window` uses a separate blank-profile Chrome window instead.
    That suits a passkey in iCloud Keychain or on a security key.
  - `--passkey-manual` prints one line to paste into the browser console on
    `1claw.co`, and you paste the result back.
- **Authenticator app**: run `npm run bootstrap -- --totp`.
- **Password only**: you are asked for your 1Claw account password.

Once a passkey or authenticator app is enrolled, 1Claw refuses the account
password for these steps. Do not retry a wrong password repeatedly: failed
attempts count toward an account lockout.

## The terminal demo

```bash
npm run demo                      # visible browser, stays open until you press Enter
npm run demo -- --site <name>     # needed when you have more than one site
npm run demo:headless             # no window
npm run demo -- --close           # close the browser as soon as it finishes
npm run demo -- --save-cookies    # also save the session cookies (see below)
```

What it does:

1. **Signed out.** The agent asks for a page the site only serves to a
   signed-in user, and is refused.
2. **Sign in.** The agent opens the login page and calls `request_fill`. The
   demo prints the full reply, which is everything the agent learns.
3. **Signed in.** The agent asks for the same page again, in the same tab, and
   now gets it. The demo reports the HTTP status, whether the page shows the
   account's username, and whether a logout link is present.
4. **Browse.** It visits the pages in the site profile's `tour`, scrolling each.
   It only views pages; nothing is submitted.

Each run saves full-page screenshots of the agent's tab to
`screenshots/<site>/<date_time>/`. There is no picture of the password being
typed: that happens on a page the agent cannot see.

### Showing it signed in

```bash
npm run demo -- --save-cookies    # writes cookies/<site>.json, owner-only
npm run show                      # opens a normal browser window, already signed in
```

The cookie file is in the format cookie-editor browser extensions import.
**Treat it like a password.** Whoever has it is signed in as you until the
session expires or you log out. Delete it when you are done.

## Claude Desktop

The MCP server gives Claude six tools:

| Tool | What Claude supplies | What Claude gets back |
| --- | --- | --- |
| `inject_sites` | nothing | the sites that are set up, and any setup in progress |
| `inject_setup` | a login page URL or the name of an existing profile, and optionally your username | a status, a short code and the link to 1Claw's approval page |
| `inject_remove` | a site name | confirmation that the site is forgotten on this machine |
| `inject_login` | a site name | whether the browser is now signed in |
| `inject_open` | a URL on a set-up site | the page's title, text and links |
| `inject_screenshot` | nothing | a picture of the current page |

Claude cannot choose the account or the password, cannot open sites that are
not set up, and has no tool that returns cookies or runs script. The browser
window opens on the first tool call.

### Setting up a site from Claude

Ask Claude to set up a site and give it the login page. `inject_setup` builds
the site profile from that page if there is none, asks 1Claw for a setup
request, opens 1Claw's approval page in your own browser and returns straight
away with a short code. On that page you:

1. sign in to 1Claw if you are not already,
2. check the code matches the one Claude told you, and that the site and login
   address are the ones you meant,
3. type the site's password (and username, if Claude did not pass it),
4. approve with your passkey or authenticator app.

Then tell Claude you are done. Running it again for the same site stores a new
password.

What you type goes to 1Claw and nowhere else: not to this extension, and not to
Claude. Claude does choose the login address it passes in, which is why the
approval page shows it for you to check. Only `https` pages are accepted, and
nothing is stored or bound until you approve.

### Installing

**As an extension (recommended).**

Download
[`1claw-inject.mcpb`](https://github.com/1clawAI/1claw-inject/releases/latest/download/1claw-inject.mcpb)
from the [latest release](https://github.com/1clawAI/1claw-inject/releases/latest),
or build it yourself:

```bash
npm run pack          # builds 1claw-inject.mcpb
```

Open `1claw-inject.mcpb` with Claude Desktop. It asks for nothing: it finds
the setup file and any site profiles you added by itself, and uses the first
Chromium-family browser installed.

**By hand.** Add this to Claude Desktop's `claude_desktop_config.json` (Settings
> Developer > Edit Config):

```json
{
  "mcpServers": {
    "1claw-inject": {
      "command": "npx",
      "args": ["-y", "github:1clawAI/1claw-inject", "mcp"]
    }
  }
}
```

From a clone, use `"command": "node"` and
`"args": ["/absolute/path/to/1claw-inject/src/mcp-server.mjs"]` instead. Restart Claude
Desktop, then ask it something like *"Sign in to example and tell me what is
on my home page."*

Server settings, all optional environment variables:

| Variable | Meaning |
| --- | --- |
| `DEMO_ENV_FILE` | path to the setup file, if not `~/.config/1claw-inject/setup.env` |
| `DEMO_SITES_DIR` | folder of site profiles, if not `~/.config/1claw-inject/sites/` |
| `DEMO_BROWSER` | browser name, as in `--browser`, if not the first one installed |
| `INJECT_HOME` | folder for the setup file and added site profiles, if not `~/.config/1claw-inject` |
| `DEMO_HEADLESS=1` | no visible window |
| `DEMO_TRACE_DIR` | a folder to debug a failed sign-in: each step of the fill is logged and the bridge's pictures of the login page are saved there. They never show the password being typed, but may show your username, so keep the folder private |

### Packaging it for other people

The bundle contains code and site profiles only. `.mcpbignore` keeps `.env`,
cookies and screenshots out, and `npm run pack` output can be checked with
`unzip -l 1claw-inject.mcpb`. Each person needs their own 1Claw account and
sets up their own sites from Claude as described above: pairing a device and
creating a binding need their own approval.

The package also has a command-line entry point, `1claw-inject`
(`setup`, `add-site`, `demo`, `show`, `mcp`), which is what the `npx` lines in
this README run.

## Your sites

Each site is a small profile (where its login form is) plus an entry in the
setup file (which 1Claw binding and username go with it). You can have as many
as you like.

**From Claude Desktop**, just ask:

- *"Set up sign-in for https://example.com/login"* adds a site. Its name comes
  from the address (`example`); say *"call it work-mail"* to choose one.
- *"What sites are set up?"* lists them with their usernames.
- *"Set up example again"* stores a new password or username for it.
- *"Remove example"* forgets it on this machine.

Two accounts on the same site are two sites with different names, such as
`shop-personal` and `shop-work`. They share the browser's cookies for that
site, so signing in to one while the other is signed in may not switch
accounts.

Removing a site deletes its profile and its entry in the setup file. The
password and the binding stay in 1Claw until you delete them in your 1Claw
dashboard; this project holds no credential that could delete them for you.

**From a terminal:**

```bash
npm run add-site -- https://example.com/login
```

This opens the login page (nothing is typed or submitted), finds the username
field, password field and submit button, and writes
`~/.config/1claw-inject/sites/<name>.json`. It loads the page twice and ignores
any id or name that changed, so sites that randomise their field names still
work. Profiles there are picked up by the demo and the Claude Desktop extension
alike.

Then:

```bash
npm run bootstrap -- --site <name>
npm run demo -- --site <name>
```

With only one site, `--site` can be left out.

### Which sites work

- **Works:** a login page with the username and password on the same page,
  served over `https`.
- **Does not work yet:** sites that ask for the username first and the password
  on a second page, login forms inside an embedded frame, and logins that need
  a CAPTCHA or a second factor. Setup tells you when it meets one of the first
  two.
- **"Sign in with Google" and similar** are not password logins and are not
  handled.

### Tuning a profile

A generated profile is usually enough. Two optional fields cannot be discovered
without an account and make the signed-in check much stronger:

```json
{
  "name": "example",
  "loginUrl": "https://example.com/login",
  "allowedHosts": ["example.com", "www.example.com"],
  "usernameSelector": "#login-form input[name=\"email\"]",
  "passwordSelector": "#login-form #password",
  "submitSelector": "#login-form button[type=\"submit\"]",
  "signedInUrl": "https://example.com/account",
  "profileLinkSelector": "a.my-profile",
  "tour": [["inbox", "/messages"], ["settings", "/account/settings"]]
}
```

| Field | Required | Meaning |
| --- | --- | --- |
| `loginUrl` | yes | the page with the login form; must be `https` |
| `allowedHosts` | yes | bare hostnames the password may be typed into |
| `passwordSelector` | yes | CSS selector for the password field |
| `usernameSelector` | no | the username field; omit if the site remembers it |
| `submitSelector` | no | the submit button; omit to press Enter |
| `signedInUrl` | no | a page served only to a signed-in user. Without it the demo falls back to weaker signs (login form gone, logout link present) |
| `profileLinkSelector` | no | a link to the user's own profile once signed in |
| `tour` | no | `[label, path]` pages to browse after signing in. Use view-only pages |

Site profiles hold no secrets and are safe to share.

## Choosing the browser

```bash
npm run demo -- --list-browsers     # what is installed here
npm run demo -- --browser brave     # chrome, chrome-canary, chrome-beta, chromium, brave, edge, vivaldi, opera
npm run demo -- --chrome /path/to/any/chromium-based/binary
```

`npm run show` and `npm run add-site` take the same options. Firefox and Safari
cannot be used: the bridge starts the browser and talks to it over Chromium's
debugging pipe, which they do not have.

## What is stored where

| What | Where | Committed? |
| --- | --- | --- |
| Site password | 1Claw vault only | no |
| 1Claw account password, passkey | never stored | no |
| Human API key | not used, except by `--with-key` setup: then wherever you put it (the prompt, your environment or `.env`) | no |
| Device credential (`bb_`), agent key (`ocv_`), ids, site username | `~/.config/1claw-inject/setup.env`, owner-only | no (outside the project) |
| Session cookies | `cookies/<site>.json`, only with `--save-cookies` | no (git-ignored) |
| Screenshots of signed-in pages | `screenshots/` | no (git-ignored) |
| Site profiles (URLs and selectors) | `~/.config/1claw-inject/sites/*.json` | no (outside the project) |

`.gitignore`, `.mcpbignore` and `.claudeignore` all list the same private
files, and `.claude/settings.json` stops Claude Code from reading them.

## How it works

- **The bridge owns the browser.** It launches the browser over a pipe, with no
  debugging port, and is the only process attached to it. The agent connects to
  the bridge as if it were the browser, and every command it sends crosses an
  allowlist.
- **A fill happens somewhere the agent is not.** The bridge opens a new page in
  the agent's browser context, navigates to the binding's own login URL, types
  the username and password, submits, and closes the page. The session cookie
  belongs to the browser context, so the agent's own tab is now signed in.
- **Two credentials, two roles.** The device credential says which machine and
  the agent token says which agent. The agent may ask *whether* a fill is
  allowed; only the paired device, inside the bridge, may collect the secret.
  You granted both when you approved setup.
- **One addition of this project.** The hosted binding stores which secret and
  which hosts, but not the username or form selectors. `src/session.mjs` wraps
  the hosted driver and adds those from the site profile to each grant. The
  vault still decides whether a fill happens.

Source map:

| File | Role |
| --- | --- |
| `bin/cli.mjs` | the `1claw-inject` command |
| `scripts/bootstrap.mjs` | setup for a site, from a terminal |
| `scripts/add-site.mjs` | builds a site profile from a login page, from a terminal |
| `scripts/show-logged-in.mjs` | opens a browser signed in from saved cookies |
| `src/demo.mjs` | the terminal demo |
| `src/mcp-server.mjs` | the Claude Desktop / MCP server |
| `src/session.mjs` | bridge + browser + agent tab, shared by both |
| `src/setup.mjs` | the key-based setup steps behind `--with-key` |
| `src/hosted-setup.mjs` | setup through 1Claw's approval page |
| `src/profile.mjs` | works out a login form's selectors |
| `src/passkey.mjs` | passkey confirmation during key-based setup |
| `src/browsers.mjs` | which browser to drive |
| `src/lib.mjs` | site profiles, `.env`, prompts, API client |
| `manifest.json` | Claude Desktop extension manifest |
| `test/selftest.mjs` | offline end-to-end test |

## Limits

- **Single-page logins only.** Username and password must be on the same page.
  Sites that ask for the username first and the password on a second page are
  not supported by the bridge's fill.
- **No CAPTCHA, no two-factor.** If the site adds either at login, the fill
  will type and submit but the site will not sign in.
- **"Filled" is not "signed in".** The bridge reports `filled` once it has
  typed and submitted, even if the site rejects the login. The demo and the
  `inject_login` tool both check the result themselves.
- **The agent can read what a signed-in user can read.** Keeping the password
  from the agent does not limit what it does with the session. Page text
  returned to Claude is website content and may contain text written by others.
- **Setup trusts what you check.** Claude passes the login address to
  `inject_setup`. If it were misled into passing a look-alike address, the
  approval page would show that address, and a password you typed would be
  bound to it. Likewise, anyone can ask 1Claw for a setup request, so approve
  only one showing the code you were just given.
- **Organisations that require approvals for new policies.** The approval page
  cannot finish setup there; it stays waiting for sign-off. Use `--with-key`.
- **A device credential opens sessions by itself.** Filling a password still
  needs the agent's key and its read access. If a machine is lost, revoke its
  device in 1Claw.
- **One browser for every site.** All your sites are signed in to in the same
  browser window, and Claude can open pages on any of them once they are set
  up. Set up only sites you are content for Claude to browse as you.
- **Unverified combinations.** Only Google Chrome on macOS has been run end to
  end. Other Chromium browsers and Linux should work but have not been tried.

## Troubleshooting

| Symptom | Likely cause and fix |
| --- | --- |
| Claude says no site is set up | Ask it to set one up, or run `npm run bootstrap`. If you set up with version 1.0.0, the setup is still in the project's `.env`: run `npm run bootstrap` once to move it. |
| The approval page did not open | Claude's reply, or the terminal, shows the link; open it. A request expires after 15 minutes: start setup again. |
| Setup says the request was denied or expired | Nothing was set up. Start again and approve the request showing your code. |
| `... is missing from .../setup.env. Run: npm run bootstrap` | Setup has not been run, or not finished. Run it; finished steps are skipped. |
| `Site "x" has not been set up` | Run `npm run bootstrap -- --site x`, or ask Claude to set it up. |
| `--with-key`: `requires re-authentication` (403) | The confirmation was refused. With a passkey or authenticator app enrolled, the account password is not accepted. Re-run and use the passkey flow, or `--totp`. |
| Passkey prompt never appears | The Chrome profile holding the passkey is not the front window, or *Allow JavaScript from Apple Events* is off. Try `--passkey-manual`. |
| Demo: `browser bridge vault call failed (4xx)` | 1Claw rejected the request. The message names the reason. A 403 on a fill usually means the page's host is not in the binding's `allowedHosts`. |
| `request_fill -> {"status":"aborted"}` | The login page navigated between the request and the typing. Run it again. |
| Fill reports `filled` but `signed in: no` | Wrong stored username or password (run setup again for that site), or the site wants a CAPTCHA or second factor. Run once with `DEMO_TRACE_DIR=/some/folder` and look at the `settle` picture to see what the site answered. |
| Fill reports `error` | A selector in the site profile did not match. Check them against the live page, or regenerate with `npm run add-site -- <url> --force`. |
| Claude Desktop shows no tools | Check the path in the config, that `npm install` was run, and Claude Desktop's MCP log for the server's error output. |

## Development

```bash
npm test
```

runs the offline self-test: the real bootstrap, demo, cookie export, `add-site`,
MCP server, hosted setup and command-line entry point against a local stand-in for the 1Claw API and a local copy of a
login form, in a real headless browser. It needs no account and touches neither
real service. It proves the wiring, not that the real API or a real site agree
with the stand-ins.

## License

[Apache-2.0](LICENSE).