AI测试分析协议服务器

MCP-Allure是一个用于AI驱动测试分析的模型上下文协议服务器,将Allure测试报告转换为适合LLM处理的格式。

  • by huixin2022
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 huixin2022/allure-analysis-mcp

使用说明

MCP魅力

用于AI驱动的测试分析的模型上下文协议(MCP)服务器。将Allure测试报告转换为LLM友好格式。


主要特点

双格式支持

使用解析两种Allure报告格式 自动检测:

格式 目录 描述
HTML报告 allure-report/ 生成的HTML报告(包含 data/suites.json)
原始结果 allure-results/ 原始测试输出(*-result.json 文件)

无需指定格式——该工具会自动正确检测和解析。

智能上下文管理

通过以下方式避免LLM上下文长度限制 4种输出模式:

模式 大小 最适合
summary 最小 快速概述,初步分析
compact 小 只关注失败
detailed 中等 失败的测试,包含步骤详细信息
full 最大 完整数据(如果>50KB,则自动截断)

安装

选择最适合您需求的方法:

方法 最适合 优点
CLI(推荐) 生产使用 启动更快,配置更简单,无需运行时下载
紫外线运行 快速测试 无需安装,始终为最新版本

方法1:CLI安装(推荐)

安装一次软件包,然后使用简单的 mcp-allure 命令。

步骤1:安装

# Clone or download the repository
cd /path/to/mcp-allure

# Install with uv (recommended)
uv pip install .

# Or with pip
pip install .

步骤2:配置MCP

添加到您的MCP设置中(例如。, ~/.cursor/mcp.json 或Claude桌面配置):

{
  "mcpServers": {
    "mcp-allure-server": {
      "command": "mcp-allure"
    }
  }
}

就是这样!这 mcp-allure 命令现在可用。

方法2:使用 uv run (无需安装)

无需安装即可直接运行。适用于测试或一次性使用。

{
  "mcpServers": {
    "mcp-allure-server": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp[cli]",
        "mcp",
        "run",
        "/path/to/mcp-allure/mcp_allure_server.py"
      ]
    }
  }
}

注: 如果您支持公司代理,您可能需要添加 "env": { "UV_NATIVE_TLS": "true" } 以处理SSL证书。


工具参考

analyze_allure_report

使用智能输出大小分析Allure报告,以供LLM使用。

参数:

参数 类型 默认值 说明
results_dir string 必填 路径 allure-report 或 allure-results
mode 字符串 "summary" 输出模式: summary, compact, detailed, full
status_filter 字符串 null 筛选器: failed, passed, broken, skipped

输出模式说明:

1. summary (默认)-建议首次通话

最紧凑。仅返回统计信息和失败的测试列表。

{
  "summary": {
    "total_suites": 5,
    "total_tests": 150,
    "passed": 142,
    "failed": 6,
    "broken": 2,
    "skipped": 0,
    "pass_rate": "94.7%"
  },
  "failed_tests": [
    {"suite": "tests.test_login", "name": "test_invalid_password", "status": "failed"}
  ],
  "suites": [
    {"name": "tests.test_login", "status": "passed", "test_count": 10}
  ],
  "_metadata": {"source_type": "results", "mode": "summary"}
}

2. compact --故障焦点

仅显示失败的测试,并提供最少的详细信息。

{
  "overview": {"total_passed": 142, "total_failed": 8, "showing": "failed_only"},
  "test-suites": [
    {
      "name": "tests.test_api",
      "status": "failed",
      "test-cases": [
        {"name": "test_create_user", "status": "failed", "failed_steps": ["POST /api/users"]}
      ]
    }
  ]
}

3. detailed --有步骤

包括步长信息(限制为50次测试,2级步长)。

{
  "note": "Showing 50 tests (max 50), step depth limited to 2",
  "test-suites": [
    {
      "name": "tests.test_login",
      "test-cases": [
        {
          "name": "test_success",
          "title": "Test successful login",
          "status": "passed",
          "severity": "critical",
          "steps": [
            {"name": "Open login page", "status": "passed"},
            {"name": "Enter credentials", "status": "passed"}
          ]
        }
      ]
    }
  ]
}

4. full --一切(小心使用)

完整数据。如果响应超过50KB,则自动截断。

使用示例:

# Quick overview (recommended first call)
analyze_allure_report(results_dir="/path/to/allure-results")

# Focus on failures
analyze_allure_report(results_dir="/path/to/allure-results", mode="compact")

# Detailed failed tests only
analyze_allure_report(results_dir="/path/to/allure-results", mode="detailed", status_filter="failed")

# All passed tests (verification)
analyze_allure_report(results_dir="/path/to/allure-results", mode="compact", status_filter="passed")

工作流示例

分析测试结果的典型工作流程:

第一步:分析测试结果

# Get quick overview
analyze_allure_report(results_dir="./allure-results", mode="summary")

第二步:调查故障

# Get details on failed tests
analyze_allure_report(results_dir="./allure-results", mode="detailed", status_filter="failed")

第三步:深入了解具体测试

# Get full details for comprehensive analysis
analyze_allure_report(results_dir="./allure-results", mode="full", status_filter="failed")

为什么选择MCP Allure?

问题 解决方案
Allure报告未经过LLM优化 通过智能大小转换为结构化JSON
上下文长度限制 从摘要到完整的多种输出模式
大型测试套件压倒LLM 自动截断和过滤

许可证

MIT许可证-请参阅 许可证 了解详情。