Skip to content

beyondworks/UI-Inspector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

UI Inspector MCP

Live UI preview server with built-in inspector, responsive viewport switching, and multi-framework export β€” powered by MCP (Model Context Protocol).

Vite 기반 라이브 UI 프리뷰 + μΈμŠ€νŽ™ν„° + λ°˜μ‘ν˜• 뷰포트 μ „ν™˜ + λ©€ν‹°ν”„λ ˆμž„μ›Œν¬ 내보내기λ₯Ό μ§€μ›ν•˜λŠ” MCP μ„œλ²„.


Features / μ£Όμš” κΈ°λŠ₯

Feature Description
Live Preview Vite dev server with HMR β€” changes reflect instantly / Vite HMR둜 μ¦‰μ‹œ λ°˜μ˜λ˜λŠ” 라이브 프리뷰
Inspector Click any element to see source location, design term, styles, and size / μ—˜λ¦¬λ¨ΌνŠΈ 클릭 μ‹œ μ†ŒμŠ€ μœ„μΉ˜, λ””μžμΈ μš©μ–΄, μŠ€νƒ€μΌ, 크기 ν‘œμ‹œ
Viewport Switching Mobile (375px), Tablet (768px), Desktop β€” real CSS @media breakpoints via iframe / iframe 기반 μ‹€μ œ CSS 미디어쿼리 λ°˜μ‘
Multi-Framework Export Export to Next.js, Remix, Nuxt, Astro, Vue (Vite), React (Vite) as ZIP / 6개 ν”„λ ˆμž„μ›Œν¬λ‘œ ZIP 내보내기
Design Tokens Inject CSS custom properties at session start / μ„Έμ…˜ μ‹œμž‘ μ‹œ λ””μžμΈ 토큰 μ£Όμž…
WebSocket Bridge Real-time communication between inspector UI and MCP server / μΈμŠ€νŽ™ν„° UI와 MCP μ„œλ²„ κ°„ μ‹€μ‹œκ°„ 톡신

Architecture / μ•„ν‚€ν…μ²˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  AI Assistant (Claude, etc.)                        β”‚
β”‚  ─── MCP Protocol (stdio) ───                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  UI Friend MCP Server (index.mjs)                   β”‚
β”‚  β”œβ”€β”€ PreviewManager     μ„Έμ…˜ 관리 / Session manager  β”‚
β”‚  β”œβ”€β”€ ProjectScaffold    ν…œν”Œλ¦Ώ 생성 / Scaffolding    β”‚
β”‚  β”œβ”€β”€ ViteLauncher       Vite ν”„λ‘œμ„ΈμŠ€ / Dev server   β”‚
β”‚  β”œβ”€β”€ WSBridge           WebSocket 톡신 / Comms       β”‚
β”‚  └── ExportEngine       ν”„λ ˆμž„μ›Œν¬ λ³€ν™˜ / Conversion  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Browser                                            β”‚
β”‚  β”œβ”€β”€ PreviewShell       νˆ΄λ°” + iframe 래퍼           β”‚
β”‚  β”‚   β”œβ”€β”€ Viewport switcher (Mobile/Tablet/Desktop)  β”‚
β”‚  β”‚   β”œβ”€β”€ Inspector toggle                           β”‚
β”‚  β”‚   β”œβ”€β”€ Export controls                            β”‚
β”‚  β”‚   └── CodePanel (element details)                β”‚
β”‚  └── iframe (preview-content)                       β”‚
β”‚      β”œβ”€β”€ App component (user code)                  β”‚
β”‚      β”œβ”€β”€ IframeWrapper (WS + postMessage listener)  β”‚
β”‚      └── InspectorOverlay (hover/click highlight)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Installation / μ„€μΉ˜

Prerequisites / 사전 μš”κ΅¬μ‚¬ν•­

  • Node.js >= 18
  • npm >= 9

1. Clone & Install / 클둠 및 μ„€μΉ˜

git clone https://github.com/beyondworks/UI-Friend-MCP.git
cd UI-Friend-MCP
npm install

2. Configure MCP Client / MCP ν΄λΌμ΄μ–ΈνŠΈ μ„€μ •

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

claude_desktop_config.json에 μ•„λž˜ λ‚΄μš©μ„ μΆ”κ°€ν•˜μ„Έμš”:

{
  "mcpServers": {
    "ui-friend": {
      "command": "node",
      "args": ["/absolute/path/to/UI-Friend-MCP/index.mjs"]
    }
  }
}

Claude Code (CLI)

Add to .claude/settings.json or ~/.claude.json:

.claude/settings.json λ˜λŠ” ~/.claude.json에 μΆ”κ°€:

{
  "mcpServers": {
    "ui-friend": {
      "command": "node",
      "args": ["/absolute/path/to/UI-Friend-MCP/index.mjs"]
    }
  }
}

Cursor / VS Code (Copilot)

Add to .cursor/mcp.json or VS Code MCP settings:

{
  "mcpServers": {
    "ui-friend": {
      "command": "node",
      "args": ["/absolute/path/to/UI-Friend-MCP/index.mjs"]
    }
  }
}

3. Restart your AI client / AI ν΄λΌμ΄μ–ΈνŠΈ μž¬μ‹œμž‘

After configuration, restart your AI client to load the MCP server.

μ„€μ • ν›„ AI ν΄λΌμ΄μ–ΈνŠΈλ₯Ό μž¬μ‹œμž‘ν•˜λ©΄ MCP μ„œλ²„κ°€ λ‘œλ“œλ©λ‹ˆλ‹€.


Usage / μ‚¬μš© 방법

Tools Overview / 도ꡬ λͺ©λ‘

Tool Description
preview_start Start a live preview session / 라이브 프리뷰 μ„Έμ…˜ μ‹œμž‘
preview_update Update files with HMR / 파일 μ—…λ°μ΄νŠΈ (HMR μ¦‰μ‹œ 반영)
preview_status Check session status / μ„Έμ…˜ μƒνƒœ 확인
preview_stop Stop a session / μ„Έμ…˜ μ’…λ£Œ
preview_select_element Inspector: get/enable/disable / μΈμŠ€νŽ™ν„° μ œμ–΄
preview_export Export to framework ZIP / ν”„λ ˆμž„μ›Œν¬ ZIP 내보내기
preview_screenshot Capture screenshot / μŠ€ν¬λ¦°μƒ· 캑처

Example Workflow / μ‚¬μš© μ˜ˆμ‹œ

1. Start a Preview / 프리뷰 μ‹œμž‘

"Create a landing page preview called my-landing"
β†’ Calls preview_start with project_name: "my-landing"
β†’ Opens http://localhost:5173 in browser
"my-landingμ΄λΌλŠ” λžœλ”©νŽ˜μ΄μ§€ 프리뷰λ₯Ό μ‹œμž‘ν•΄μ€˜"
β†’ preview_start 호좜 (project_name: "my-landing")
β†’ λΈŒλΌμš°μ €μ—μ„œ http://localhost:5173 μžλ™ μ—΄λ¦Ό

Parameters:

{
  "project_name": "my-landing",
  "framework": "react",
  "initial_code": {
    "src/App.tsx": "export default function App() { return <h1>Hello</h1> }"
  },
  "design_tokens": {
    "colorPrimary": "#3b82f6",
    "colorBackground": "#020617"
  }
}

2. Update Files / 파일 μ—…λ°μ΄νŠΈ

"Update the hero section with a gradient background"
β†’ Calls preview_update with session_id and new file content
β†’ Vite HMR applies changes instantly (no page reload)
"νžˆμ–΄λ‘œ μ„Ήμ…˜μ— κ·ΈλΌλ°μ΄μ…˜ 배경을 μ μš©ν•΄μ€˜"
β†’ preview_update 호좜 (session_id + μƒˆ 파일 λ‚΄μš©)
β†’ Vite HMR둜 μ¦‰μ‹œ 반영 (μƒˆλ‘œκ³ μΉ¨ μ—†μŒ)

Parameters:

{
  "session_id": "prev_abc123",
  "files": {
    "src/components/Hero.tsx": "... updated code ..."
  }
}

3. Inspect Elements / μ—˜λ¦¬λ¨ΌνŠΈ 검사

The toolbar in the browser provides:

  • Inspector ON/OFF β€” Toggle element selection mode
  • Click any element β†’ Code panel shows:
    • Source file and line number (e.g., src/components/Hero.tsx:26)
    • Design term (e.g., "Hero Section", "Call to Action", "Navigation Bar")
    • Computed styles, size, text content

λΈŒλΌμš°μ € νˆ΄λ°”μ—μ„œ:

  • Inspector ON/OFF β€” μ—˜λ¦¬λ¨ΌνŠΈ 선택 λͺ¨λ“œ ν† κΈ€
  • μ—˜λ¦¬λ¨ΌνŠΈ 클릭 β†’ Code νŒ¨λ„μ— ν‘œμ‹œ:
    • μ†ŒμŠ€ 파일과 라인 번호 (예: src/components/Hero.tsx:26)
    • λ””μžμΈ μš©μ–΄ (예: "Hero Section", "Call to Action", "Navigation Bar")
    • κ³„μ‚°λœ μŠ€νƒ€μΌ, 크기, ν…μŠ€νŠΈ λ‚΄μš©

4. Switch Viewports / 뷰포트 μ „ν™˜

Click Mobile (375px), Tablet (768px), or Desktop in the toolbar. The preview uses a real iframe, so CSS @media queries respond correctly.

νˆ΄λ°”μ—μ„œ Mobile (375px), Tablet (768px), Desktop을 ν΄λ¦­ν•©λ‹ˆλ‹€. μ‹€μ œ iframe을 μ‚¬μš©ν•˜λ―€λ‘œ CSS @media 쿼리가 μ •ν™•νžˆ λ°˜μ‘ν•©λ‹ˆλ‹€.

5. Export Project / ν”„λ‘œμ νŠΈ 내보내기

"Export this project as Next.js to ~/Desktop"
β†’ Calls preview_export with target_framework: "nextjs"
β†’ Saves ZIP to ~/Desktop/gemini-export-my-landing-nextjs.zip
"이 ν”„λ‘œμ νŠΈλ₯Ό Next.js둜 ~/Desktop에 λ‚΄λ³΄λ‚΄μ€˜"
β†’ preview_export 호좜 (target_framework: "nextjs")
β†’ ~/Desktop/gemini-export-my-landing-nextjs.zip μ €μž₯

Parameters:

{
  "session_id": "prev_abc123",
  "target_framework": "nextjs",
  "output_path": "~/Desktop"
}

Supported frameworks / 지원 ν”„λ ˆμž„μ›Œν¬:

  • vite-react β€” React + Vite (default)
  • nextjs β€” Next.js (App Router)
  • vite-vue β€” Vue 3 + Vite
  • nuxt β€” Nuxt 3
  • astro β€” Astro
  • remix β€” Remix

6. Stop Session / μ„Έμ…˜ μ’…λ£Œ

{
  "session_id": "prev_abc123",
  "keep_files": false
}

Inspector Design Terms / μΈμŠ€νŽ™ν„° λ””μžμΈ μš©μ–΄

The inspector automatically identifies UI patterns and labels them with design terminology:

μΈμŠ€νŽ™ν„°κ°€ UI νŒ¨ν„΄μ„ μžλ™ μ‹λ³„ν•˜μ—¬ λ””μžμΈ μš©μ–΄λ₯Ό ν‘œμ‹œν•©λ‹ˆλ‹€:

Category Terms
Structure Header, Footer, Main Content, Sidebar, Section, Divider
Navigation Navigation Bar, Sticky Header, Breadcrumb, Tabs, Pagination, Menu
Content Card, Hero Section, Panel, Widget, Dashboard, Metric Card
Interactive Button, Call to Action, Link, Dropdown, Toggle Switch, Search
Form Form, Input Field, Text Area, Select Dropdown, Date Picker
Data Data Table, List, Tree View, Timeline, Chart
Feedback Modal, Toast, Alert, Progress Bar, Skeleton, Spinner
Media Image, Avatar, Icon, Video Player, Carousel
Layout Grid, Container, Stack, Spacer, Sticky Element

Project Structure / ν”„λ‘œμ νŠΈ ꡬ쑰

UI-Friend-MCP/
β”œβ”€β”€ index.mjs                 MCP server entry point / MCP μ„œλ²„ μ§„μž…μ 
β”œβ”€β”€ package.json
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ preview-manager.mjs   Session orchestrator / μ„Έμ…˜ μ˜€μΌ€μŠ€νŠΈλ ˆμ΄ν„°
β”‚   β”œβ”€β”€ project-scaffold.mjs  Template scaffolding / ν…œν”Œλ¦Ώ 생성
β”‚   β”œβ”€β”€ vite-launcher.mjs     Vite process manager / Vite ν”„λ‘œμ„ΈμŠ€ 관리
β”‚   β”œβ”€β”€ ws-bridge.mjs         WebSocket bridge / WebSocket λΈŒλ¦Ώμ§€
β”‚   β”œβ”€β”€ export-engine.mjs     Framework export / ν”„λ ˆμž„μ›Œν¬ λ³€ν™˜ μ—”μ§„
β”‚   β”œβ”€β”€ converters/            Framework converters / ν”„λ ˆμž„μ›Œν¬ λ³€ν™˜κΈ°
β”‚   β”‚   β”œβ”€β”€ nextjs.mjs
β”‚   β”‚   β”œβ”€β”€ vite-react.mjs
β”‚   β”‚   β”œβ”€β”€ vite-vue.mjs
β”‚   β”‚   β”œβ”€β”€ nuxt.mjs
β”‚   β”‚   β”œβ”€β”€ astro.mjs
β”‚   β”‚   └── remix.mjs
β”‚   └── templates/             Project templates / ν”„λ‘œμ νŠΈ ν…œν”Œλ¦Ώ
β”‚       β”œβ”€β”€ react/             React + Vite + Inspector
β”‚       β”œβ”€β”€ vue/               Vue 3 + Vite
β”‚       └── vanilla/           Vanilla + Vite

How It Works / λ™μž‘ 원리

  1. Session Start: preview_start scaffolds a project from a template, runs npm install, and launches Vite dev server + WebSocket bridge.

  2. Live Editing: preview_update writes files to the project directory. Vite HMR detects changes and hot-reloads the browser.

  3. Inspector: The preview runs inside an iframe. When Inspector is ON, an overlay captures hover/click events, identifies the element's source location (via Babel source-loc plugin), maps it to a design term, and displays details in the Code panel.

  4. Viewport: The iframe's actual width changes, triggering real CSS @media breakpoints β€” not just visual scaling.

  5. Export: The export engine copies user code (stripping inspector files), runs a framework-specific converter, and creates a ZIP file.


  1. μ„Έμ…˜ μ‹œμž‘: preview_startκ°€ ν…œν”Œλ¦Ώμ—μ„œ ν”„λ‘œμ νŠΈλ₯Ό μƒμ„±ν•˜κ³ , npm install ν›„ Vite 개발 μ„œλ²„ + WebSocket λΈŒλ¦Ώμ§€λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.

  2. 라이브 νŽΈμ§‘: preview_updateκ°€ ν”„λ‘œμ νŠΈ 디렉토리에 νŒŒμΌμ„ μ“°λ©΄, Vite HMR이 변경을 κ°μ§€ν•˜μ—¬ λΈŒλΌμš°μ €λ₯Ό ν•«λ¦¬λ‘œλ“œν•©λ‹ˆλ‹€.

  3. μΈμŠ€νŽ™ν„°: 프리뷰가 iframe μ•ˆμ—μ„œ μ‹€ν–‰λ©λ‹ˆλ‹€. Inspector ON μ‹œ μ˜€λ²„λ ˆμ΄κ°€ hover/click 이벀트λ₯Ό μΊ‘μ²˜ν•˜κ³ , Babel source-loc ν”ŒλŸ¬κ·ΈμΈμœΌλ‘œ μ†ŒμŠ€ μœ„μΉ˜λ₯Ό μ‹λ³„ν•˜λ©°, λ””μžμΈ μš©μ–΄λ₯Ό λ§€ν•‘ν•˜μ—¬ Code νŒ¨λ„μ— ν‘œμ‹œν•©λ‹ˆλ‹€.

  4. 뷰포트: iframe의 μ‹€μ œ λ„ˆλΉ„κ°€ λ³€κ²½λ˜μ–΄ CSS @media λΈŒλ ˆμ΄ν¬ν¬μΈνŠΈκ°€ μ‹€μ œλ‘œ λ°˜μ‘ν•©λ‹ˆλ‹€ β€” λ‹¨μˆœ μ‹œκ°μ  μΆ•μ†Œκ°€ μ•„λ‹™λ‹ˆλ‹€.

  5. 내보내기: 내보내기 엔진이 μ‚¬μš©μž μ½”λ“œλ₯Ό 볡사(μΈμŠ€νŽ™ν„° 파일 제거)ν•˜κ³ , ν”„λ ˆμž„μ›Œν¬λ³„ λ³€ν™˜κΈ°λ₯Ό μ‹€ν–‰ν•œ λ’€ ZIP νŒŒμΌμ„ μƒμ„±ν•©λ‹ˆλ‹€.


License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors