Skip to main content
Glama
sudo-ai-git

io.github.sudo-ai-git/mcp-benchmark-hygiene

mcp-benchmark-hygiene

mcp-name: io.github.sudo-ai-git/mcp-benchmark-hygiene

对会静默破坏 agent-benchmark / 函数评分的 pytest 配置泄漏进行确定性检测。

无需 LLM。无需网络。一个问题,可靠回答:

如果我在这个工作区内运行 python -m pytest <tests>,它是否会继承 宿主机上的覆盖率/中止门控,从而将通过的代码误判为失败?


此工具捕获的缺陷

自动化 agent 评估框架通常会在目标工作区内运行 python -m pytest <hidden_tests>。如果该工作区嵌套在带有 pytest addopts 的仓库根目录之下——例如:

[tool.pytest.ini_options]
addopts = "--cov=harness --cov-report=term-missing:skip-covered --cov-fail-under=80"

pytest 会将宿主机上的 pyproject.toml 解析为其 rootdir,继承其中的 addopts,并因宿主机自身的覆盖率门控而失败(harness 的覆盖率为 0% → 低于阈值 → 非零退出)。随后,评估框架将功能上 PASSING 的代码记录为 FAILED。

这正是 sudo-ai-git/vulcanbench-findings 中记录的缺陷:VulcanBench 的声明式评分器因此将每个功能任务误评为 0.0;而用 -o addopts= 中和该泄漏后,同样的工作区 10/10 全部通过。

Related MCP server: forge-repo-mcp

它交给你的修复方案

当工作区被标记为 CORRUPTED 时,该工具会返回修正后的命令:

python -m pytest -o addopts= <tests>

-o addopts= 会剥离继承而来的覆盖率/中止门控。(或者从仓库根目录之外运行评分器。)

工具

工具

用途

inspect_workspace(path)

完整分析:ini 链、生效的 addopts、CLEAN/CORRUPTED/UNKNOWN 判定 + 修正后的命令

check_addopts(path)

轻量布尔:corrupted + 原因

summarize(analysis)

一行可操作的摘要字符串

确定性核心(零依赖)

该分析会从工作区目录向上遍历到文件系统根目录,按 pytest 最先找到的顺序读取 pyproject.toml / pytest.ini / tox.ini / setup.cfg,并提取 addopts。标记项:

  • 覆盖率门控 — --cov, --cov-fail-under, --cov-report, --cov-config

  • 中止/严格门控 — --maxfail, -x, --strict, --strict-markers, --pdb, --ff

只有会改变退出码/中止评分的门控才会被标记。无害的 addopts 会连同其确切字符串一起报告为 CLEAN。

安装与运行(MCP stdio)

一条命令(推荐)——直接从仓库安装,无需 PyPI token:

uv tool install git+https://github.com/sudo-ai-git/mcp-benchmark-hygiene
mcp-benchmark-hygiene                        # run stdio server
mcp-benchmark-hygiene --http --port 8137     # or Streamable HTTP

或者使用 pipx:pipx install git+https://github.com/sudo-ai-git/mcp-benchmark-hygiene

直接从源码安装(备选方案):

{ "mcpServers": {
    "benchmark-hygiene": { "command": "python3", "args": ["/abs/path/to/mcp_server.py"] }
}}

需要官方的 mcp Python 包(pip install mcp)。确定性核心(inspect_workspace / check_addopts / summarize)以零依赖即可导入并运行——mcp 包仅用于 stdio 服务器。

Streamable HTTP(远程/可发布到 Smithery)

python3 mcp_server.py --http --port 8137   # serves on http://<host>:8137/mcp/

使用 --http 运行,即可通过 Streamable HTTP(远程 MCP 端点)提供服务,而非 stdio。这正是 smithery mcp publish <url> 进行基于 URL 的发布时所期望的传输方式——因此一旦存在 Smithery 服务 token,该服务器即可原样部署。

示例

inspect_workspace(path="/home/runner/vulcanbench/workspace/task-1")
→ {
    "ok": true,
    "workspace": "/home/runner/vulcanbench/workspace/task-1",
    "ini_chain": [{"file": "/home/runner/vulcanbench/pyproject.toml",
                   "addopts": "--cov=harness ... --cov-fail-under=80"}],
    "effective_addopts": "--cov=harness ... --cov-fail-under=80",
    "will_corrupt_grading": true,
    "verdict": "CORRUPTED",
    "fixed_command": ["python3", "-m", "pytest", "-o", "addopts=", "<tests>"],
    "reasons": ["coverage gate(s) present: ['--cov', '--cov-fail-under']"]
}

验证

  • python3 test_detector.py — 5/5 项核心检测检查(根门控、嵌套继承、干净、中止门控、pyproject-no-pytest)

  • python3 test_e2e.py — 驱动真实的 MCP stdio 传输(initialize → tools/call),并断言 CORRUPTED / CLEAN 能在线路上完整传递

同系列项目

这是 sudo-ai-git 推出的三个确定性、无 LLM 的 agent 信任 MCP 服务器之一:

许可证与出处

MIT。独立衍生自文档记载的 VulcanBench #79 发现;不暗示获得 morganlinton/VulcanBench 的认可或与其存在关联。

定制集成服务

需要将此连接到你的内部系统(认证、日志、安全扫描通过、托管)?请提交一个 custom-build request。无论采用哪种方式,MIT 参考资产均可免费使用。

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to run and analyze pytest tests for desktop applications through interactive commands. Supports test execution, filtering, result analysis, and debugging for comprehensive test automation workflows.
    2
    -
  • A
    license
    A
    quality
    B
    maintenance
    Provides structured, sandboxed test and lint feedback for coding agents, returning compact typed verdicts with failure fingerprints instead of raw runner output. It enables impact-selected test execution in isolated containers, distinguishing pre-existing failures from regressions.
    4
    Apache 2.0