# ui-loop [Health: Active]

**Category:** 💻 Developer Tools  
**Repository:** https://github.com/djig/ui-loop  
**GitHub Stars:** 1  
**npm Downloads (last month):** 67  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/djignesh21-ui-loop

## Description
Context-budgeted visual feedback for coding agents. MCP server + CLI + Claude Code plugin that lets an agent see the UI it just changed without flooding context.

## Tools
Capabilities this server exposes over MCP:

- **ui_capture** — Screenshot a page and save it as the baseline for its label. Returns a compact text summary (title, console errors, failed requests, overflow, a11y violations). The image is returned only on the first capture of a label or when includeFull=true. Call this BEFORE editing so ui_diff has something to compare against.
- **ui_diff** — Re-capture a page, pixel-diff it against the baseline for its label, and return ONLY what changed: a text summary plus cropped images of changed regions (largest first) that fit within maxTokens. Omitted regions are listed so you can fetch them with ui_region. The new capture becomes the baseline. If no baseline exists, behaves like ui_capture.
- **ui_region** — Fetch a single crop from a stored capture at higher resolution. region is either a diff region index (from ui_diff output) or a box {x,y,width,height} in page pixels.
- **ui_assert** — Run cheap text-only checks against a live page: text present, element visible/hidden, element count, no console errors, no horizontal overflow, no a11y violations. Returns pass/fail with short evidence. Never returns images.
- **ui_list** — List labels and their stored captures (ids, sizes) under .ui-loop/captures.
- **ui_forget** — Delete stored captures for a label, or all labels when omitted.
- **ui_detect_dev_server** — Find running local dev servers (UI_LOOP_URL env, Next.js .next/dev/lock, common ports 3000–3005/5173/4200/8080). Returns candidate base URLs.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "ui-loop": {
    "command": "npx",
    "args": ["-y","@djignesh21/ui-loop@0.1.2"],
    "env": {
      "UI_LOOP_CHROMIUM": "",
      "UI_LOOP_URL": "",
      "UI_LOOP_ROUTE": "",
      "UI_LOOP_MAX_TOKENS": "",
      "UI_LOOP_KEEP": "",
      "UI_LOOP_MAX_CROP_SIDE": "",
      "UI_LOOP_TIMEOUT_MS": "",
      "UI_LOOP_HOOK_DISABLED": ""
    }
  }
}
```

**Requires environment variables:** `UI_LOOP_CHROMIUM`, `UI_LOOP_URL`, `UI_LOOP_ROUTE`, `UI_LOOP_MAX_TOKENS`, `UI_LOOP_KEEP`, `UI_LOOP_MAX_CROP_SIDE`, `UI_LOOP_TIMEOUT_MS`, `UI_LOOP_HOOK_DISABLED` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What ui-loop does

The ui-loop MCP server connects an agent to a locally running web application through Chromium. It captures a page, stores the result under `.ui-loop/`, and uses later captures as baselines for visual comparison. Rather than returning a full screenshot on every turn, it produces a compact text report and crops for changed regions.

Reports can include the page title and final URL, viewport dimensions, deduplicated console errors and warnings, uncaught exceptions, failed requests with status 400 or higher, horizontal overflow, selected layout shifts, and axe-core accessibility violations at serious impact or higher by default. Diff results also report the percentage of changed pixels and identify nearby elements by tag, role, and text snippet.

Captures are automatically evicted according to the configured retention limit, so the conversation does not accumulate image history. Every tool also returns structured JSON content for clients that prefer machine-readable results.

## How the ui-loop MCP server works

The normal workflow starts by locating the development server with `ui_detect_dev_server`. The server checks `UI_LOOP_URL`, Next.js development state, and common ports including 3000–3005, 5173, 4200, and 8080. Call `ui_capture` before an edit to establish a baseline, make the code change, then call `ui_diff` against the same label. Each diff becomes the next baseline.

The first capture for a label can include one downscaled full image. Later diffs return changed-region crops, ordered by area, while the running result stays within `maxTokens`. Crops are padded and downscaled according to configuration. If the budget cannot include every region, the response identifies omitted regions so the agent can request one with `ui_region`. Use `ui_assert` for text-only checks after visual verification.

## Setup and configuration

Install the package with `npx -y @djignesh21/ui-loop@0.1.2 serve` as the command for an MCP client. Claude Code also has a plugin that registers the server, adds a post-edit hook, and supplies a capture-to-diff workflow. Cursor and Codex can register the same stdio command through their MCP configuration. Running `npx -y @djignesh21/ui-loop@0.1.2 init` adds `.ui-loop/` to `.gitignore` and prints configuration snippets.

Chromium is selected from `UI_LOOP_CHROMIUM`, then Playwright's bundled browser, then common Chrome or Chromium locations. If no browser is found, install Chromium with Playwright or set the executable path explicitly. `UI_LOOP_URL` sets the development server base URL, while `UI_LOOP_ROUTE` overrides route inference for hook-driven diffs, including dynamic routes.

The default token budget is 4000, with five captures retained per label. `UI_LOOP_MAX_TOKENS`, `UI_LOOP_KEEP`, `UI_LOOP_MAX_CROP_SIDE`, and `UI_LOOP_TIMEOUT_MS` adjust these values. Set `UI_LOOP_HOOK_DISABLED=1` to disable the hook.

## Tools and capabilities

- `ui_capture`: Capture a page and create or replace a label baseline.
- `ui_diff`: Re-capture a page and return pixel differences, summaries, and region crops.
- `ui_region`: Retrieve one stored region at higher resolution.
- `ui_assert`: Check text, visibility, counts, console errors, overflow, and accessibility conditions without returning images.
- `ui_list`: List labels and stored capture sizes.
- `ui_forget`: Delete one label's captures or clear all stored captures.
- `ui_detect_dev_server`: Find a likely local development server.

## Limitations and notes

The server is designed for local development URLs and depends on a usable Chromium installation. Its image-token calculation is an upper-bound heuristic based on Anthropic's formula; other models may bill images differently. The optional Claude Code hook only runs for edits to supported UI-related extensions when a development server is detected, injects a bounded text summary, never blocks the edit, and remains silent when there is nothing to inspect.

The ui-loop MCP server does not replace general browser automation: its documented purpose is post-edit visual feedback using summaries, diffs, and targeted crops. A diff without an existing baseline behaves like a capture and reports that condition.

_Full upstream README: https://allmcps.com/mcp/djignesh21-ui-loop/readme_

