mcpField
T
Test Intel

Test Intel

本地服务
petri-labs.org开发工具35 周前更新

关于 Test Intel

Test Intel 是分析 JavaScript 和 TypeScript 覆盖率文件及源码、帮助确定测试优先级的 MCP 服务。它在本地运行,支持常见覆盖率格式,并提供报告命令和 GitHub Action。

主要功能

  1. 01分析未覆盖的文件、函数、行和分支
  2. 02查找缺少匹配测试文件的函数
  3. 03评估函数复杂度
  4. 04建议测试用例类别
  5. 05读取 lcov、Istanbul JSON 和 Cobertura
  6. 06提供 CLI 报告和 GitHub Action

适用场景

  1. 01根据覆盖率报告确定待补缺口的优先级
  2. 02找出复杂且未覆盖的函数进行测试
  3. 03审查函数的潜在测试用例
  4. 04将覆盖率分析加入 CI 摘要

MCP 相关

向 MCP 客户端提供覆盖率分析、未测试函数检测、复杂度评估和测试建议工具。它读取本地文件,并将访问范围限制在服务启动目录内。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"barissozudogru-test-intel": {
"command": "npx",
"args": [
"-y",
"@barissozudogru/test-intel-mcp"
]
}
}
}
启动命令npx -y @barissozudogru/test-intel-mcp

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@barissozudogru/test-intel-mcp0.8.1

工具

4

收录的工具列表 · 更新于 3 周前

参数类型必填说明
formatenum否覆盖率格式。如果省略,则根据文件扩展名自动检测。lcov | istanbul | cobertura
coverage_pathstring是覆盖率文件的路径(lcov.info、coverage-summary.json、coverage.xml 等)

详细介绍

test-intel-mcp

npm 版本 npm 下载量 CI MCP 注册表 MIT 许可证

test-intel-mcp

将 JavaScript 和 TypeScript 覆盖率文件转换为实用的测试优先级。该服务会读取本地覆盖率和源文件,找出缺口、评估函数复杂度,并建议有针对性的测试用例,不会将代码发送到外部服务。

工具页面 · npm · 已列入官方 MCP 注册表

test-intel-mcp 分析真实的 p-limit 覆盖率

一分钟上手

在任何兼容 stdio 的 MCP 客户端中添加一条本地服务配置:

{
  "mcpServers": {
    "test-intel": {
      "command": "npx",
      "args": ["-y", "@barissozudogru/test-intel-mcp"]
    }
  }
}

然后让客户端检查现有的覆盖率文件:

Use test-intel to analyze coverage/lcov.info, identify the highest-impact gaps,
and suggest tests for the most complex uncovered function.

无需账号、API 密钥或托管服务。文件访问权限仅限于服务启动所在的目录。

本仓库的实际效果

对真实的 src/paths.ts 文件运行复杂度工具,结果如下:

Function complexity analysis for: src/paths.ts
Total functions analyzed: 1

Priority | Function        | Line | Cyclomatic | Branches | Loops
---------|-----------------|------|------------|----------|------
low      | deriveTestPaths | 11   | 3          | 1        | 1

Summary: 0 critical, 0 high, 0 medium, 1 low priority

同一服务还可读取 lcov、Istanbul JSON 和 Cobertura 文件,找出未覆盖的函数、行和分支。

固定版本的 p-limit 7.3.1 案例研究 使用上游项目中通过的 22 个测试复现了覆盖率。test-intel-report 将其 lcov 文件中的未覆盖内容缩减为两行和一个分支,同时保留原始覆盖率文件供检查。

如果这为你节省了时间,不妨考虑为仓库加星,帮助其他开发者发现它。

工具

工具能解答的问题
analyze_test_coverage哪些文件、函数、行和分支仍未覆盖?
find_untested_functions哪些源函数没有对应的测试文件?
get_function_complexity哪些函数应优先关注测试?
suggest_test_cases应检查哪些正常路径、边界、错误、异步和类型用例?

支持的覆盖率格式:

格式常见生成工具
lcovJest、Vitest、nyc、Istanbul
Istanbul JSONJest、nyc、Istanbul
Cobertura XMLJest、pytest-cov、JaCoCo

基于启发式的源码与测试匹配以及复杂度分数仅用于确定优先级。原生覆盖率数据和人工审查仍是判断依据。

覆盖率报告命令

该软件包还提供了一个非 MCP 命令,可用于 CI 和终端:

npx -y -p @barissozudogru/test-intel-mcp test-intel-report coverage/lcov.info

如果文件名有歧义,可以指定格式:

test-intel-report coverage/result.xml cobertura

GitHub Action

使用项目自己的测试运行器生成覆盖率,然后将生成的文件传递给该 Action:

name: Test priorities

on: [pull_request]

jobs:
  test-intel:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v4
      - name: Run tests with coverage
        run: npm ci && npm test -- --coverage
      - uses: barissozudogru/[email protected]
        with:
          coverage-path: coverage/lcov.info

报告会写入工作流摘要。该 Action 分析的是已有文件,不会上传源代码或覆盖率数据。

客户端配置

Claude Desktop、Cursor、Windsurf、Cline 及类似客户端

使用快速入门中的 stdio 配置。不同客户端的配置文件位置各不相同,但服务条目相同:

{
  "mcpServers": {
    "test-intel": {
      "command": "npx",
      "args": ["-y", "@barissozudogru/test-intel-mcp"]
    }
  }
}
搭配 Copilot 使用 VS Code

创建 .vscode/mcp.json:

{
  "servers": {
    "test-intel": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@barissozudogru/test-intel-mcp"]
    }
  }
}
可流式传输的 HTTP

启动本地端点:

npx @barissozudogru/test-intel-mcp --http

MCP 端点为 http://localhost:3000/mcp,健康检查端点为 http://localhost:3000/health。设置 PORT 可使用其他端口。

Docker
docker build -t test-intel-mcp .
docker run -p 3000:3000 -v "$(pwd):/project" -w /project test-intel-mcp

将 HTTP 客户端连接到 http://localhost:3000/mcp。

本地开发

npm install
npm test
npm run build
node dist/index.js

要求:Node.js 18 或更高版本。

有关开发工作流,请参阅 CONTRIBUTING.md。

安全与限制

  • 分析在本地运行,无需网络访问。
  • 拒绝访问服务启动目录之外的路径。
  • 函数发现、源码与测试匹配以及复杂度评分均采用启发式方法。
  • 找不到匹配的测试文件名,并不能证明某个函数没有经过行为测试。

许可证

MIT

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。