
Universal Test Framework
io.github.phoenice-labs由 GitHub 账号 phoenice-labs 发布v1.0.2更新于 Nov 3, 2026
Polyglot MCP test generation with 8-section contract enforcement across Python, TS, Java, Go, C++.
概览
本地 MCP 服务器,可跨六种语言生成、校验、登记、运行测试并生成报告,强制满足 8 段式测试契约。
- 可以做什么
- 为 Python、TypeScript、JavaScript、Java、Go 和 C++ 源码生成测试套件,并自动识别语言与测试框架、推荐测试类型。
- 按 8 段式契约校验任意测试并打分,低于最低分数的测试会被拦截。
- 登记契约、导入 JUnit XML 结果、运行测试与变异测试,并查询按项目隔离的 SQLite 登记库。
- 分析覆盖率缺口、构建需求到测试的追溯矩阵,并输出 HTML、JUnit 或 JSON 合规报告及状态与趋势摘要。
- 适用场景
- 适合让 AI 助手编写测试、同时希望每个测试都关联需求、按固定契约评分并跨会话留痕的场景。也适用于需要追溯性与覆盖率缺口报告,或在 CI 中对生成测试设质量门禁的团队。
- 运行要求
- 以本地 stdio 进程运行,来自 PyPI 包 universal-test-framework;推荐用 uvx 启动,pip 或本地克隆安装需 Python 3.11+。也可用 Docker 提供共享的 HTTP/SSE 端点。需通过工具参数 project_dir 或环境变量 UTF_PROJECT_DIR 指定项目目录,以保证登记库按项目隔离。
安装
在 SourceWeft 中
- 打开 控制台中的 Universal Test Framework,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Universal Test Framework (UTF)
Contract-driven test enforcement and reporting for LLM-generated code — via MCP, VS Code, Copilot CLI, Claude, Cursor, or Python SDK.
UTF is an MCP server and contract enforcement engine. It does not replace your AI coding assistant — it gives every test your AI writes a mandatory quality gate, a structured audit trail, and a comprehensive compliance report.
[PyPI version] [Python] [License: MIT]
Why UTF? (Not Another Test Generator)
AI tools — GitHub Copilot, Claude, Cursor, Gemini — generate tests fast. The problem: fast ≠ trustworthy.
UTF vs Markdown Instructions / Prompt Files
You may already use markdown files (AGENTS.md, copilot-instructions.md, .cursorrules) to guide your AI. UTF is complementary — not competing:
Use markdown instructions to shape how your AI thinks. Use UTF to verify and report on what it produced.
Key Features
- 13 MCP tools — generate, validate, register, analyze, trace, execute, mutate, report, and query tests
- 6 languages — Python, TypeScript, JavaScript, Java, Go, C++
- 7 test types — unit, integration, API, E2E, contract, performance, security
- 8-section contract — every test must pass all 8 sections or it is blocked (minimum score: 0.85)
- 3-segment test IDs —
TC-{PRJ}-{MODULE}-{NNN}and classicTC-{MODULE}-{NNN}both accepted - Five install modes —
uvx(zero-clone), local clone, Docker, GitHub MCP Registry, pip SDK - VS Code @utf — chat participant with slash commands
- CI/CD ready — GitHub Actions, GitLab CI, pre-commit hooks
- Per-project overrides — YAML rules in
.utf/rules/override global defaults
Quick Start
Setup Method Comparison
All methods (1, 2, 4) using stdio transport write the registry to ${workspaceFolder}/.utf/utf.db — isolated per project and persistent across sessions.
Method 1 — uvx (Zero-Install, Recommended)
Requires uv. No cloning, no venv.
Add to %APPDATA%\Code\User\mcp.json (Windows) or ~/.config/Code/User/mcp.json (macOS/Linux):
Registry:
.utf/utf.dbinside${workspaceFolder}— isolated per project, persistent across sessions.
Reload VS Code after editingmcp.json.
Method 2 — Local Clone (VS Code + Copilot)
Reload VS Code → open Copilot Chat → ask naturally: generate e2e tests for my backend.
The install script writes this entry to mcp.json:
Registry:
${workspaceFolder}/.utf/utf.db— isolated per project.
@utfslash commands are available after the VSIX extension is installed.
Method 3 — Docker (Team / Remote)
Connect from VS Code by adding to mcp.json:
Registry: persisted in a named Docker volume (
utf_registry → /app/.utf/utf.db).
For per-project isolation with Docker, use a bind-mount indocker-compose.yml:Because Docker uses HTTP/SSE transport (no
${workspaceFolder}templating), passproject_direxplicitly in tool calls, or setUTF_PROJECT_DIRin the container environment.
Per-project Docker workflow:
Method 4 — GitHub MCP Registry
Once published, UTF is discoverable via the MCP marketplace. Clients that support server.json install it automatically. The generated mcp.json entry is equivalent to Method 1 (uvx).
Registry isolation: The MCP registry schema does not support a
cwdfield at the registry level.
UTF resolves project isolation via (in priority order):
project_dirargument passed to each tool callUTF_PROJECT_DIRenvironment variablePath.cwd()fallback (server's working directory)For correct isolation, ensure the MCP client writes
"cwd": "${workspaceFolder}"and"UTF_PROJECT_DIR": "${workspaceFolder}"in the generated entry (UTF'smcp-gallery.jsondoes this).
Method 5 — pip + Python SDK
Registry:
<project_dir>/.utf/utf.dbwhenproject_diris passed; falls back toPath.cwd().
MCP Tools Reference
The 8-Section Test Contract
Every test generated by UTF must satisfy all 8 sections. Tests that fail any hard section are blocked — returned in blocked_tests, never silently included.
Minimum passing score: 0.85. Tests below this threshold are blocked regardless of individual section presence. "none" in gaps or vague rationale like "to test the function" are rejected.
Supported Matrix
The UTF 3-Phase E2E Workflow
This is the canonical flow for using UTF with any AI CLI (Copilot, Claude, Cursor) or VS Code. Follow the phases in order — skipping Phase 1 registration means the report has no Per-Test Contract Detail cards.
Why register before running? The UTF registry has two record types.
status=generatedrecords (created byregister_contracts) drive the Per-Test Contract Detail cards in the HTML report.status=executed/failedrecords (created byimport_test_results) drive the Execution Results table. Both must exist for a test to appear in both sections. Running pytest before registering means you get execution rows but no 8-section detail cards.
Per-Method 8-Section Comment Block (mandatory)
Every test METHOD must have its own inline comment block — not a class docstring:
Test ID formats accepted: TC-HLT-001 (2-segment) or TC-FIQ-HLT-001 (3-segment project-prefixed).
Invoking UTF from AI CLIs
GitHub Copilot CLI
UTF tools are called via natural language — no special syntax required:
Claude (claude.ai / Claude CLI / MCP client)
Claude supports MCP servers natively. With UTF added to your MCP config:
To add UTF to Claude's MCP config (~/.config/claude/mcp.json or equivalent):
Cursor
In Cursor, add UTF as an MCP server in .cursor/mcp.json (project-level) or ~/.cursor/mcp.json (global):
Then ask Cursor naturally:
Any MCP-Compatible Client (Windsurf, Continue, etc.)
The MCP entry is identical regardless of client:
UTF uses natural language detection — the same prompts work across all MCP-compatible AI clients.
GitHub Copilot CLI Usage
UTF is invoked via natural language in the GitHub Copilot CLI — there are no special slash commands or @utf syntax at the CLI prompt. Simply describe what you want and the MCP tools are called automatically.
How to Invoke UTF from the CLI
Full Command Reference (Natural Language → MCP Tool)
Registry Persistence
The UTF SQLite registry persists per-project across all sessions:
Once tests are generated (generate_tests), they are registered in .utf/utf.db. Subsequent calls to utf report, utf status, and query registry read from this persistent store — no re-generation required between sessions.
Providing Project Context
When the MCP server cannot infer your project root automatically, pass project_dir explicitly:
Or configure "cwd": "${workspaceFolder}" in your mcp.json (already set in the quickstart above) so the server always starts in the correct workspace.
VS Code Copilot Chat Integration
After running .\scripts\install-vscode-mcp.ps1 (Option 2) or adding the uvx MCP entry (Option 1):
Note: The
@utfprefix and/slash-commandsyntax only work if you have the UTF VS Code Chat Participant extension installed (included via Option 2). In GitHub Copilot CLI and standard VS Code Copilot Chat without the extension, use natural language — the MCP tools are invoked automatically. See GitHub Copilot CLI Usage above.
VS Code Chat Participant Slash Commands (extension required)
Natural Language (no extension required)
In standard VS Code Copilot Chat or GitHub Copilot CLI, just ask:
UTF reads the open file, detects language and framework, infers requirements from function signatures, generates happy-path + negative + edge-case tests — all validated against the 8-section contract.
Python SDK
Use UTF directly in scripts or CI pipelines without the MCP server:
CI/CD Integration
GitHub Actions
Per-Project Configuration
Create .utf/rules/project-overrides.yaml in your project root:
Rules are deep-merged: project overrides layer on top of UTF's global defaults. The 8-section contract structure itself cannot be overridden.
Architecture
Transport modes:
stdio— default, used by VS Code MCP client anduvxHTTP/SSE— for remote/team deployment (--transport http --port 8765)
SQLite registry resolves to .utf/utf.db relative to the caller's project root (the cwd in mcp.json, or the project_dir parameter passed to any tool). Each project has its own isolated registry — no shared state. The registry persists across all sessions until explicitly cleared.
Installation Options Summary
Registry Isolation Rules
All setups resolve the SQLite registry path using the same priority chain:
The recommended approach for all setups: set both "cwd": "${workspaceFolder}" and
"env": { "UTF_PROJECT_DIR": "${workspaceFolder}" } in your mcp.json entry.
This ensures registry isolation works even if a tool call omits project_dir.
Security
- All MCP tool inputs are validated via Pydantic before processing
- No secrets, credentials, or PII are logged or stored
- The registry (
utf.db) is local to each project and never transmitted - Docker image runs as non-root user
- Rate limiting is enforced on the HTTP/SSE transport
License
MIT — see LICENSE
来源:README.md,提交 767601f
工具
0版本历史
1- v1.0.2最新Sep 16, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。