MCP Component Review
Analyzes React component changes by performing structural analysis and generating visual diffs to identify pixel-level differences. It integrates with Figma to validate implementation compliance against design specifications and automates component reviews across git branches.
README
MCP Component Review
An MCP (Model Context Protocol) server for reviewing React component changes. Analyzes structural differences, generates visual diffs, and validates implementations against Figma designs.
Features
- Structural Analysis: Parse React components (TSX/JSX) and extract props, children, and styles
- Style Detection: Support for Tailwind CSS, styled-components, and CSS Modules
- Visual Diff: Screenshot components and generate pixel-level diff images
- Figma Integration: Extract design specs and validate implementation compliance
- Branch Review: Analyze all changed components in a git branch
Installation
git clone https://github.com/yourusername/mcp-component-review.git
cd mcp-component-review
npm install
npm run build
Usage
With Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"component-review": {
"command": "node",
"args": ["/path/to/mcp-component-review/dist/index.js"]
}
}
}
With Claude Code
claude mcp add component-review node /path/to/mcp-component-review/dist/index.js
Available Tools
analyze_component
Analyze a single React component file.
analyze_component({
file: "/path/to/Button.tsx"
})
Output:
- Component name and props
- Component tree structure
- Extracted styles (colors, spacing, typography)
compare_components
Compare two component files and get a structured diff.
compare_components({
oldFile: "/path/to/Button.old.tsx",
newFile: "/path/to/Button.new.tsx"
})
Output:
- Text content changes
- Child component additions/removals
- Prop changes
- Style changes (colors, spacing, typography)
visual_diff_components
Generate visual diff screenshots.
visual_diff_components({
oldFile: "/path/to/Button.old.tsx",
newFile: "/path/to/Button.new.tsx",
outputDir: "/path/to/output"
})
Output:
- Screenshots of old and new components
- Diff image highlighting changes
- Combined side-by-side view
get_figma_specs
Extract design specifications from Figma.
get_figma_specs({
figmaUrl: "https://www.figma.com/file/ABC123/Design?node-id=1:2",
figmaToken: "figd_xxxxx"
})
Output:
- Dimensions (width, height)
- Spacing (padding, margin, gap)
- Colors (background, text, border)
- Typography (font-size, font-weight, line-height)
- Border (radius, width)
validate_design_implementation
Compare Figma specs with implementation.
validate_design_implementation({
figmaUrl: "https://www.figma.com/file/ABC123/Design?node-id=1:2",
figmaToken: "figd_xxxxx",
componentFile: "/path/to/Button.tsx",
tolerance: 2
})
Output:
# Design Validation Report: Button
## Summary ⚠️
- **Score**: 75%
- **Matches**: 6/8
- **Mismatches**: 2
## Validation Details
| Property | Figma | Implementation | Status |
|---------------|-----------|----------------------|------------|
| padding-top | 8px | 8px (p-2) | ✅ match |
| background | #22C55E | #16A34A (bg-green-600)| ❌ mismatch|
| font-size | 16px | 18px (text-lg) | ❌ mismatch|
review_branch
Review all changed components in a git branch.
review_branch({
repoPath: "/path/to/repo",
baseBranch: "main",
targetBranch: "feature/new-button",
figmaToken: "figd_xxxxx",
figmaFileKey: "ABC123",
figmaMapping: {
"src/components/Button.tsx": "1:234",
"src/components/Card.tsx": "1:567"
},
outputDir: "/path/to/visual-diffs"
})
Output:
- Summary of all changed components
- Structural analysis for each component
- Visual diffs for modified components
- Figma validation scores
validate_and_fix
Validate a component and get auto-fix instructions. If the component doesn't match Figma, returns exact Tailwind/CSS changes needed.
validate_and_fix({
figmaUrl: "https://www.figma.com/file/ABC123/Design?node-id=1:2",
figmaToken: "figd_xxxxx",
componentFile: "/path/to/Button.tsx"
})
Output (when fixes needed):
🔧 **AUTO-FIX REQUIRED** for `src/Button.tsx`
Current design compliance: **62%**
## Required Changes
### 🔴 Missing (High Priority)
- **gap**: Add `gap-2`
- Expected: `8px`
### 🟡 Mismatches (Medium Priority)
- **background**: Change to `bg-green-500`
- Current: `bg-green-600`
- Expected: `#22C55E`
- **font-size**: Change to `text-base`
- Current: `text-lg`
- Expected: `16px`
## Instructions
1. Open `src/Button.tsx`
2. Find the className or styled-components styles
3. Apply the following Tailwind class changes:
Add/Replace: gap-2 bg-green-500 text-base
4. Save the file
5. Run validation again to confirm compliance
This output is designed to be directly actionable by an AI agent to automatically fix the issues.
Getting a Figma Token
- Go to Figma → Settings → Account
- Scroll to "Personal access tokens"
- Click "Create new token"
- Copy the token (starts with
figd_)
Example Workflow
Design Review Automation
// 1. Get the Figma specs for a component
const specs = await get_figma_specs({
figmaUrl: "https://www.figma.com/file/ABC/Design?node-id=1:2",
figmaToken: process.env.FIGMA_TOKEN
});
// 2. Validate the implementation
const validation = await validate_design_implementation({
figmaUrl: "https://www.figma.com/file/ABC/Design?node-id=1:2",
figmaToken: process.env.FIGMA_TOKEN,
componentFile: "src/components/Button.tsx"
});
// 3. If there are visual changes, generate a diff
const visualDiff = await visual_diff_components({
oldFile: "src/components/Button.old.tsx",
newFile: "src/components/Button.tsx",
outputDir: "./review-output"
});
PR Review Automation
// Review all components changed in a PR
const review = await review_branch({
repoPath: ".",
baseBranch: "main",
targetBranch: "HEAD",
figmaToken: process.env.FIGMA_TOKEN,
figmaFileKey: "ABC123",
figmaMapping: {
"src/components/Button.tsx": "1:234"
}
});
Development
# Install dependencies
npm install
# Build
npm run build
# Run in development mode
npm run dev
License
MIT
Contributing
Contributions are welcome! Please read the contributing guidelines before submitting a PR.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。