websight
by h34tsink
README.md
<div align="center">
# ποΈ WebSight
### *Give Your AI Agent Eyes*
[](https://www.typescriptlang.org/)
[](https://modelcontextprotocol.io/)
[](https://playwright.dev/)
[](https://opensource.org/licenses/MIT)
**WebSight is an MCP server that enables AI agents to see, analyze, and verify visual changes on web pages with pixel-perfect accuracy.**
[Getting Started](#-quick-start) β’
[Features](#-features) β’
[How It Works](#-how-it-works) β’
[API Reference](#-api-reference) β’
[Contributing](#-contributing)
</div>
---
## π― The Problem
AI coding assistants are incredibly powerful at writing and modifying codeβbut they're **blind**. When you ask an AI to *"make the button bigger"* or *"change the theme to dark mode"*, it edits the code and hopes for the best. There's no way for the AI to actually **see** what changed.
## π‘ The Solution
**WebSight gives AI agents vision.** It's a set of visual analysis tools exposed via the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/), allowing AI agents to:
- π **Analyze** β Understand page structure, CSS variables, themes, and interactive elements
- πΈ **Snapshot** β Capture visual baselines before making changes
- π― **Compare** β Verify changes with pixel-level diffing and percentage metrics
---
## β¨ Features
| Feature | Description |
|---------|-------------|
| π¨ **Theme Extraction** | Automatically detects light/dark mode, color schemes, CSS custom properties |
| ποΈ **Layout Analysis** | Identifies landmarks (header, nav, main, footer) and content sections |
| π±οΈ **Action Detection** | Finds all interactive elements with their selectors and test IDs |
| π **Visual Diffing** | Pixel-by-pixel comparison with configurable threshold |
| π±οΈ **Page Interactions** | Click, type, select, hover, scroll β all from AI commands |
| β‘ **10x Faster** | Persistent browser session eliminates cold-start overhead |
| π€ **MCP Integration** | Works seamlessly with Claude Desktop, Cursor, and VS Code Copilot |
| π **Auto-Detection** | Automatically finds running dev servers (Vite, Next.js, etc.) |
---
## π Quick Start
### Installation
```bash
# Clone the repository
git clone https://github.com/h34tsink/websight.git
cd websight
# Install dependencies
npm install
# Build the project
npm run build
# Auto-install to your AI tools
npm run install:mcp
```
> π‘ **Tip:** The installer automatically detects and configures Claude Desktop, Cursor, and VS Code!
### Target Specific Tools
```bash
npm run install:claude # Claude Desktop only
npm run install:cursor # Cursor only
npm run install:vscode # VS Code Copilot only
npm run install:all # All detected tools
```
---
## π How It Works
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI AGENT WORKFLOW β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. LOOK 2. BASELINE 3. DIFF β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Analyze the β β Save visual β β Compare and β β
β β current pageββββ snapshot ββββββΊβ verify β β
β β structure β β before edit β β the changes β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β
β "I see CSS vars, "Baseline "2.3% pixel β
β theme is dark, saved!" difference, β
β 3 buttons..." change OK!" β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
### Example Conversation
> **You:** "Use WebSight to change the primary color to red"
> **AI:** *Looking at page... I see `--primary: #3b82f6` in the CSS variables. Let me save a baseline first.*
>
> *[Makes code changes]*
>
> *Comparing with baseline... Visual difference: 12.4%. The primary color has been updated across 3 buttons and the header accent.*
---
## π Usage
### With AI Agents (Recommended)
Just tell your AI assistant:
```
"use websight to analyze this page"
"use websight to change the theme to dark mode"
"use websight to verify my CSS changes worked"
```
The AI will automatically use the appropriate tools in sequence.
### CLI Commands
```bash
npm run dev # Start test page at localhost:5173
npm run look # Analyze the current page
npm run baseline # Save snapshot before changes
npm run diff # Compare current state with baseline
```
---
## π API Reference
### MCP Tool Actions
| Action | Parameters | Description |
|--------|------------|-------------|
| `look` | `url?` | Analyze page structure, CSS variables, theme, and interactive elements |
| `baseline` | `url?` | Capture and save visual snapshot for later comparison |
| `diff` | `url?` | Compare current state against saved baseline, returns % difference |
| `click` | `target`, `url?` | Click an element by text, test ID, or selector |
| `type` | `target`, `text`, `url?` | Type text into an input field |
| `select` | `target`, `value`, `url?` | Choose an option from a dropdown |
| `hover` | `target`, `url?` | Hover over an element |
| `scroll` | `direction`, `url?` | Scroll the page (up/down/top/bottom) |
| `press` | `key`, `url?` | Press a keyboard key (Enter, Escape, Tab, etc.) |
### Example Usage
```
websight(action="look")
websight(action="click", target="Submit")
websight(action="type", target="email", text="test@example.com")
websight(action="select", target="country", value="USA")
```
### Programmatic API
```typescript
import { analyze, saveBaseline, closeSession, click, type } from 'websight/session';
// Analyze any page
const { snapshot, report } = await analyze('http://localhost:3000');
// Interact
await click('Open Modal');
await type('email', 'test@example.com');
await click('Submit');
console.log(analysis.snapshot.theme); // { mode: 'dark', scheme: 'monochrome' }
console.log(analysis.snapshot.cssVars); // { '--primary': '#3b82f6', ... }
console.log(analysis.snapshot.actions); // [{ type: 'button', text: 'Submit', ... }]
// Save baseline before changes
await saveBaseline('http://localhost:3000', './out');
// Clean up
await closeBrowser();
```
---
## ποΈ Project Structure
```
websight/
βββ π src/
β βββ mcp-server.ts # MCP server entry point
β βββ π tools/
β βββ api.ts # Programmatic API
β βββ types.ts # TypeScript definitions
β βββ detect.ts # Dev server auto-detection
β βββ compare.ts # Pixel diffing logic
β βββ report.ts # Report generation
β βββ π extractors/ # Page analysis modules
β βββ theme.ts # Theme & CSS variable extraction
β βββ landmarks.ts # Layout landmark detection
β βββ sections.ts # Content section analysis
β βββ actions.ts # Interactive element finder
β βββ overlays.ts # Modal/overlay detection
βββ π scripts/
β βββ install.js # Automated MCP installer
βββ π test-page/
β βββ index.html # Development test page
βββ π dist/ # Compiled output
βββ π out/ # Generated analysis & snapshots
```
---
## βοΈ Configuration
### Automatic Setup (Recommended)
```bash
npm run install:mcp
```
This automatically detects and configures your AI tools.
### Manual Configuration
<details>
<summary><b>Claude Desktop</b></summary>
Edit `%APPDATA%/Claude/claude_desktop_config.json`:
```json
{
"mcpServers": {
"websight": {
"command": "node",
"args": ["C:/path/to/websight/dist/src/mcp-server.js"]
}
}
}
```
</details>
<details>
<summary><b>VS Code Copilot</b></summary>
Edit `.vscode/mcp.json` in your workspace:
```json
{
"mcpServers": {
"websight": {
"command": "node",
"args": ["C:/path/to/websight/dist/src/mcp-server.js"]
}
}
}
```
</details>
<details>
<summary><b>Cursor</b></summary>
Edit `%APPDATA%/Cursor/User/globalStorage/cursor.mcp/mcp.json`:
```json
{
"mcpServers": {
"websight": {
"command": "node",
"args": ["C:/path/to/websight/dist/src/mcp-server.js"]
}
}
}
```
</details>
<details>
<summary><b>Claude Code</b></summary>
**Option 1:** Create `.mcp.json` in your project root:
```json
{
"mcpServers": {
"websight": {
"command": "node",
"args": ["C:/path/to/websight/dist/src/mcp-server.js"]
}
}
}
```
**Option 2:** Use the CLI command:
```bash
claude mcp add websight node C:/path/to/websight/dist/src/mcp-server.js
```
</details>
---
## π οΈ Development
```bash
npm run dev # Start test page with hot reload
npm run mcp # Run MCP server in dev mode
npm run build # Build for production
npm run clean # Remove generated files
```
---
## π€ Contributing
Contributions are welcome! Feel free to:
- π Report bugs
- π‘ Suggest features
- π§ Submit pull requests
---
## π€ Author
<table>
<tr>
<td align="center">
<b>Sean Treppa</b><br/>
<sub>Creator & Maintainer</sub>
</td>
</tr>
</table>
---
## π License
This project is licensed under the **MIT License** β see the [LICENSE](LICENSE) file for details.
---
<div align="center">
**Built with β€οΈ for the AI-assisted development community**
*Because AI agents shouldn't have to code blind.*
</div>
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo issues