@eden_qu/ut-automation-mcp
v1.4.1
Published
UT Automation MCP Server - Deterministic unit test generation based on rules
Downloads
670
Maintainers
Readme
UT Automation MCP Server
A deterministic unit test automation service based on Model Context Protocol (MCP).
Features
- Deterministic: Same input always produces same output (no AI randomness)
- Rule-based: Reads rules from
.cursor/rules/unit-test/*.mdc - Multi-platform: Supports iOS (Swift), Android (Kotlin/Java), C++
- 100% Coverage: Generates tests for all branches
- Auto-fix: Automatically fixes common compilation errors
- Configurable: Supports external workflow configuration
Installation
npm install @eden_qu/ut-automation-mcpOr install globally:
npm install -g @eden_qu/ut-automation-mcpUsage
As MCP Server
Add to your Cursor MCP configuration:
{
"mcpServers": {
"ut-automation": {
"command": "npx",
"args": ["@eden_qu/ut-automation-mcp"]
}
}
}Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
| UT_WORKSPACE_PATH | Override the workspace root directory | process.cwd() |
Using UT_WORKSPACE_PATH
When running the MCP server, you can set the workspace path via environment variable:
{
"mcpServers": {
"ut-automation": {
"command": "npx",
"args": ["@eden_qu/ut-automation-mcp"],
"env": {
"UT_WORKSPACE_PATH": "/path/to/your/project"
}
}
}
}This is useful when:
- The MCP server is started from a different directory than your project
- You want to run the server in a CI/CD environment
- Cursor doesn't support the
cwdconfiguration option
Commands
The MCP server recognizes these commands:
| Command | Description | Example |
|---------|-------------|---------|
| ut_changed | Generate UT for git changed files | ut_changed platform=ios |
| ut_all | Generate UT for all source files | ut_all platform=android |
| ut_path | Generate UT for files in path | ut_path path=common/ios |
| ut_files | Generate UT for specific files | ut_files files=A.swift,B.swift |
Parameters
platform: Target platform (ios,android,cpp,all)base: Base branch for git diff (default:develop)path: Path to scan for filesfiles: Comma-separated list of files
Architecture
┌─────────────────────────────────────────────────────────────────┐
│ ut_automation_mcp │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Tools (exposed): │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ execute(command, workflow?, config?) │ │
│ │ get_commands() │ │
│ │ get_rules(platform) │ │
│ └─────────────────────────────────────────────────────────────┘ │
│ │
│ Workflow Engine: │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ load_rules → detect_files → analyze → generate → compile → │ │
│ │ → test → coverage → report │ │
│ └─────────────────────────────────────────────────────────────┘ │
│ │
│ Skills (internal): │
│ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │
│ │Command │ │Rule │ │File │ │Source │ │UT │ │
│ │Parser │ │Loader │ │Detector│ │Analyzer│ │Generator│ │
│ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ │
│ ┌────────┐ ┌────────┐ ┌────────┐ │
│ │Build │ │Test │ │Report │ │
│ │Manager │ │Runner │ │Generator│ │
│ └────────┘ └────────┘ └────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘Workflow
Default Workflow
steps:
1. load_rules # Load .cursor/rules/unit-test/*.mdc
2. detect_files # Detect source files
3. analyze_source # Parse AST, extract branches
4. generate_ut # Generate test code
5. compile_and_fix # Compile with auto-fix
6. run_tests # Execute tests
7. collect_coverage # Collect coverage data
8. generate_reports # Output reportsCustom Workflow
Create .cursor/ut-automation/workflow.yaml:
name: custom_workflow
version: "1.0.0"
# Override config
config:
coverage_threshold:
line: 80
branch: 80
# Custom steps
steps:
- id: load_rules
action: load_rules
- id: detect
action: detect_files
# ... more stepsOutput
Reports are generated in .cursor/ut-reports/:
coverage-report.json- Line and branch coveragebranch-coverage.json- Detailed branch coveragerule-references.json- Applied rulesut-summary.md- Human-readable summary
Rules
The MCP reads rules from:
.cursor/rules/unit-test/ios-unit-test.mdc.cursor/rules/unit-test/android-unit-test.mdc.cursor/rules/unit-test/cpp-unit-test.mdc.cursor/rules/unit-test/unit-testing-principles.mdc
Determinism
This MCP guarantees deterministic output:
- Command parsing: Regex-based, no AI
- Rule loading: Direct file reading
- File detection: Git commands, file system
- AST analysis: Pattern-based parsing
- UT generation: Template rendering
- All steps: Reproducible
Development
# Install dependencies
npm install
# Build
npm run build
# Run locally
npm run dev
# Test
npm test
# Publish
npm run publish:npmLicense
MIT
