Frontend Test Generation & Code Review MCP Server
fe-testgen-mcp
MCPプロトコルに基づいたフロントエンドユニットテスト生成サービスで、AI分析とコード生成機能に特化しています。HTTP Streamingを通じてMCPツールを公開し、n8n、Cursor、Claudeなどのクライアントと統合可能です。
コア機能
テストマトリックス分析:コードの変更を分析し、機能リストとテストシナリオを生成
テストコード生成:マトリックスに基づいて完全なユニットテストコードを生成
マルチフレームワーク対応:VitestとJestをサポート
マルチシナリオカバレッジ:happy-path、edge-case、error-path、state-change
Related MCP server: Phabricator MCP Server
クイックスタート
# 安装依赖
pnpm install
# 构建
pnpm build
# 启动服务
pnpm startサービスはデフォルトで http://localhost:3000/mcp をリッスンします。
環境設定
env.example を .env にコピーし、必要な設定を入力してください:
# 必需:OpenAI API 密钥
OPENAI_API_KEY=your_api_key
# 可选:自定义模型
OPENAI_MODEL=gpt-4
# 可选:服务配置
HTTP_PORT=3000
HTTP_HOST=0.0.0.0 # 允许外部访问MCPツール
analyze-test-matrix
コードの変更を分析し、テストマトリックスを生成します。
パラメータ:
パラメータ | 型 | 必須 | 説明 |
rawDiff | string | ✅ | Unified diff形式のテキスト |
identifier | string | 一意識別子(MR ID、commit hash) | |
rules | string | test-strategy.mdの内容 | |
framework | string | テストフレームワーク(vitest/jest) |
戻り値:機能リスト、テストシナリオ、統計情報
generate-tests
ユニットテストコードを生成します。
パラメータ:
パラメータ | 型 | 必須 | 説明 |
rawDiff | string | ✅ | Unified diff形式のテキスト |
identifier | string | 一意識別子 | |
rules | string | test-strategy.mdの内容 | |
framework | string | テストフレームワーク | |
scenarios | string[] | 指定するシナリオタイプ | |
maxTests | number | 最大テスト数 |
戻り値:テストケースの配列(ファイルパス、コード、シナリオタイプを含む)
n8n統合
ワークフロー例
GitLab/Phabricator Webhook
│
▼
读取 diff + rules 文件
│
▼
调用 MCP generate-tests
│
▼
写入测试文件 + 创建 MR
│
▼
发送通知(企微/飞书)HTTP呼び出し例
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "generate-tests",
"arguments": {
"rawDiff": "diff --git a/src/utils.ts ...",
"framework": "vitest"
}
}
}'rulesファイル形式
プロジェクト内に .cursor/rules/test-strategy.md を作成します:
# 测试生成规则
## 测试框架配置
- **测试框架**:vitest
- **测试文件模式**:**/*.{test,spec}.{ts,tsx}
## Mock 策略
- 使用 vi.fn() 进行函数 mock
- HTTP 请求优先 mock fetch/axiosn8nはこのファイルの内容を読み取り、rules パラメータとしてMCPに渡します。
Dockerデプロイ
docker build -t fe-testgen-mcp .
docker run -d -p 3000:3000 \
-e OPENAI_API_KEY=xxx \
fe-testgen-mcpよくある質問
Q: 生成結果の一貫性を高めるには?
A: サービスはデフォルトで temperature=0 と固定の seed=42 を使用し、レスポンスキャッシュを有効にしています。
Q: テストフレームワークを指定するには?
A: 優先順位:framework パラメータ > rules 内の解析 > デフォルトの vitest
Q: 必要なNode.jsのバージョンは?
A: Node.js 18以上(20以上を推奨)
This server cannot be deployed
Maintenance
Related MCP Connectors
Approved test intent, reviewed Playwright automation and run evidence, inside your editor.
Code review that knows what depends on your change — before commit or on every PR.
Direct access to Cypress tests results and accessibility reports in your AI workflow.
Risk-scan a diff, flag AI-generated-code tells, find secrets. 5 of 7 tools need no account.
Related MCP Servers
- AlicenseDqualityDmaintenanceProvides tools for frontend testing including code analysis, test generation, test execution, and React component testing for Jest and Cypress frameworks.426MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with Phabricator for task management and code review workflows, including viewing and commenting on tasks, managing differential revisions, and providing intelligent review analysis with code context.7MIT
- AlicenseNot gradedqualityDmaintenanceAnalyzes 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.MIT
- FlicenseAqualityDmaintenanceProvides AI assistants with frontend development tools including component scaffolding, bundle analysis, accessibility checks, and responsive design guidance. Enables automated generation of React components with tests and stories, bundle optimization recommendations, and WCAG compliance fixes.6-