Skip to main content
Glama
README.md
# VRT MCP

Visual Regression Testing MCP Server - Compare page screenshots against design references using AI.

## Features

- **Figma Integration** - Fetch designs directly from Figma API
- **Local File Support** - Use local PNG files as design references
- **Smart Viewport Matching** - Auto-match viewport to design dimensions
- **Side-by-side Comparison** - Generate combined design/screenshot/diff images
- **Pre-actions** - Click, scroll, type, wait before capturing
- **Retry Logic** - Configurable retry with different wait strategies
- **Element Cropping** - Screenshot specific elements
- **Session Caching** - Reuse designs across iterations
- **Diagnostic Analysis** - Smart suggestions for high diff percentages

## Installation

```bash
# Clone the repository
git clone https://github.com/yourusername/vrt-mcp.git
cd vrt-mcp

# Install dependencies and setup
npm install
npm run setup
```

The setup script will automatically check and install:
- `odiff` - Image comparison tool
- Playwright Chromium browser

## Configuration

### Claude Desktop

Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "vrt": {
      "command": "node",
      "args": ["/path/to/vrt-mcp/dist/index.js"],
      "env": {
        "FIGMA_TOKEN": "your-figma-token"
      }
    }
  }
}
```

### Environment Variables

| Variable | Required | Description |
|----------|----------|-------------|
| `FIGMA_TOKEN` | For Figma source | Get from Figma Settings → Personal Access Tokens |

## Usage

### Basic Comparison (Local File)

```json
{
  "page_url": "http://localhost:3000",
  "design_source": {
    "type": "file",
    "path": "/path/to/design.png"
  }
}
```

### Figma Source

```json
{
  "page_url": "http://localhost:3000",
  "design_source": {
    "type": "figma",
    "file_key": "abc123",
    "node_id": "1:234",
    "scale": 2
  }
}
```

### With Pre-actions

```json
{
  "page_url": "http://localhost:3000",
  "design_source": { "type": "file", "path": "/path/to/design.png" },
  "pre_actions": [
    { "type": "wait", "value": 1000 },
    { "type": "click", "selector": ".menu-button" },
    { "type": "wait", "value": ".dropdown-menu" }
  ]
}
```

### Element Screenshot

```json
{
  "page_url": "http://localhost:3000",
  "design_source": { "type": "file", "path": "/path/to/header.png" },
  "crop_to_element": "header.main-header"
}
```

## Tools

### `vrt_compare`

Main comparison tool.

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `page_url` | string | required | URL to capture |
| `design_source` | object | required | Figma or file source |
| `viewport` | object | auto | `{ width, height }` |
| `auto_match_viewport` | boolean | true | Match design dimensions |
| `threshold` | number | 1 | Diff threshold (%) |
| `session_id` | string | auto | Session for caching |
| `skip_design_fetch` | boolean | false | Use cached design |
| `wait_for_selector` | string | - | CSS selector to wait for |
| `wait_until` | string | networkidle | load/domcontentloaded/networkidle/commit |
| `retry_count` | number | 1 | Retry attempts (1-3) |
| `retry_delay` | number | 1000 | Delay between retries (ms) |
| `crop_to_element` | string | - | CSS selector to crop to |
| `pre_actions` | array | - | Actions before capture |
| `generate_side_by_side` | boolean | false | Force side-by-side image |
| `antialiasing` | boolean | false | Enable antialiasing tolerance |

### `vrt_session_info`

Manage sessions and cache.

| Parameter | Type | Description |
|-----------|------|-------------|
| `action` | string | list/get/clear/clear_all |
| `session_id` | string | Required for get/clear |

## Response

```json
{
  "success": true,
  "session_id": "abc12345",
  "match": false,
  "diff_percentage": 5.23,
  "threshold": 1,
  "passed": false,
  "viewport": {
    "width": 1280,
    "height": 720,
    "source": "auto-matched from design"
  },
  "files": {
    "design": "/tmp/vrt-abc12345/design.png",
    "screenshot": "/tmp/vrt-abc12345/screenshot.png",
    "diff": "/tmp/vrt-abc12345/diff.png",
    "side_by_side": "/tmp/vrt-abc12345/side-by-side.png"
  },
  "cache_info": {
    "design_cached": true,
    "cache_path": "/tmp/vrt-abc12345",
    "created_at": "2025-01-22T10:00:00.000Z"
  },
  "analysis": {
    "likely_causes": ["Minor visual differences - could be font rendering or anti-aliasing"],
    "severity": "minor"
  }
}
```

## Development

```bash
npm run build    # Build TypeScript
npm run dev      # Watch mode
npm run setup    # Check/install dependencies
```

## License

MIT

TDQS

A3.5/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have clearly separate purposes: vrt_compare performs the actual screenshot capture and diff, while vrt_session_info handles inspection and cleanup of session/cache state. There is no realistic way an agent would confuse them, and vrt_compare's description explicitly points to session_id usage, linking the two cleanly.

Naming Consistency5/5

Both tools use a consistent vrt_ prefix with snake_case noun/verb naming (vrt_compare, vrt_session_info). A fully predictable pattern for a two-tool server.

Tool Count3/5

Two tools is on the thin side even for a narrowly scoped visual regression server. The core work is done by a single tool, with the second only supporting session housekeeping, making the surface feel minimal.

Completeness3/5

The compare-plus-session-management pair covers the primary iterate-on-diff workflow, including cached design reuse. However, there is no tool for approving/updating baselines, batch or multi-URL comparison, or standalone session creation/deletion beyond the vague 'manage' in vrt_session_info, leaving notable gaps.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues