browsme-mcp
by halilugur
README.md
<p align="center">
<img src="./extension/public/icons/icon.svg" alt="Browsme logo" width="84" height="84" />
</p>
<h1 align="center">Browsme</h1>
<p align="center">
Local-first Chrome MV3 browser automation extension, Native Messaging bridge, CLI, and MCP server — zero cloud dependencies.
</p>
<p align="center">
<a href="https://github.com/halilugur/browsme/actions/workflows/ci.yml"><img src="https://github.com/halilugur/browsme/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
<a href="./LICENSE"><img src="https://img.shields.io/badge/License-Apache--2.0-00D8E8.svg" alt="License: Apache-2.0" /></a>
<img src="https://img.shields.io/badge/Chrome-MV3%20(116%2B)-171614.svg" alt="Chrome MV3 116+" />
<img src="https://img.shields.io/badge/TypeScript-5.7-171614.svg" alt="TypeScript 5.7" />
<img src="https://img.shields.io/badge/Tools-32-171614.svg" alt="32 Tools" />
</p>
---
Browsme gives AI agents, MCP clients, CLI scripts, and human operators full local control over Chromium browsers through Chrome DevTools Protocol (CDP), Accessibility Tree inspection, DOM automation, workflow recording, scheduled shortcuts, and animated GIF capture — all running strictly on your machine.
## Key Features
- **Native-Host-First Architecture:** Chrome spawns `com.browsme.host` over `stdio`, and the Native Host embeds the local HTTP/CLI/MCP bridge at `http://127.0.0.1:9229` automatically — no separate background daemon required.
- **Optional WebSocket & Hybrid Modes:** Switch between **Native Host** (default), **WebSocket** (for remote/Docker/VM setups), or **Both** directly in Options.
- **38 Local Automation Tools:** Full mouse/keyboard input (including Unicode & macOS text editing chords), HTML5 drag-and-drop, CSS-selector / ref / coordinate targeting, set-of-marks screenshots, multi-step batching, cross-frame accessibility refs (heuristic DOM tree or Chrome's real accessibility tree), semantic element search (any script, incl. Turkish), JS execution with top-level `await` in any frame (incl. cross-origin iframes, CSP-safe), console/network diagnostics, clipboard, browser storage/cookies/downloads (with completion waiting), PDF export, and GIF recording.
- **Agents stay out of your tabs:** every agent session (each MCP client window, the CLI, a named script) is bound to its own tab group named after it — e.g. `Claude Code · 3fa2` — and can only see and target tabs inside that group (the Claude in Chrome model). Share a tab with an agent by dragging it into its group; drag it out to revoke. The group title shows ⌛ working / 🔔 needs approval / ✅ done. (Options → *Agents work only in their own tabs* turns confinement off.)
- **Take over at any time:** "Take over" in the page banner or Side Panel pauses the agent (its calls wait, then get a `paused` error) while you use the page; "Resume" hands control back. Stop aborts immediately.
- **Localized UI:** Side Panel, Options, page overlays and notifications follow the browser language (English / Türkçe).
- **Safety & Permission Guardrails:** Supports `autonomous`, `confirm_sensitive`, and `ask_per_domain` approval modes with visual crosshair target previews, wildcard allow/block URL patterns, and sensitive parameter redaction in network logs.
- **Live Indicators & Auto Tab Grouping:** Highlights automated tabs with an in-page focus border, a status banner naming the current action (with a Stop button), a phantom cursor, a `RUN` badge on the toolbar icon (visible even when the agent works in a background tab), a live "Agent active" strip in the Side Panel, and a dedicated `Browsme` tab group so automated tabs stay separated from your personal tabs.
- **Live Workflow Recorder & Calendar Schedules:** Record real clicks, typing (passwords masked as `{{password}}`), selects, keys, scrolls, file uploads (`{{file_path}}` variable) and navigations into reusable shortcuts that replay by CSS selector (with coordinate fallback) scheduled via `chrome.alarms` (`interval`, `once`, `daily`, `weekly`, `monthly`, `annually`).
## Architecture
```text
MCP Client / CLI / Local Script
│
▼ HTTP (http://127.0.0.1:9229)
┌─────────────────────────────────────────┐
│ Native Host (com.browsme.host) │ ◄── Default: spawned automatically by Chrome
│ Embedded BrowsmeBridgeServer (stdio) │
└─────────────────────────────────────────┘
▲
│ Chrome Native Messaging (32-bit length-prefixed JSON over stdio)
▼
┌─────────────────────────────────────────┐
│ Browsme Chrome MV3 Extension │
│ Side Panel · Options · Service Worker │
│ CDP Engine · Permissions · Shortcuts │
└─────────────────────────────────────────┘
▲
│ Optional WebSocket (ws://127.0.0.1:9229/browsme)
▼
Standalone Bridge Daemon (for Docker/remote use)
```
## Workspace Structure
```text
browsme/
├── package.json # npm workspaces root scripts
├── tsconfig.base.json # shared strict TypeScript config
├── LICENSE # Apache License 2.0
├── shared/ # @browsme/shared — types, wire protocol, 32 tool schemas, scheduling, workflow compiler, matching
├── bridge/ # @browsme/bridge — Native Host (embedded HTTP bridge), optional WS daemon, CLI & MCP server
└── extension/ # @browsme/extension — Chrome MV3 service worker, CDP engine, content scripts, Side Panel, Options, tests
```
## Installation & Quick Start
### Option A — Chrome Web Store + Local Bridge (Recommended for Users)
1. Install **Browsme** from the Chrome Web Store (coming soon) and copy its Extension ID from `chrome://extensions`.
2. Build the local bridge & register the Chrome Native Messaging host (requires Node.js 20+ on macOS or Linux):
```bash
git clone https://github.com/halilugur/browsme.git
cd browsme
npm install
npm run build -w @browsme/shared && npm run build -w @browsme/bridge
node bridge/dist/installNativeHost.js --extension-id <CHROME_EXTENSION_ID>
```
3. Reload the extension in `chrome://extensions` (or open the Side Panel and click the **Native** pill). Chrome will launch `com.browsme.host` automatically and expose `http://127.0.0.1:9229`.
### Option B — Load Unpacked from Source (Developers)
1. Install dependencies and build all workspaces:
```bash
npm install
npm run build
```
2. Open `chrome://extensions`, enable **Developer mode**, click **Load unpacked**, and select `extension/dist`.
3. Install the Native Messaging host manifest (automatically computes the unpacked extension ID for `extension/dist`). On macOS/Linux it is written for Google Chrome and for every installed Chrome Beta/Dev/Canary, Chromium, Brave, Edge and Vivaldi profile; on Windows it registers `HKCU` keys for Chrome, Chromium, Edge, Brave and Vivaldi. Pass `--extension-id <id>` for a Web Store install:
```bash
npm run install-native-host
```
4. Reload **Browsme** in `chrome://extensions` and press `Cmd+E` (`Ctrl+E` on Windows/Linux) to open the Side Panel.
## CLI & MCP Usage
### CLI
Once the Native Host is connected (or the standalone WebSocket daemon is running):
```bash
# Check bridge status & connected extension metadata
npm run browsme -- status
# List all 38 registered tools
npm run browsme -- tools
# Inspect interactive elements on the active tab
npm run browsme -- read_page '{"filter":"interactive"}'
# Capture a screenshot to disk
npm run browsme -- computer '{"action":"screenshot","scale":1}' --out shot.png
```
Environment variables:
- `BROWSME_BRIDGE_URL` (default `http://127.0.0.1:9229`)
- `BROWSME_SESSION` / `--session NAME` — agent session name, also the title of its tab group (CLI default `CLI`; the MCP server defaults to the client name plus a short id, e.g. `Claude Code · 3fa2`). HTTP callers may send `"session"` in the body or an `X-Browsme-Session` header.
- `BROWSME_TOKEN` — Bearer token, required when an **API Token** is set in Options → Bridge & MCP (the extension hands that token to the Native Host, so the HTTP API, CLI and MCP all require it). For a standalone `browsme-bridge` daemon the env variable itself sets the token.
### MCP Server (`browsme-mcp`)
Add Browsme to your MCP client configuration (stdio transport):
```json
{
"mcpServers": {
"browsme": {
"command": "node",
"args": ["/absolute/path/to/browsme/bridge/dist/mcp.js"],
"env": { "BROWSME_TOKEN": "<only if you set an API token>" }
}
}
}
```
Or connect over **Streamable HTTP** without spawning a process — the bridge serves MCP at `http://127.0.0.1:9229/mcp` (JSON responses; send `Authorization: Bearer <token>` if an API token is set):
```json
{
"mcpServers": {
"browsme": { "type": "http", "url": "http://127.0.0.1:9229/mcp" }
}
}
```
### Agent Skill (`SKILL.md`)
A ready-to-use agent skill is included at [`.agents/skills/browsme/SKILL.md`](./.agents/skills/browsme/SKILL.md) so AI coding agents know when and how to drive your real Chrome browser over `http://127.0.0.1:9229`:
```bash
mkdir -p ~/.gemini/config/skills
ln -sfn "$(pwd)/.agents/skills/browsme" ~/.gemini/config/skills/browsme
```
### Wire Protocol (`v1.0`)
Both Native Messaging (`stdin`/`stdout` 32-bit little-endian framing) and WebSocket share the same JSON envelope:
- Extension handshake:
```json
{
"type": "hello",
"protocolVersion": "1.0",
"client": "browsme-extension",
"extensionVersion": "1.0.0",
"apiToken": "<optional, native transport only>",
"tools": []
}
```
- Incoming tool request:
```json
{
"type": "tool_request",
"id": "req-1",
"tool": "read_page",
"args": { "filter": "interactive" }
}
```
- Tool response:
```json
{
"type": "tool_response",
"id": "req-1",
"tool": "read_page",
"result": { "success": true, "output": "..." }
}
```
## All 38 Automation Tools
| Category | Tools | Highlights |
| :--- | :--- | :--- |
| **Interaction** | `computer`, `browser_batch`, `wait_for`, `clipboard` | Click/drag (incl. HTML5 drag-and-drop)/hover/scroll by `ref`, CSS `selector` or coordinate, `viewport` & `screenshot` coordinate spaces, `fullPage`, element and **set-of-marks** (`annotate`) screenshots, smart SPA waiting (`selector`, `text`, `url`, `networkIdle`), Unicode typing, up to 50 batched actions, clipboard read/write |
| **DOM & JS** | `read_page`, `find`, `form_input`, `get_page_text`, `javascript_tool`, `extract_table` | A11y tree with `WeakRef` refs or Chrome's computed accessibility tree (`source: "accessibility"`, `ax_N` refs), cross-frame semantic/role search, HTML/ARIA table JSON extraction, React/Vue/rich-editor-safe inputs, CDP JS evaluation in any frame |
| **Navigation & Tabs** | `navigate`, `tabs_context`, `tabs_create`, `tabs_close`, `tabs_activate`, `tabs_group`, `resize_window`, `emulate_device`, `list_frames` | Background auto-grouping into `Browsme`, device/viewport/dark-mode/GPS/network emulation presets, `beforeunload` policy, iframe discovery |
| **Diagnostics** | `read_console_messages`, `read_network_requests`, `read_network_response`, `network_intercept`, `handle_dialog` | Console/network capture with sensitive header & query redaction, response body inspection, CDP `Fetch` request mocking/blocking, JS dialog control |
| **Media & Files** | `gif_creator`, `file_upload`, `upload_image`, `page_pdf` | Offscreen canvas action-overlay GIF export (`gif.js`), CDP file uploads, `Page.printToPDF` |
| **Browser Data** | `cookies_manage`, `storage_manage`, `downloads_manage`, `history_search`, `bookmarks_manage` | Full local cookie, `localStorage`/`sessionStorage`, download (incl. `wait` for completion), history, and bookmark management |
| **Workflows & Shortcuts** | `workflow_recorder`, `shortcuts_list`, `shortcuts_execute`, `shortcuts_save`, `shortcuts_delete` | Live event recording with password masking (`{{password}}`) and calendar scheduling via `chrome.alarms` |
## Privacy, Security & Permissions
**Local bridge hardening:** The HTTP API and WebSocket on `127.0.0.1:9229` reject any request that carries a web-page `Origin` (only `chrome-extension://` and Origin-less CLI/MCP clients are accepted) and any non-loopback `Host` header, and send no CORS headers. A website you visit therefore cannot drive your browser through the bridge (CSRF / DNS rebinding). Set an **API Token** in Options (or `BROWSME_TOKEN` for a standalone daemon) to additionally require a bearer token from every local caller.
**Zero Telemetry / Local-Only:** Browsme does **not** include analytics, tracking, ads, or remote servers. All DOM inspection, screenshots, recordings, settings, and execution logs remain strictly inside your browser and your local machine (`127.0.0.1` loopback / local Native Messaging `stdio`).
### Chrome Extension Permissions Justification (for Chrome Web Store Review)
| Permission | Purpose |
| :--- | :--- |
| `sidePanel` | Displays Browsme's primary Side Panel UI for manual tool control, inspection, workflows, and approval prompts. |
| `storage`, `unlimitedStorage` | Stores user preferences, trusted domains, saved workflows/shortcuts, and temporary captured screenshots/GIF frames locally. |
| `activeTab`, `tabs`, `tabGroups` | Inspects, switches, creates, closes, and organizes automated tabs into a dedicated `Browsme` tab group. |
| `scripting`, `webNavigation` | Injects content scripts for accessibility refs, visual automation indicators, live workflow recording, and navigation tracking. |
| `debugger` | Powers precise mouse/keyboard synthesis, console/network diagnostics, JS evaluation, and PDF printing via Chrome DevTools Protocol (`chrome.debugger`). |
| `alarms`, `notifications` | Executes user-scheduled shortcuts and shows approval prompts with Allow / Deny buttons. |
| `offscreen` | Renders multi-frame animated GIF recordings with action overlays and performs clipboard access in an isolated MV3 offscreen document. |
| `clipboardRead`, `clipboardWrite` | Implements the explicit `clipboard` tool (read text a page copied, or place text to paste). Only used when that tool is invoked. |
| `nativeMessaging` | Communicates locally over `stdio` with the `com.browsme.host` bridge process for CLI and MCP integrations. |
| `downloads`, `cookies`, `history`, `bookmarks` | Exposes explicit user/agent tools (`downloads_manage`, `cookies_manage`, `history_search`, `bookmarks_manage`). |
| `<all_urls>` host permission | Allows automation, DOM inspection, and visual indicators on user-selected websites, subject to configured allow/block patterns and per-domain approval rules. |
Full privacy details and Chrome Web Store submission notes: [`PRIVACY.md`](./PRIVACY.md) · [`docs/CHROME_WEB_STORE.md`](./docs/CHROME_WEB_STORE.md).
## Packaging for Chrome Web Store
```bash
npm run package:extension
```
This validates `extension/dist/manifest.json` and writes `release/browsme-v<version>.zip` ready for upload to the [Chrome Web Store Developer Dashboard](https://chrome.google.com/webstore/devconsole). See [`docs/CHROME_WEB_STORE.md`](./docs/CHROME_WEB_STORE.md) for the complete Store listing copy, permission justifications, and GitHub Actions auto-publish (`release.yml`) setup.
## Development & Testing
```bash
npm run typecheck # Strict TypeScript checks across shared, bridge, extension
npm run test # Vitest unit & integration suite (mocked Chrome APIs)
npm run test:e2e # Real-Chrome end-to-end test: loads extension/dist into Chrome and drives it
npm run build # Builds @browsme/shared, @browsme/bridge, and @browsme/extension
```
## Third-Party Notices & License
- Licensed under the **[Apache License, Version 2.0](./LICENSE)**.
- Bundles [`gif.js` (`0.2.0`)](https://github.com/jnordberg/gif.js) (`extension/public/gif.js` and `extension/public/gif.worker.js`), copyright Johan Nordberg, licensed under the MIT License.