# chrome-eye
**A fast, cheap "eye" into real Chrome for Claude Code — structured JSON
instead of screenshots.** 56 MCP tools over the Chrome DevTools Protocol:
click/type/snapshot the real DOM, read the real layout and design tokens of
any page, emulate viewports/network/geolocation, mock requests, diff
screenshots, record and replay sessions.
[](go.mod)
[](LICENSE)
```
you: "does my mobile menu overlap the header on ui.shadcn.com?"
chrome-eye:
{ "headerRect": {"top":0,"bottom":56}, "panelRect": {"top":58}, "gap": 2 }
```
Real numbers from a real page, not a screenshot Claude has to eyeball —
that's the whole pitch. A `snapshot → click → snapshot` loop this way costs
a few hundred tokens instead of the few thousand an image-understanding
round trip costs with `claude-in-chrome`'s vision loop, and geometry
questions ("does X overlap Y", "is this the real height") get an exact
answer instead of a guess from pixels.
## Quick start
```bash
# 1. Chrome with a remote-debugging port (needs its own profile — see below)
open -na "Google Chrome" --args --remote-debugging-port=9222 \
--user-data-dir="$HOME/.chrome-eye-profile"
# 2. Build (from this repo's root)
cd chrome-eye
go build -o chrome-eye ./cmd/chrome-eye
# 3. Register with Claude Code
claude mcp add chrome-eye -- "$(pwd)/chrome-eye"
```
Restart Claude Code / reconnect MCP servers, then just ask it to look at a
page — it reaches for `chrome-eye`'s tools instead of taking a screenshot.
## Setup details
### Why Chrome needs a dedicated profile
Chrome **silently ignores** `--remote-debugging-port` when launched against
your default profile — a security guardrail Google added so a remote CDP
port can't be pointed at your real logged-in profile by accident. You must
pass a dedicated `--user-data-dir` too:
```bash
open -na "Google Chrome" --args \
--remote-debugging-port=9222 \
--user-data-dir="$HOME/Documents/uiux/chrome-eye/.chrome-profile"
```
The first run starts with empty cookies/logins in that profile; log into
whatever sites you need once and they persist there for next time (the
directory is gitignored). Verify it's listening:
```bash
curl -s http://127.0.0.1:9222/json/version
```
This is a separate profile from your everyday Chrome, not literally your
already-logged-in browser window — Chrome's own security policy rules that
out for a locally-run CDP client. It's the same tradeoff every CDP-based
tool (Playwright persistent context, browser-use, etc.) makes.
### Registering manually
If you'd rather edit `.mcp.json` directly instead of `claude mcp add`:
```json
{
"mcpServers": {
"chrome-eye": { "command": "/absolute/path/to/chrome-eye/chrome-eye" }
}
}
```
## Tools exposed
| Tool | Purpose |
|---|---|
| `list_tabs` | List open tabs; get a `target_id` |
| `snapshot` | Structured UI tree of the visible viewport (diffed by default) — `include_offscreen=true` to tag the whole page regardless of scroll position |
| `click` | Real, trusted click on an element by its stable id |
| `hover` | Move the mouse to an element without clicking — real DOM events + CSS :hover state, for dropdowns/tooltips/hover-reveal UI |
| `type` | Real, trusted keystrokes into a focused element |
| `press_key` | Real key press, with modifiers (Enter, Tab, Ctrl/Cmd+A, arrows, ...) |
| `scroll` | Scroll the page, or scroll an element into view |
| `navigate` | Load a URL in a tab |
| `go_back` / `go_forward` | Step through the tab's real browser history (Chrome's native back/forward, via the raw CDP history command — see `internal/browser/nav.go`) |
| `reload` | Reload the current page |
| `wait_for` | Wait for a condition (selector present/absent, text present, network idle) server-side until true, instead of Claude polling `snapshot` in a loop — the three DOM conditions resolve via a `MutationObserver` the instant the DOM actually changes, not a fixed poll tick |
| `inspect` | Computed style (curated subset), box model, and event listener types for an element — for "why is this positioned/styled like that" without falling back to `screenshot` |
| `get_cookies` / `set_cookie` | Read/write cookies via CDP (sees HttpOnly cookies, unlike an `execute_js` `document.cookie` read) |
| `get_storage` / `set_storage` | Read/write a tab's `localStorage`/`sessionStorage` via CDP's DOMStorage domain |
| `pdf` | Render a tab to PDF (`Page.printToPDF`) — a capability `claude-in-chrome` has no equivalent to |
| `get_tab_state` | Whether a tab is actually rendered right now (`visible`/`focused`) — check this before trusting `screenshot` or `start_gif_recording` on a backgrounded tab |
| `read_performance` | Navigation/Paint Timing (TTFB, DOMContentLoaded, load, FCP) plus passively-captured Web Vitals (LCP, CLS, long tasks) |
| `create_tab` / `close_tab` | Open/close a tab. chrome-eye never closes a tab on its own — only when explicitly asked |
| `resize_window` | Resize the OS Chrome window itself — for framing a screenshot/GIF recording. Not for testing responsive breakpoints; see `emulate_viewport` |
| `emulate_viewport` / `clear_viewport_emulation` | Override what the page's renderer thinks its viewport is (width/height/DPR/mobile), independent of the real OS window — the actual mechanism for testing responsive CSS/media queries. Takes effect immediately, unlike an OS window resize (see Known limitations) |
| `execute_js` | Escape hatch — run arbitrary JS, get the result back as JSON |
| `upload_file` | Set files on an `` |
| `read_console` | Buffered console.log/warn/error + uncaught exceptions for a tab |
| `read_network` | Buffered request/response log (method, url, status, mime) for a tab |
| `screenshot` | Cropped JPEG fallback — only when structured data isn't enough |
| `start_gif_recording` / `stop_gif_recording` | Record a tab's repaints (CDP screencast, push-based) and get back an animated GIF — for showing a human what happened, not for Claude's own perception loop |
| `list_browsers` / `connect_browser` | See/add other connected Chrome instances (different profile, different machine) |
| `enable_visual_feedback` / `disable_visual_feedback` | Opt-in "chrome-eye is driving this tab" indicator for a human watching: orange border, animated favicon (⊹✢✣✤✥✦), ⚙️ tab-title marker, and a real synthetic cursor icon that animates to each click target before it's clicked (like claude-in-chrome's, ~350ms/click). Off by default — the normal loop pays none of this cost, and `click` skips the cursor animation entirely unless this is on |
| `handle_dialog` | Arm how the *next* JS dialog (alert/confirm/prompt) on a tab is answered. Every dialog is already auto-answered the instant it appears (see Known limitations) — this overrides the default before triggering whatever opens one |
| `read_dialogs` | Buffered log of every JS dialog chrome-eye has seen and answered for a tab, and how |
| `read_downloads` | Buffered log of every download chrome-eye has seen begin/progress/complete for a tab |
| `list_frames` | Enumerate a page's frames (id, parent, url, same-origin) — the top document plus any iframes, nested arbitrarily deep |
| `mock_response` / `block_request` / `clear_mocks` | Intercept requests matching a glob URL pattern on a tab and fake a response or fail them — test error/loading states without a real backend |
| `emulate_network` / `clear_network_emulation` | Throttle or fully disconnect a tab's network, matching `navigator.onLine` |
| `emulate_geolocation` | Override a tab's reported location |
| `diff_screenshots` | Pixel-diff two screenshots — a cheap visual regression check, with a highlighted diff image and the largest changed regions (bounding boxes) back |
| `get_theme_tokens` | Every CSS custom property a page's stylesheets define (resolved live), plus real rendered typography for body/h1-h6/p/a/button — for extracting a page's design tokens |
| `get_layout_tree` | The real authored structure under one element — tag, raw `class` attribute, ARIA `role`, layout CSS (display/flex-direction or grid-template-columns/gap/justify-content/align-items) for every layout-defining container, and which known component library/component each element likely is (`data-slot`, `data-state`+`role`, and ~20 other verified signatures across shadcn/ui, Radix, React Aria, Base UI, Headless UI, MUI, Mantine, Ant Design, Chakra, Fluent UI, Carbon, Element Plus, Vuetify, Bootstrap — see `internal/tools/layout/signatures.go`), each tagged with a confidence level. Nested exactly as the DOM nests it. For rebuilding a region in another framework — reads the actual recipe (and, where recognized, the real component identity) directly instead of reverse-engineering spacing from `snapshot()`'s pixel coordinates through a diff/rebuild loop |
| `get_breakpoints` | The real responsive breakpoint scale a page likely uses — detects the CSS framework from the same signature registry `get_layout_tree` uses and returns its verified default breakpoints (Tailwind, Bootstrap, MUI, Ant Design, Chakra UI, Mantine), with real `--breakpoint-*`/`--bs-breakpoint-*` live values from the page itself where Tailwind v4/Bootstrap 5.2+ expose them (`live_detected: true`) overriding the assumed defaults. Pass each `min_width_px` to `emulate_viewport` to capture a region mobile-first — the direction Tailwind's own cascade actually flows, not desktop-first with mobile guessed afterward |
| `get_animations` | List CSS transitions/animations/Web Animations API animations active right now (play state, current time, duration, easing) — real numbers, not eyeballed from a video |
| `batch` | Run a sequence of the above tools in **one** MCP round trip, even across different `browser_id`s |
| `start_recording_actions` / `stop_recording_actions` | Capture every subsequent tool call against a tab as a replayable script (same shape `batch` accepts) |
| `replay_actions` | Run a recorded (or hand-written) script back — optionally redirected to a different tab/browser than it recorded from |
| `discover_browsers` | Probe common Chrome debug ports (9222-9229) on localhost for ones not yet registered — reports candidates for `connect_browser`, never connects itself |
`snapshot` also now walks into same-origin iframes transparently (their
elements appear like any other) and, for a cross-origin iframe it can't walk
into, emits a placeholder node (`tag: "iframe", cross_origin: true, src`)
instead of silently omitting it.
Typical loop: `snapshot` → find the element you want by its `id` → `click`
or `type` → `snapshot` again (returns only what changed). Chain a known
sequence (e.g. `type` → `press_key(enter)` → `snapshot`) through `batch` to
turn 3 round trips into 1.
`read_console`/`read_network` are captured passively in the background from
the moment chrome-eye first attaches to a tab (via `Runtime.enable` /
`Network.enable` / `Log.enable`) — they can't see activity from before that,
and each tab's log is capped at the last 500 entries.
Every tool takes an optional `browser_id` (default: `"default"`, the Chrome
chrome-eye was started against). Use `connect_browser` to register another
one — e.g. a second profile on a different `--remote-debugging-port` — under
a name, then pass that name as `browser_id` anywhere.
## Architecture
```
cmd/chrome-eye/ composition root: flags, wiring, ServeStdio
internal/browser/ shared kernel: Browser, Tab, Manager, EventLog, GIF recording
internal/security/ loopback guard
internal/tools// one package per tool group — cdp.go (CDP calls) + mcp.go (MCP registration)
```
Adding a new tool: create `internal/tools//` with a `cdp.go` (talks to
Chrome via the kernel's `*browser.Browser`/`*browser.Tab`) and an `mcp.go`
(`func Register(reg *tools.Registry)` registering its MCP schema), then add
one `.Register(reg)` line in `cmd/chrome-eye/main.go`. `reg.Add` takes
a `tools.ActivationPolicy` as a required argument
(`tools.NoActivation`/`tools.ActivateFirst`) — pick `ActivateFirst` if the
tool reads live computed style/animation state or dispatches input relying
on hit-testing (see Known limitations below); there's no default that would
let this be skipped by accident. See
`docs/RFC-0002-remaining-tools-and-architecture.md` for the reasoning behind
this shape.
## Design philosophy: structured-first, vision as a fallback, not a choice
chrome-eye is not "structured-DOM only" the way that sounds — it's
structured-first with a real vision escape hatch, because the two approaches
fail differently and a serious tool needs both:
- **Structured (`snapshot`)** is cheap and fast because it reads what the
browser already computed — DOM, computed style, layout — instead of asking
a model to re-derive "where is the button" from pixels every single step.
This is the right default for the overwhelming majority of real pages
(ordinary HTML forms, buttons, links, text), and it's what makes a
multi-step task (fill a form, click through a list, verify a value)
practical in terms of both latency and cost — a screenshot-decide-click
loop pays a full image round trip *per step*; `snapshot` pays it once, and
a `wait_for`/diff-mode follow-up costs a few tokens.
- **Vision (`screenshot`)** exists for exactly the cases structured data
can't answer: canvas/WebGL content, pixel-exact layout questions, anything
genuinely visual rather than semantic. It's deliberately described as the
"expensive fallback," not a parallel first-class path — reach for it when
`snapshot`'s structured view genuinely isn't enough, not by default.
The honest trade-off structured-first makes: element ids are DOM references
that have to be (re)established via `snapshot` before they're usable, and
by default only cover what's currently in the viewport (see
`include_offscreen` below for when that matters) — a page whose structure
changes between snapshot and action needs a fresh snapshot. Vision-based
clicking doesn't have that specific failure mode, but it isn't
"free of fragility" either — it has its own: a screenshot taken now can be
stale by the time a model finishes reasoning about it and a click lands,
it's exposed to the exact same Chrome tab-compositing quirks structured
mode is (a backgrounded tab returns a stale frame to *either* approach —
see `get_tab_state`), and it doesn't scale to multi-step tasks the way one
structured snapshot plus several cheap diffs does. Neither approach is
strictly more robust than the other across every scenario; they're
optimized for different failure modes, which is why chrome-eye ships both
instead of picking a side.
**On a page that reconciles heavily (React/Vue/etc. destroying and
re-mounting DOM nodes on state changes, not just mutating them):** a stale
element id fails loudly (`"element not found — call snapshot again"`) —
verified directly, there's no fallback that silently matches a similarly-
positioned/worded element instead, so an action never lands on the wrong
thing. But every remount between a `snapshot` and the action that follows
is a failed call needing a retry, which vision-loop tools don't pay since
they never held a persistent identity to lose in the first place. On a
page known to reconcile heavily, prefer re-`snapshot()`-ing immediately
before each action over batching several off one snapshot, or fall back to
`screenshot()` — this isn't just a fallback of convenience for that class
of site, it's the correct strategy.
## Known limitations
- Every JS dialog (`alert`/`confirm`/`prompt`/`beforeunload`) on every tab
is answered automatically the instant it appears — `alert`/`beforeunload`
accepted, `confirm`/`prompt` declined by default. This is not optional:
a JS dialog blocks the page's own script execution (and, transitively,
every further CDP command on that tab) until answered, and nothing on a
later MCP round trip could react in time. Call `handle_dialog` first to
override the default for the next dialog. See `read_dialogs` for what
happened. This only covers tabs chrome-eye has already attached to (any
tool call against a `target_id` triggers attach) — deliberately: chrome-
eye attaches lazily, on first use, rather than eagerly watching every tab
from process start, to keep the normal loop cheap. A tab that fires a
dialog before chrome-eye has ever been asked to look at it isn't covered.
- `screenshot` decodes/crops in Go (no GPU); fine for small crops, slow for
full 4K captures — ask for a tight region.
- `snapshot`/`click`/`type`/`inspect` reach into a cross-origin iframe when
Chrome actually gave it its own process (an out-of-process iframe,
OOPIF) — the common case for a genuinely different site embedded via
`